Browse Source

New WiX projects now use installed WiX targets.

Now generating the same WiX project format as Visual Studio does when WiX 3.6 is installed.
pull/30/head
Matt Ward 13 years ago
parent
commit
894f7d93ed
  1. 18
      src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
  2. 2
      src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIFeatureTreeProject.xpt
  3. 2
      src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIInstallDirProject.xpt
  4. 2
      src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIMinimalProject.xpt
  5. 2
      src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIMondoProject.xpt
  6. 67
      src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs
  7. 20
      src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs
  8. 6
      src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
  9. 7
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

18
src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.WixBinding @@ -25,7 +25,7 @@ namespace ICSharpCode.WixBinding
public class WixProject : CompilableProject, IWixPropertyValueProvider
{
public const string DefaultTargetsFile = @"$(WixToolPath)\wix.targets";
public const string DefaultTargetsFile = "$(WixTargetsPath)";
public const string FileNameExtension = ".wixproj";
delegate bool IsFileNameMatch(string fileName);
@ -39,13 +39,16 @@ namespace ICSharpCode.WixBinding @@ -39,13 +39,16 @@ namespace ICSharpCode.WixBinding
: base(info)
{
SetProperty("OutputType", "Package");
AddWixTargetsPathProperties();
AddImport(DefaultTargetsFile, null);
}
void AddWixTargetsPathProperties()
{
string condition = " '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ";
AddConditionalProperty("WixTargetsPath", @"$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets", condition);
string wixToolPath = @"$(SharpDevelopBinPath)\Tools\Wix";
AddGuardedProperty("WixToolPath", wixToolPath);
AddGuardedProperty("WixTargetsPath", @"$(WixToolPath)\wix.targets");
AddGuardedProperty("WixTasksPath", @"$(WixToolPath)\WixTasks.dll");
this.AddImport(DefaultTargetsFile, null);
AddGuardedProperty("WixTargetsPath", @"$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets");
}
public override string Language {
@ -227,7 +230,6 @@ namespace ICSharpCode.WixBinding @@ -227,7 +230,6 @@ namespace ICSharpCode.WixBinding
public WixStartBehavior(WixProject project, ProjectBehavior next = null)
: base(project, next)
{
}
new WixProject Project {

2
src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIFeatureTreeProject.xpt

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<WixVariables>WixUILicenseRtf=license.rtf</WixVariables>
</PropertyGroup>
<ProjectItems>
<WixExtension Include="$(WixToolPath)\WixUIExtension.dll"/>
<WixExtension Include="WixUIExtension.dll"/>
</ProjectItems>
<Files>
<File name="Setup.wxs"><![CDATA[<?xml version="1.0"?>

2
src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIInstallDirProject.xpt

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<WixVariables>WixUILicenseRtf=license.rtf</WixVariables>
</PropertyGroup>
<ProjectItems>
<WixExtension Include="$(WixToolPath)\WixUIExtension.dll"/>
<WixExtension Include="WixUIExtension.dll"/>
</ProjectItems>
<Files>
<File name="Setup.wxs"><![CDATA[<?xml version="1.0"?>

2
src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIMinimalProject.xpt

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<WixVariables>WixUILicenseRtf=license.rtf</WixVariables>
</PropertyGroup>
<ProjectItems>
<WixExtension Include="$(WixToolPath)\WixUIExtension.dll"/>
<WixExtension Include="WixUIExtension.dll"/>
</ProjectItems>
<Files>
<File name="Setup.wxs"><![CDATA[<?xml version="1.0"?>

2
src/AddIns/BackendBindings/WixBinding/Project/Templates/WixUIMondoProject.xpt

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<WixVariables>WixUILicenseRtf=license.rtf</WixVariables>
</PropertyGroup>
<ProjectItems>
<WixExtension Include="$(WixToolPath)\WixUIExtension.dll"/>
<WixExtension Include="WixUIExtension.dll"/>
</ProjectItems>
<Files>
<File name="Setup.wxs"><![CDATA[<?xml version="1.0"?>

67
src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs

@ -69,58 +69,35 @@ namespace WixBinding.Tests.Project @@ -69,58 +69,35 @@ namespace WixBinding.Tests.Project
Assert.AreEqual(WixProject.DefaultTargetsFile, project.MSBuildProjectFile.Imports.Single().Project);
}
}
[Test]
public void WixToolPath()
public void FirstWixTargetsPathCondition()
{
Assert.AreEqual(@"$(SharpDevelopBinPath)\Tools\Wix", project.GetUnevalatedProperty("WixToolPath"));
ProjectPropertyElement property = GetMSBuildProperty("WixTargetsPath");
Assert.AreEqual(" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ", property.Condition);
}
[Test]
public void WixToolPathCondition()
public void FirstWixTargetsPathValue()
{
ProjectPropertyElement property = GetMSBuildProperty("WixToolPath");
Assert.AreEqual(" '$(WixToolPath)' == '' ", property.Condition);
ProjectPropertyElement property = GetMSBuildProperty("WixTargetsPath");
Assert.AreEqual(@"$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets", property.Value);
}
[Test]
public void ToolPathDoesNotExist()
public void LastWixTargetsPathCondition()
{
Assert.IsNull(project.GetUnevalatedProperty("ToolPath"));
ProjectPropertyElement property = GetLastMSBuildProperty("WixTargetsPath");
Assert.AreEqual(" '$(WixTargetsPath)' == '' ", property.Condition);
}
[Test]
public void WixMSBuildExtensionsPathShouldNotExist()
public void LastWixTargetsPathValue()
{
Assert.IsNull(project.GetUnevalatedProperty("WixMSBuildExtensionsPath"));
ProjectPropertyElement property = GetLastMSBuildProperty("WixTargetsPath");
Assert.AreEqual(@"$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets", property.Value);
}
[Test]
public void WixTargetsPath()
{
Assert.AreEqual(@"$(WixToolPath)\wix.targets", project.GetUnevalatedProperty("WixTargetsPath"));
}
[Test]
public void WixTargetsPathCondition()
{
ProjectPropertyElement property = GetMSBuildProperty("WixTargetsPath");
Assert.AreEqual(" '$(WixTargetsPath)' == '' ", property.Condition);
}
[Test]
public void WixTasksPath()
{
Assert.AreEqual(@"$(WixToolPath)\WixTasks.dll", project.GetUnevalatedProperty("WixTasksPath"));
}
[Test]
public void WixTasksPathCondition()
{
ProjectPropertyElement property = GetMSBuildProperty("WixTasksPath");
Assert.AreEqual(" '$(WixTasksPath)' == '' ", property.Condition);
}
[Test]
public void DebugConfiguration()
{
@ -166,5 +143,21 @@ namespace WixBinding.Tests.Project @@ -166,5 +143,21 @@ namespace WixBinding.Tests.Project
}
return null;
}
/// <summary>
/// Gets the last MSBuild build property with the specified name from the WixProject.
/// </summary>
ProjectPropertyElement GetLastMSBuildProperty(string name)
{
ProjectPropertyElement matchedElement = null;
foreach (ProjectPropertyGroupElement propertyGroup in project.MSBuildProjectFile.PropertyGroups) {
foreach (ProjectPropertyElement element in propertyGroup.Properties) {
if (element.Name == name) {
matchedElement = element;
}
}
}
return matchedElement;
}
}
}

20
src/AddIns/BackendBindings/WixBinding/Test/Utils/WixBindingTestsHelper.cs

@ -65,26 +65,22 @@ namespace WixBinding.Tests.Utils @@ -65,26 +65,22 @@ namespace WixBinding.Tests.Utils
}
/// <summary>
/// The MSBuildEngine sets the SharpDevelopBinPath so if
/// the SharpDevelop.Base assembly is shadow copied it refers
/// The MSBuildEngine sets the WixTargetsPath so if
/// the WixBinding.Tests assembly is shadow copied it refers
/// to the shadow copied assembly not the original. This
/// causes problems for wix projects that refer to the
/// wix.targets import via $(SharpDevelopBinPath) so here
/// we change it so it points to the real SharpDevelop
/// binary.
/// wix.targets import via $(WixTargetsPath) so here
/// we change it so it points to where the test assembly is built.
/// </summary>
public static void InitMSBuildEngine()
{
// Remove existing SharpDevelopBinPath property.
MSBuildEngine.MSBuildProperties.Remove("SharpDevelopBinPath");
// Set the SharpDevelopBinPath property so it points to
// Set the WixTargetsPath property so it points to
// the actual bin path where SharpDevelop was built not
// to the shadow copy folder.
string codeBase = typeof(MSBuildEngine).Assembly.CodeBase.Replace("file:///", String.Empty);
string codeBase = typeof(WixBindingTestsHelper).Assembly.CodeBase.Replace("file:///", String.Empty);
string folder = Path.GetDirectoryName(codeBase);
folder = Path.GetFullPath(Path.Combine(folder, @"..\"));
MSBuildEngine.MSBuildProperties["SharpDevelopBinPath"] = folder;
string fileName = Path.Combine(folder, "wix2010.targets");
MSBuildEngine.MSBuildProperties["WixTargetsPath"] = fileName;
}
/// <summary>

6
src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

@ -358,5 +358,11 @@ @@ -358,5 +358,11 @@
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\..\Tools\wix\wix2010.targets">
<Link>wix2010.targets</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

7
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -199,9 +199,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -199,9 +199,14 @@ namespace ICSharpCode.SharpDevelop.Project
/// &lt;<paramref name="name"/> Condition=" '$(<paramref name="name"/>)' == '' "
/// </summary>
protected void AddGuardedProperty(string name, string value)
{
AddConditionalProperty(name, value, " '$(" + name + ")' == '' ");
}
protected void AddConditionalProperty(string name, string value, string condition)
{
lock (SyncRoot) {
projectFile.AddProperty(name, value).Condition = " '$(" + name + ")' == '' ";
projectFile.AddProperty(name, value).Condition = condition;
}
}

Loading…
Cancel
Save