aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tools.sln49
-rw-r--r--appveyor.cmd21
-rw-r--r--appveyor.yml29
-rw-r--r--nuget.config13
-rw-r--r--src/Directory.Build.props22
-rw-r--r--src/WixToolset.BuildTasks/AssemblyInfo.cs7
-rw-r--r--src/WixToolset.BuildTasks/BuildException.cs26
-rw-r--r--src/WixToolset.BuildTasks/Candle.cs199
-rw-r--r--src/WixToolset.BuildTasks/Common.cs41
-rw-r--r--src/WixToolset.BuildTasks/ConvertReferences.cs93
-rw-r--r--src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs60
-rw-r--r--src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs271
-rw-r--r--src/WixToolset.BuildTasks/DoIt-Compile.cs192
-rw-r--r--src/WixToolset.BuildTasks/DoIt.cs342
-rw-r--r--src/WixToolset.BuildTasks/FileSearchHelperMethods.cs60
-rw-r--r--src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs146
-rw-r--r--src/WixToolset.BuildTasks/GetCabList.cs87
-rw-r--r--src/WixToolset.BuildTasks/GetLooseFileList.cs230
-rw-r--r--src/WixToolset.BuildTasks/GlobalSuppressions.cs8
-rw-r--r--src/WixToolset.BuildTasks/HeatDirectory.cs103
-rw-r--r--src/WixToolset.BuildTasks/HeatFile.cs95
-rw-r--r--src/WixToolset.BuildTasks/HeatProject.cs108
-rw-r--r--src/WixToolset.BuildTasks/HeatTask.cs121
-rw-r--r--src/WixToolset.BuildTasks/Insignia.cs118
-rw-r--r--src/WixToolset.BuildTasks/Light.cs488
-rw-r--r--src/WixToolset.BuildTasks/Lit.cs178
-rw-r--r--src/WixToolset.BuildTasks/Pyro.cs140
-rw-r--r--src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs132
-rw-r--r--src/WixToolset.BuildTasks/RefreshGeneratedFile.cs118
-rw-r--r--src/WixToolset.BuildTasks/ReplaceString.cs54
-rw-r--r--src/WixToolset.BuildTasks/ResolveWixReferences.cs212
-rw-r--r--src/WixToolset.BuildTasks/TaskBase.cs65
-rw-r--r--src/WixToolset.BuildTasks/Torch.cs159
-rw-r--r--src/WixToolset.BuildTasks/WixAssignCulture.cs229
-rw-r--r--src/WixToolset.BuildTasks/WixCommandLineBuilder.cs177
-rw-r--r--src/WixToolset.BuildTasks/WixToolTask.cs403
-rw-r--r--src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj51
-rw-r--r--src/WixToolset.BuildTasks/redirects/wix.ca.targets10
-rw-r--r--src/WixToolset.BuildTasks/redirects/wix.targets10
-rw-r--r--src/WixToolset.BuildTasks/wix.ca.targets123
-rw-r--r--src/WixToolset.BuildTasks/wix.harvest.targets511
-rw-r--r--src/WixToolset.BuildTasks/wix.signing.targets378
-rw-r--r--src/WixToolset.BuildTasks/wix.targets1356
-rw-r--r--src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.csproj28
-rw-r--r--src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.nuspec20
-rw-r--r--src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.props8
-rw-r--r--src/WixToolset.MSBuild/WixToolset.MSBuild.csproj28
-rw-r--r--src/WixToolset.MSBuild/WixToolset.MSBuild.nuspec21
-rw-r--r--src/WixToolset.MSBuild/WixToolset.MSBuild.props9
-rw-r--r--src/dotnet-wix/DotnetToolSettings.xml6
-rw-r--r--src/dotnet-wix/dotnet-wix.csproj28
-rw-r--r--src/dotnet-wix/dotnet-wix.nuspec24
-rw-r--r--src/test/WixToolsetTest.BuildTasks/FakeBuildEngine.cs33
-rw-r--r--src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs64
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/MsiPackage.wixproj57
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.de-de.wxl11
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.en-us.wxl11
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.wxs21
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/PackageComponents.wxs10
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/data/test.txt1
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MultiCulturalMsiPackage.sln31
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj55
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.en-us.wxl11
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.wxs21
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/PackageComponents.wxs10
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/data/test.txt1
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/SimpleMsiPackage.sln31
-rw-r--r--src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj32
-rw-r--r--src/wix/Program.cs123
-rw-r--r--src/wix/wix.csproj34
-rw-r--r--version.json11
71 files changed, 7975 insertions, 0 deletions
diff --git a/Tools.sln b/Tools.sln
new file mode 100644
index 00000000..1c8e1f84
--- /dev/null
+++ b/Tools.sln
@@ -0,0 +1,49 @@
1
2Microsoft Visual Studio Solution File, Format Version 12.00
3# Visual Studio 15
4VisualStudioVersion = 15.0.26124.0
5MinimumVisualStudioVersion = 15.0.26124.0
6Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.BuildTasks", "src\test\WixToolsetTest.BuildTasks\WixToolsetTest.BuildTasks.csproj", "{4B0098A4-B581-4D04-BA1E-6DC2370A7D43}"
7EndProject
8Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "wix", "src\wix\wix.csproj", "{DA5CA026-6165-48C4-BDA5-BB4B17D56A18}"
9EndProject
10Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.BuildTasks", "src\WixToolset.BuildTasks\WixToolset.BuildTasks.csproj", "{65141CE1-0BDD-41EF-8043-35B96C423CB6}"
11EndProject
12Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-wix", "src\dotnet-wix\dotnet-wix.csproj", "{938BCA04-610B-4B99-9CB7-02BF7397A972}"
13EndProject
14Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.MSBuild", "src\WixToolset.MSBuild\WixToolset.MSBuild.csproj", "{0DF5D4CF-8457-469D-8288-13775E984F70}"
15EndProject
16Global
17 GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 Debug|Any CPU = Debug|Any CPU
19 Release|Any CPU = Release|Any CPU
20 EndGlobalSection
21 GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 {4B0098A4-B581-4D04-BA1E-6DC2370A7D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 {4B0098A4-B581-4D04-BA1E-6DC2370A7D43}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 {4B0098A4-B581-4D04-BA1E-6DC2370A7D43}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 {4B0098A4-B581-4D04-BA1E-6DC2370A7D43}.Release|Any CPU.Build.0 = Release|Any CPU
26 {DA5CA026-6165-48C4-BDA5-BB4B17D56A18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 {DA5CA026-6165-48C4-BDA5-BB4B17D56A18}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 {DA5CA026-6165-48C4-BDA5-BB4B17D56A18}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 {DA5CA026-6165-48C4-BDA5-BB4B17D56A18}.Release|Any CPU.Build.0 = Release|Any CPU
30 {65141CE1-0BDD-41EF-8043-35B96C423CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 {65141CE1-0BDD-41EF-8043-35B96C423CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 {65141CE1-0BDD-41EF-8043-35B96C423CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 {65141CE1-0BDD-41EF-8043-35B96C423CB6}.Release|Any CPU.Build.0 = Release|Any CPU
34 {938BCA04-610B-4B99-9CB7-02BF7397A972}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 {938BCA04-610B-4B99-9CB7-02BF7397A972}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 {938BCA04-610B-4B99-9CB7-02BF7397A972}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 {938BCA04-610B-4B99-9CB7-02BF7397A972}.Release|Any CPU.Build.0 = Release|Any CPU
38 {0DF5D4CF-8457-469D-8288-13775E984F70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 {0DF5D4CF-8457-469D-8288-13775E984F70}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 {0DF5D4CF-8457-469D-8288-13775E984F70}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 {0DF5D4CF-8457-469D-8288-13775E984F70}.Release|Any CPU.Build.0 = Release|Any CPU
42 EndGlobalSection
43 GlobalSection(SolutionProperties) = preSolution
44 HideSolutionNode = FALSE
45 EndGlobalSection
46 GlobalSection(ExtensibilityGlobals) = postSolution
47 SolutionGuid = {AEB88B8C-8C84-4E97-9886-30CBDD32B34B}
48 EndGlobalSection
49EndGlobal
diff --git a/appveyor.cmd b/appveyor.cmd
new file mode 100644
index 00000000..25481c45
--- /dev/null
+++ b/appveyor.cmd
@@ -0,0 +1,21 @@
1@setlocal
2@pushd %~dp0
3@set _P=%~dp0build\Release\publish
4
5@rem Disable this test until publishing of native assets is worked out
6@rem dotnet build -c Release src\test\WixToolsetTest.BuildTasks
7
8dotnet publish -c Release -o %_P%\dotnet-wix\ -f netcoreapp2.1 src\wix
9dotnet publish -c Release -o %_P%\WixToolset.MSBuild\net461\ -f net461 src\WixToolset.BuildTasks
10dotnet publish -c Release -o %_P%\WixToolset.MSBuild\netcoreapp2.1\ -f netcoreapp2.1 src\WixToolset.BuildTasks
11
12@rem dotnet publish -c Release -o %_P%\netcoreapp2.1 -r win-x86 src\wix
13@rem dotnet publish -c Release -o %_P%\net461 -r win-x86 src\light
14@rem dotnet publish -c Release -o %_P%\net461 -r win-x86 src\WixToolset.BuildTasks
15
16dotnet pack -c Release src\dotnet-wix
17dotnet pack -c Release src\WixToolset.MSBuild
18@rem dotnet pack -c Release src\WixToolset.Core.InternalPackage
19
20@popd
21@endlocal
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 00000000..49a9f928
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,29 @@
1image: Visual Studio 2017
2
3version: 0.0.0.{build}
4configuration: Release
5
6environment:
7 DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
8 DOTNET_CLI_TELEMETRY_OPTOUT: 1
9 NUGET_XMLDOC_MODE: skip
10
11build_script:
12- appveyor.cmd
13
14pull_requests:
15 do_not_increment_build_number: true
16
17nuget:
18 disable_publish_on_pr: true
19
20skip_tags: true
21
22artifacts:
23- path: build\Release\**\*.nupkg
24 name: nuget
25
26notifications:
27- provider: Slack
28 incoming_webhook:
29 secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA=
diff --git a/nuget.config b/nuget.config
new file mode 100644
index 00000000..e8a0cc92
--- /dev/null
+++ b/nuget.config
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="utf-8"?>
2<configuration>
3 <packageSources>
4 <clear />
5 <add key="wixtoolset-core" value="https://ci.appveyor.com/nuget/wixtoolset-core" />
6 <add key="wixtoolset-core-native" value="https://ci.appveyor.com/nuget/wixtoolset-core-native" />
7 <add key="wixtoolset-data" value="https://ci.appveyor.com/nuget/wixtoolset-data" />
8 <add key="wixtoolset-dtf" value="https://ci.appveyor.com/nuget/wixtoolset-dtf" />
9 <add key="wixtoolset-extensibility" value="https://ci.appveyor.com/nuget/wixtoolset-extensibility" />
10 <add key="wixbuildtools" value="https://ci.appveyor.com/nuget/wixbuildtools" />
11 <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
12 </packageSources>
13</configuration> \ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 00000000..7cd6767f
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,22 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project>
5 <PropertyGroup>
6 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7 <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
8 <BaseOutputPath>$(MSBuildThisFileDirectory)..\build\$(Configuration)\</BaseOutputPath>
9 <OutputPath>$(BaseOutputPath)</OutputPath>
10
11 <Authors>WiX Toolset Team</Authors>
12 <Company>WiX Toolset</Company>
13 <Copyright>Copyright (c) .NET Foundation and contributors. All rights reserved.</Copyright>
14 <Product>WiX Toolset</Product>
15 </PropertyGroup>
16
17 <PropertyGroup>
18 <WixToolsetRootFolder>$(MSBuildThisFileDirectory)..\..\</WixToolsetRootFolder>
19 </PropertyGroup>
20
21 <Import Project="Custom.Build.props" Condition=" Exists('Custom.Build.props') " />
22</Project>
diff --git a/src/WixToolset.BuildTasks/AssemblyInfo.cs b/src/WixToolset.BuildTasks/AssemblyInfo.cs
new file mode 100644
index 00000000..ae52fce8
--- /dev/null
+++ b/src/WixToolset.BuildTasks/AssemblyInfo.cs
@@ -0,0 +1,7 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3using System.Reflection;
4using System.Runtime.InteropServices;
5
6[assembly: AssemblyCulture("")]
7[assembly: ComVisible(false)]
diff --git a/src/WixToolset.BuildTasks/BuildException.cs b/src/WixToolset.BuildTasks/BuildException.cs
new file mode 100644
index 00000000..953134ba
--- /dev/null
+++ b/src/WixToolset.BuildTasks/BuildException.cs
@@ -0,0 +1,26 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Globalization;
7
8 class BuildException : Exception
9 {
10 public BuildException()
11 {
12 }
13
14 public BuildException(string message) : base(message)
15 {
16 }
17
18 public BuildException(string message, Exception innerException) : base(message, innerException)
19 {
20 }
21
22 public BuildException(string format, params string[] args) : this(String.Format(CultureInfo.CurrentCulture, format, args))
23 {
24 }
25 }
26}
diff --git a/src/WixToolset.BuildTasks/Candle.cs b/src/WixToolset.BuildTasks/Candle.cs
new file mode 100644
index 00000000..82b15838
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Candle.cs
@@ -0,0 +1,199 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.Globalization;
9 using System.IO;
10 using System.Text;
11
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14
15 /// <summary>
16 /// An MSBuild task to run the WiX compiler.
17 /// </summary>
18 public sealed class CandleOld : WixToolTask
19 {
20 private const string CandleToolName = "candle.exe";
21
22 private string[] defineConstants;
23 private ITaskItem[] extensions;
24 private string[] includeSearchPaths;
25 private ITaskItem outputFile;
26 private bool pedantic;
27 private string installerPlatform;
28 private string preprocessToFile;
29 private bool preprocessToStdOut;
30 private ITaskItem[] sourceFiles;
31 private string extensionDirectory;
32 private string[] referencePaths;
33
34 public string[] DefineConstants
35 {
36 get { return this.defineConstants; }
37 set { this.defineConstants = value; }
38 }
39
40 public ITaskItem[] Extensions
41 {
42 get { return this.extensions; }
43 set { this.extensions = value; }
44 }
45
46 public string[] IncludeSearchPaths
47 {
48 get { return this.includeSearchPaths; }
49 set { this.includeSearchPaths = value; }
50 }
51
52 public string InstallerPlatform
53 {
54 get { return this.installerPlatform; }
55 set { this.installerPlatform = value; }
56 }
57
58 [Output]
59 [Required]
60 public ITaskItem OutputFile
61 {
62 get { return this.outputFile; }
63 set { this.outputFile = value; }
64 }
65
66 public bool Pedantic
67 {
68 get { return this.pedantic; }
69 set { this.pedantic = value; }
70 }
71
72 public string PreprocessToFile
73 {
74 get { return this.preprocessToFile; }
75 set { this.preprocessToFile = value; }
76 }
77
78 public bool PreprocessToStdOut
79 {
80 get { return this.preprocessToStdOut; }
81 set { this.preprocessToStdOut = value; }
82 }
83
84 [Required]
85 public ITaskItem[] SourceFiles
86 {
87 get { return this.sourceFiles; }
88 set { this.sourceFiles = value; }
89 }
90
91 public string ExtensionDirectory
92 {
93 get { return this.extensionDirectory; }
94 set { this.extensionDirectory = value; }
95 }
96
97 public string[] ReferencePaths
98 {
99 get { return this.referencePaths; }
100 set { this.referencePaths = value; }
101 }
102
103 /// <summary>
104 /// Get the name of the executable.
105 /// </summary>
106 /// <remarks>The ToolName is used with the ToolPath to get the location of candle.exe.</remarks>
107 /// <value>The name of the executable.</value>
108 protected override string ToolName
109 {
110 get { return CandleToolName; }
111 }
112
113 /// <summary>
114 /// Get the path to the executable.
115 /// </summary>
116 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
117 /// <returns>The full path to the executable or simply candle.exe if it's expected to be in the system path.</returns>
118 protected override string GenerateFullPathToTool()
119 {
120 // If there's not a ToolPath specified, it has to be in the system path.
121 if (String.IsNullOrEmpty(this.ToolPath))
122 {
123 return CandleToolName;
124 }
125
126 return Path.Combine(Path.GetFullPath(this.ToolPath), CandleToolName);
127 }
128
129 /// <summary>
130 /// Builds a command line from options in this task.
131 /// </summary>
132 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
133 {
134 base.BuildCommandLine(commandLineBuilder);
135
136 commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut);
137 commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile);
138 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
139 commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants);
140 commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths);
141 commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
142 commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform);
143 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
144 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
145
146 // Support per-source-file output by looking at the SourceFiles items to
147 // see if there is any "CandleOutput" metadata. If there is, we do our own
148 // appending, otherwise we fall back to the built-in "append file names" code.
149 // Note also that the wix.targets "Compile" target does *not* automagically
150 // fix the "@(CompileObjOutput)" list to include these new output names.
151 // If you really want to use this, you're going to have to clone the target
152 // in your own .targets file and create the output list yourself.
153 bool usePerSourceOutput = false;
154 if (this.SourceFiles != null)
155 {
156 foreach (ITaskItem item in this.SourceFiles)
157 {
158 if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput")))
159 {
160 usePerSourceOutput = true;
161 break;
162 }
163 }
164 }
165
166 if (usePerSourceOutput)
167 {
168 string[] newSourceNames = new string[this.SourceFiles.Length];
169 for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource)
170 {
171 ITaskItem item = this.SourceFiles[iSource];
172 if (null == item)
173 {
174 newSourceNames[iSource] = null;
175 }
176 else
177 {
178 string output = item.GetMetadata("CandleOutput");
179
180 if (!String.IsNullOrEmpty(output))
181 {
182 newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output);
183 }
184 else
185 {
186 newSourceNames[iSource] = item.ItemSpec;
187 }
188 }
189 }
190
191 commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " ");
192 }
193 else
194 {
195 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
196 }
197 }
198 }
199}
diff --git a/src/WixToolset.BuildTasks/Common.cs b/src/WixToolset.BuildTasks/Common.cs
new file mode 100644
index 00000000..803e9d14
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Common.cs
@@ -0,0 +1,41 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset
4{
5 using System;
6 using System.Globalization;
7 using System.Text;
8 using System.Text.RegularExpressions;
9
10 /// <summary>
11 /// Common WixTasks utility methods and types.
12 /// </summary>
13 internal static class Common
14 {
15 /// <summary>Metadata key name to turn off harvesting of project references.</summary>
16 public const string DoNotHarvest = "DoNotHarvest";
17
18 private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled);
19 private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters
20
21 /// <summary>
22 /// Return an identifier based on passed file/directory name
23 /// </summary>
24 /// <param name="name">File/directory name to generate identifer from</param>
25 /// <returns>A version of the name that is a legal identifier.</returns>
26 /// <remarks>This is duplicated from WiX's Common class.</remarks>
27 internal static string GetIdentifierFromName(string name)
28 {
29 string result = IllegalIdentifierCharacters.Replace(name, "_"); // replace illegal characters with "_".
30
31 // MSI identifiers must begin with an alphabetic character or an
32 // underscore. Prefix all other values with an underscore.
33 if (AddPrefix.IsMatch(name))
34 {
35 result = String.Concat("_", result);
36 }
37
38 return result;
39 }
40 }
41}
diff --git a/src/WixToolset.BuildTasks/ConvertReferences.cs b/src/WixToolset.BuildTasks/ConvertReferences.cs
new file mode 100644
index 00000000..fe137633
--- /dev/null
+++ b/src/WixToolset.BuildTasks/ConvertReferences.cs
@@ -0,0 +1,93 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Globalization;
9 using System.IO;
10 using System.Xml;
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the
16 /// WixLocalization element inside the file.
17 /// </summary>
18 public class ConvertReferences : Task
19 {
20 private string projectOutputGroups;
21 private ITaskItem[] projectReferences;
22 private ITaskItem[] harvestItems;
23
24 /// <summary>
25 /// The total list of cabs in this database
26 /// </summary>
27 [Output]
28 public ITaskItem[] HarvestItems
29 {
30 get { return this.harvestItems; }
31 }
32
33 /// <summary>
34 /// The project output groups to harvest.
35 /// </summary>
36 [Required]
37 public string ProjectOutputGroups
38 {
39 get { return this.projectOutputGroups; }
40 set { this.projectOutputGroups = value; }
41 }
42
43 /// <summary>
44 /// All the project references in the project.
45 /// </summary>
46 [Required]
47 public ITaskItem[] ProjectReferences
48 {
49 get { return this.projectReferences; }
50 set { this.projectReferences = value; }
51 }
52
53 /// <summary>
54 /// Gets a complete list of external cabs referenced by the given installer database file.
55 /// </summary>
56 /// <returns>True upon completion of the task execution.</returns>
57 public override bool Execute()
58 {
59 List<ITaskItem> newItems = new List<ITaskItem>();
60
61 foreach(ITaskItem item in this.ProjectReferences)
62 {
63 Dictionary<string, string> newItemMetadeta = new Dictionary<string, string>();
64
65 if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest)))
66 {
67 continue;
68 }
69
70 string refTargetDir = item.GetMetadata("RefTargetDir");
71 if (!String.IsNullOrEmpty(refTargetDir))
72 {
73 newItemMetadeta.Add("DirectoryIds", refTargetDir);
74 }
75
76 string refName = item.GetMetadata("Name");
77 if (!String.IsNullOrEmpty(refName))
78 {
79 newItemMetadeta.Add("ProjectName", refName);
80 }
81
82 newItemMetadeta.Add("ProjectOutputGroups", this.ProjectOutputGroups);
83
84 ITaskItem newItem = new TaskItem(item.ItemSpec, newItemMetadeta);
85 newItems.Add(newItem);
86 }
87
88 this.harvestItems = newItems.ToArray();
89
90 return true;
91 }
92 }
93}
diff --git a/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs b/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs
new file mode 100644
index 00000000..84816cac
--- /dev/null
+++ b/src/WixToolset.BuildTasks/CreateItemAvoidingInference.cs
@@ -0,0 +1,60 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Globalization;
9 using System.IO;
10 using System.Xml;
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the
16 /// WixLocalization element inside the file.
17 /// </summary>
18 public class CreateItemAvoidingInference : Task
19 {
20 private string inputProperties;
21 private ITaskItem[] outputItems;
22
23 /// <summary>
24 /// The output items.
25 /// </summary>
26 [Output]
27 public ITaskItem[] OuputItems
28 {
29 get { return this.outputItems; }
30 }
31
32 /// <summary>
33 /// The properties to converty to items.
34 /// </summary>
35 [Required]
36 public string InputProperties
37 {
38 get { return this.inputProperties; }
39 set { this.inputProperties = value; }
40 }
41
42 /// <summary>
43 /// Gets a complete list of external cabs referenced by the given installer database file.
44 /// </summary>
45 /// <returns>True upon completion of the task execution.</returns>
46 public override bool Execute()
47 {
48 List<ITaskItem> newItems = new List<ITaskItem>();
49
50 foreach (string property in this.inputProperties.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
51 {
52 newItems.Add(new TaskItem(property));
53 }
54
55 this.outputItems = newItems.ToArray();
56
57 return true;
58 }
59 }
60}
diff --git a/src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs b/src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs
new file mode 100644
index 00000000..7cda6b01
--- /dev/null
+++ b/src/WixToolset.BuildTasks/CreateProjectReferenceDefineConstants.cs
@@ -0,0 +1,271 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Globalization;
8 using System.IO;
9 using Microsoft.Build.Framework;
10 using Microsoft.Build.Utilities;
11
12 /// <summary>
13 /// An MSBuild task to create a list of preprocessor defines to be passed to candle from the
14 /// list of referenced projects.
15 /// </summary>
16 public sealed class CreateProjectReferenceDefineConstants : Task
17 {
18 private ITaskItem[] defineConstants;
19 private ITaskItem[] projectConfigurations;
20 private ITaskItem[] projectReferencePaths;
21
22 [Output]
23 public ITaskItem[] DefineConstants
24 {
25 get { return this.defineConstants; }
26 }
27
28 [Required]
29 public ITaskItem[] ProjectReferencePaths
30 {
31 get { return this.projectReferencePaths; }
32 set { this.projectReferencePaths = value; }
33 }
34
35 public ITaskItem[] ProjectConfigurations
36 {
37 get { return this.projectConfigurations; }
38 set { this.projectConfigurations = value; }
39 }
40
41 public override bool Execute()
42 {
43 List<ITaskItem> outputItems = new List<ITaskItem>();
44 Dictionary<string, string> defineConstants = new Dictionary<string, string>();
45
46 for (int i = 0; i < this.ProjectReferencePaths.Length; i++)
47 {
48 ITaskItem item = this.ProjectReferencePaths[i];
49
50 string configuration = item.GetMetadata("Configuration");
51 string fullConfiguration = item.GetMetadata("FullConfiguration");
52 string platform = item.GetMetadata("Platform");
53
54 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i);
55 string projectDir = Path.GetDirectoryName(projectPath) + Path.DirectorySeparatorChar;
56 string projectExt = Path.GetExtension(projectPath);
57 string projectFileName = Path.GetFileName(projectPath);
58 string projectName = Path.GetFileNameWithoutExtension(projectPath);
59
60 string referenceName = CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName);
61
62 string targetPath = item.GetMetadata("FullPath");
63 string targetDir = Path.GetDirectoryName(targetPath) + Path.DirectorySeparatorChar;
64 string targetExt = Path.GetExtension(targetPath);
65 string targetFileName = Path.GetFileName(targetPath);
66 string targetName = Path.GetFileNameWithoutExtension(targetPath);
67
68 // If there is no configuration metadata on the project reference task item,
69 // check for any additional configuration data provided in the optional task property.
70 if (String.IsNullOrEmpty(fullConfiguration))
71 {
72 fullConfiguration = this.FindProjectConfiguration(projectName);
73 if (!String.IsNullOrEmpty(fullConfiguration))
74 {
75 string[] typeAndPlatform = fullConfiguration.Split('|');
76 configuration = typeAndPlatform[0];
77 platform = (typeAndPlatform.Length > 1 ? typeAndPlatform[1] : String.Empty);
78 }
79 }
80
81 // write out the platform/configuration defines
82 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.Configuration", referenceName)] = configuration;
83 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.FullConfiguration", referenceName)] = fullConfiguration;
84 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.Platform", referenceName)] = platform;
85
86 // write out the ProjectX defines
87 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectDir", referenceName)] = projectDir;
88 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectExt", referenceName)] = projectExt;
89 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectFileName", referenceName)] = projectFileName;
90 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectName", referenceName)] = projectName;
91 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.ProjectPath", referenceName)] = projectPath;
92
93 // write out the TargetX defines
94 string targetDirDefine = String.Format(CultureInfo.InvariantCulture, "{0}.TargetDir", referenceName);
95 if (defineConstants.ContainsKey(targetDirDefine))
96 {
97 //if target dir was already defined, redefine it as the common root shared by multiple references from the same project
98 string commonDir = FindCommonRoot(targetDir, defineConstants[targetDirDefine]);
99 if (!String.IsNullOrEmpty(commonDir))
100 {
101 targetDir = commonDir;
102 }
103 }
104 defineConstants[targetDirDefine] = CreateProjectReferenceDefineConstants.EnsureEndsWithBackslash(targetDir);
105
106 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.TargetExt", referenceName)] = targetExt;
107 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.TargetFileName", referenceName)] = targetFileName;
108 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.TargetName", referenceName)] = targetName;
109
110 //if target path was already defined, append to it creating a list of multiple references from the same project
111 string targetPathDefine = String.Format(CultureInfo.InvariantCulture, "{0}.TargetPath", referenceName);
112 if (defineConstants.ContainsKey(targetPathDefine))
113 {
114 string oldTargetPath = defineConstants[targetPathDefine];
115 if (!targetPath.Equals(oldTargetPath, StringComparison.OrdinalIgnoreCase))
116 {
117 defineConstants[targetPathDefine] += ";" + targetPath;
118 }
119
120 //If there was only one targetpath we need to create its culture specific define
121 if (!oldTargetPath.Contains(";"))
122 {
123 string oldSubFolder = FindSubfolder(oldTargetPath, targetDir, targetFileName);
124 if (!String.IsNullOrEmpty(oldSubFolder))
125 {
126 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.{1}.TargetPath", referenceName, oldSubFolder.Replace('\\', '_'))] = oldTargetPath;
127 }
128 }
129
130 // Create a culture specific define
131 string subFolder = FindSubfolder(targetPath, targetDir, targetFileName);
132 if (!String.IsNullOrEmpty(subFolder))
133 {
134 defineConstants[String.Format(CultureInfo.InvariantCulture, "{0}.{1}.TargetPath", referenceName, subFolder.Replace('\\', '_'))] = targetPath;
135 }
136
137 }
138 else
139 {
140 defineConstants[targetPathDefine] = targetPath;
141 }
142 }
143
144 foreach (KeyValuePair<string, string> define in defineConstants)
145 {
146 outputItems.Add(new TaskItem(String.Format(CultureInfo.InvariantCulture, "{0}={1}", define.Key, define.Value)));
147 }
148
149 this.defineConstants = outputItems.ToArray();
150
151 return true;
152 }
153
154 public static string GetProjectPath(ITaskItem[] projectReferencePaths, int i)
155 {
156 return projectReferencePaths[i].GetMetadata("MSBuildSourceProjectFile");
157 }
158
159 public static string GetReferenceName(ITaskItem item, string projectName)
160 {
161 string referenceName = item.GetMetadata("Name");
162 if (String.IsNullOrEmpty(referenceName))
163 {
164 referenceName = projectName;
165 }
166
167 // We cannot have an equals sign in the variable name because it
168 // messes with the preprocessor definitions on the command line.
169 referenceName = referenceName.Replace('=', '_');
170
171 // We cannot have a double quote on the command line because it
172 // there is no way to escape it on the command line.
173 referenceName = referenceName.Replace('\"', '_');
174
175 // We cannot have parens in the variable name because the WiX
176 // preprocessor will not be able to parse it.
177 referenceName = referenceName.Replace('(', '_');
178 referenceName = referenceName.Replace(')', '_');
179
180 return referenceName;
181 }
182
183 /// <summary>
184 /// Look through the configuration data in the ProjectConfigurations property
185 /// to find the configuration for a project, if available.
186 /// </summary>
187 /// <param name="projectName">Name of the project that is being searched for.</param>
188 /// <returns>Full configuration spec, for example "Release|Win32".</returns>
189 private string FindProjectConfiguration(string projectName)
190 {
191 string configuration = String.Empty;
192
193 if (this.ProjectConfigurations != null)
194 {
195 foreach (ITaskItem configItem in this.ProjectConfigurations)
196 {
197 string configProject = configItem.ItemSpec;
198 if (configProject.Length > projectName.Length &&
199 configProject.StartsWith(projectName) &&
200 configProject[projectName.Length] == '=')
201 {
202 configuration = configProject.Substring(projectName.Length + 1);
203 break;
204 }
205 }
206 }
207
208 return configuration;
209 }
210
211 /// <summary>
212 /// Finds the common root between two paths
213 /// </summary>
214 /// <param name="path1"></param>
215 /// <param name="path2"></param>
216 /// <returns>common root on success, empty string on failure</returns>
217 private static string FindCommonRoot(string path1, string path2)
218 {
219 path1 = path1.TrimEnd(Path.DirectorySeparatorChar);
220 path2 = path2.TrimEnd(Path.DirectorySeparatorChar);
221
222 while (!String.IsNullOrEmpty(path1))
223 {
224 for (string searchPath = path2; !String.IsNullOrEmpty(searchPath); searchPath = Path.GetDirectoryName(searchPath))
225 {
226 if (path1.Equals(searchPath, StringComparison.OrdinalIgnoreCase))
227 {
228 return searchPath;
229 }
230 }
231
232 path1 = Path.GetDirectoryName(path1);
233 }
234
235 return path1;
236 }
237
238 /// <summary>
239 /// Finds the subfolder of a path, excluding a root and filename.
240 /// </summary>
241 /// <param name="path">Path to examine</param>
242 /// <param name="rootPath">Root that must be present </param>
243 /// <param name="fileName"></param>
244 /// <returns></returns>
245 private static string FindSubfolder(string path, string rootPath, string fileName)
246 {
247 if (Path.GetFileName(path).Equals(fileName, StringComparison.OrdinalIgnoreCase))
248 {
249 path = Path.GetDirectoryName(path);
250 }
251
252 if (path.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase))
253 {
254 // cut out the root and return the subpath
255 return path.Substring(rootPath.Length).Trim(Path.DirectorySeparatorChar);
256 }
257
258 return String.Empty;
259 }
260
261 private static string EnsureEndsWithBackslash(string dir)
262 {
263 if (dir[dir.Length - 1] != Path.DirectorySeparatorChar)
264 {
265 dir += Path.DirectorySeparatorChar;
266 }
267
268 return dir;
269 }
270 }
271}
diff --git a/src/WixToolset.BuildTasks/DoIt-Compile.cs b/src/WixToolset.BuildTasks/DoIt-Compile.cs
new file mode 100644
index 00000000..f89078fe
--- /dev/null
+++ b/src/WixToolset.BuildTasks/DoIt-Compile.cs
@@ -0,0 +1,192 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#if false
4namespace WixToolset.BuildTasks
5{
6 using System;
7 using System.Collections.Generic;
8 using System.IO;
9 using Microsoft.Build.Framework;
10 using WixToolset.Data;
11
12 /// <summary>
13 /// An MSBuild task to run the WiX compiler.
14 /// </summary>
15 public sealed class Candle : TaskBase
16 {
17 public string[] DefineConstants { get; set; }
18
19 public ITaskItem[] Extensions { get; set; }
20
21 public string[] IncludeSearchPaths { get; set; }
22
23 public string InstallerPlatform { get; set; }
24
25 [Output]
26 [Required]
27 public ITaskItem OutputFile { get; set; }
28
29 public bool Pedantic { get; set; }
30
31 public string PreprocessToFile { get; set; }
32
33 public bool PreprocessToStdOut { get; set; }
34
35 [Required]
36 public ITaskItem IntermediateDirectory { get; set; }
37
38 [Required]
39 public ITaskItem[] SourceFiles { get; set; }
40
41 public string ExtensionDirectory { get; set; }
42
43 public string[] ReferencePaths { get; set; }
44
45 protected override void ExecuteCore()
46 {
47 Messaging.Instance.InitializeAppName("WIX", "wix.exe");
48
49 Messaging.Instance.Display += this.DisplayMessage;
50
51 var preprocessor = new Preprocessor();
52
53 var compiler = new Compiler();
54
55 var sourceFiles = this.GatherSourceFiles();
56
57 var preprocessorVariables = this.GatherPreprocessorVariables();
58
59 foreach (var sourceFile in sourceFiles)
60 {
61 var document = preprocessor.Process(sourceFile.SourcePath, preprocessorVariables);
62
63 var intermediate = compiler.Compile(document);
64
65 intermediate.Save(sourceFile.OutputPath);
66 }
67 }
68
69 private void DisplayMessage(object sender, DisplayEventArgs e)
70 {
71 this.Log.LogMessageFromText(e.Message, MessageImportance.Normal);
72 }
73
74 private IEnumerable<SourceFile> GatherSourceFiles()
75 {
76 var files = new List<SourceFile>();
77
78 foreach (var item in this.SourceFiles)
79 {
80 var sourcePath = item.ItemSpec;
81 var outputPath = item.GetMetadata("CandleOutput") ?? this.OutputFile?.ItemSpec;
82
83 if (String.IsNullOrEmpty(outputPath))
84 {
85 outputPath = Path.Combine(this.IntermediateDirectory.ItemSpec, Path.GetFileNameWithoutExtension(sourcePath) + ".wir");
86 }
87
88 files.Add(new SourceFile(sourcePath, outputPath));
89 }
90
91 return files;
92 }
93
94 private IDictionary<string, string> GatherPreprocessorVariables()
95 {
96 var variables = new Dictionary<string, string>();
97
98 foreach (var pair in this.DefineConstants)
99 {
100 string[] value = pair.Split(new[] { '=' }, 2);
101
102 if (variables.ContainsKey(value[0]))
103 {
104 //Messaging.Instance.OnMessage(WixErrors.DuplicateVariableDefinition(value[0], (1 == value.Length) ? String.Empty : value[1], this.PreprocessorVariables[value[0]]));
105 break;
106 }
107
108 if (1 == value.Length)
109 {
110 variables.Add(value[0], String.Empty);
111 }
112 else
113 {
114 variables.Add(value[0], value[1]);
115 }
116 }
117
118 return variables;
119 }
120
121 ///// <summary>
122 ///// Builds a command line from options in this task.
123 ///// </summary>
124 //protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
125 //{
126 // base.BuildCommandLine(commandLineBuilder);
127
128 // commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut);
129 // commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile);
130 // commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
131 // commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants);
132 // commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths);
133 // commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
134 // commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform);
135 // commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
136 // commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
137
138 // // Support per-source-file output by looking at the SourceFiles items to
139 // // see if there is any "CandleOutput" metadata. If there is, we do our own
140 // // appending, otherwise we fall back to the built-in "append file names" code.
141 // // Note also that the wix.targets "Compile" target does *not* automagically
142 // // fix the "@(CompileObjOutput)" list to include these new output names.
143 // // If you really want to use this, you're going to have to clone the target
144 // // in your own .targets file and create the output list yourself.
145 // bool usePerSourceOutput = false;
146 // if (this.SourceFiles != null)
147 // {
148 // foreach (ITaskItem item in this.SourceFiles)
149 // {
150 // if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput")))
151 // {
152 // usePerSourceOutput = true;
153 // break;
154 // }
155 // }
156 // }
157
158 // if (usePerSourceOutput)
159 // {
160 // string[] newSourceNames = new string[this.SourceFiles.Length];
161 // for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource)
162 // {
163 // ITaskItem item = this.SourceFiles[iSource];
164 // if (null == item)
165 // {
166 // newSourceNames[iSource] = null;
167 // }
168 // else
169 // {
170 // string output = item.GetMetadata("CandleOutput");
171
172 // if (!String.IsNullOrEmpty(output))
173 // {
174 // newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output);
175 // }
176 // else
177 // {
178 // newSourceNames[iSource] = item.ItemSpec;
179 // }
180 // }
181 // }
182
183 // commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " ");
184 // }
185 // else
186 // {
187 // commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
188 // }
189 //}
190 }
191}
192#endif
diff --git a/src/WixToolset.BuildTasks/DoIt.cs b/src/WixToolset.BuildTasks/DoIt.cs
new file mode 100644
index 00000000..02b33522
--- /dev/null
+++ b/src/WixToolset.BuildTasks/DoIt.cs
@@ -0,0 +1,342 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Runtime.InteropServices;
8 using Microsoft.Build.Framework;
9 using Microsoft.Build.Utilities;
10 using WixToolset.Core;
11 using WixToolset.Data;
12 using WixToolset.Extensibility;
13 using WixToolset.Extensibility.Services;
14
15 /// <summary>
16 /// An MSBuild task to run the WiX compiler.
17 /// </summary>
18 public sealed class DoIt : Task
19 {
20 public string AdditionalOptions { get; set; }
21
22 public string[] Cultures { get; set; }
23
24 public string[] DefineConstants { get; set; }
25
26 public ITaskItem[] Extensions { get; set; }
27
28 public string ExtensionDirectory { get; set; }
29
30 public string[] IncludeSearchPaths { get; set; }
31
32 public string InstallerPlatform { get; set; }
33
34 [Required]
35 public ITaskItem IntermediateDirectory { get; set; }
36
37 public ITaskItem[] LocalizationFiles { get; set; }
38
39 public bool NoLogo { get; set; }
40
41 public ITaskItem[] LibraryFiles { get; set; }
42
43 [Output]
44 [Required]
45 public ITaskItem OutputFile { get; set; }
46
47 public string OutputType { get; set; }
48
49 public string PdbOutputFile { get; set; }
50
51 public bool Pedantic { get; set; }
52
53 [Required]
54 public ITaskItem[] SourceFiles { get; set; }
55
56 public string[] ReferencePaths { get; set; }
57
58
59 /// <summary>
60 /// Gets or sets whether all warnings should be suppressed.
61 /// </summary>
62 public bool SuppressAllWarnings { get; set; }
63
64 /// <summary>
65 /// Gets or sets a list of specific warnings to be suppressed.
66 /// </summary>
67 public string[] SuppressSpecificWarnings { get; set; }
68
69 /// <summary>
70 /// Gets or sets whether all warnings should be treated as errors.
71 /// </summary>
72 public bool TreatWarningsAsErrors { get; set; }
73
74 /// <summary>
75 /// Gets or sets a list of specific warnings to treat as errors.
76 /// </summary>
77 public string[] TreatSpecificWarningsAsErrors { get; set; }
78
79 /// <summary>
80 /// Gets or sets whether to display verbose output.
81 /// </summary>
82 public bool VerboseOutput { get; set; }
83
84
85 public ITaskItem[] BindInputPaths { get; set; }
86
87 public bool BindFiles { get; set; }
88
89 public ITaskItem BindContentsFile { get; set; }
90
91 public ITaskItem BindOutputsFile { get; set; }
92
93 public ITaskItem BindBuiltOutputsFile { get; set; }
94
95 public string CabinetCachePath { get; set; }
96 public int CabinetCreationThreadCount { get; set; }
97 public string DefaultCompressionLevel { get; set; }
98
99 [Output]
100 public ITaskItem UnreferencedSymbolsFile { get; set; }
101
102 public ITaskItem WixProjectFile { get; set; }
103 public string[] WixVariables { get; set; }
104
105 public bool SuppressValidation { get; set; }
106 public string[] SuppressIces { get; set; }
107 public string AdditionalCub { get; set; }
108
109 public override bool Execute()
110 {
111 try
112 {
113 this.ExecuteCore();
114 }
115 catch (Exception e)
116 {
117 this.Log.LogErrorFromException(e);
118
119 if (e is NullReferenceException || e is SEHException)
120 {
121 throw;
122 }
123 }
124
125 return !this.Log.HasLoggedErrors;
126 }
127
128 private void ExecuteCore()
129 {
130 var listener = new MsbuildMessageListener(this.Log, "WIX", this.BuildEngine.ProjectFileOfTaskNode);
131
132 var commandLineBuilder = new WixCommandLineBuilder();
133
134 commandLineBuilder.AppendTextUnquoted("build");
135
136 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
137 commandLineBuilder.AppendSwitchIfNotNull("-outputType ", this.OutputType);
138 commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
139 commandLineBuilder.AppendArrayIfNotNull("-culture ", this.Cultures);
140 commandLineBuilder.AppendArrayIfNotNull("-d ", this.DefineConstants);
141 commandLineBuilder.AppendArrayIfNotNull("-I ", this.IncludeSearchPaths);
142 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths);
143 commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation);
144 commandLineBuilder.AppendArrayIfNotNull("-sice ", this.SuppressIces);
145 commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile);
146 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
147 commandLineBuilder.AppendSwitchIfNotNull("-intermediatefolder ", this.IntermediateDirectory);
148 commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile);
149 commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile);
150 commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile);
151
152 commandLineBuilder.AppendIfTrue("-bindFiles", this.BindFiles);
153 commandLineBuilder.AppendArrayIfNotNull("-bindPath ", this.CalculateBindPathStrings());
154 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
155 commandLineBuilder.AppendArrayIfNotNull("-lib ", this.LibraryFiles);
156 commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions);
157 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
158
159 var commandLineString = commandLineBuilder.ToString();
160
161 this.Log.LogMessage(MessageImportance.Normal, "wix.exe " + commandLineString);
162
163 var serviceProvider = new WixToolsetServiceProvider();
164
165 var messaging = serviceProvider.GetService<IMessaging>();
166 messaging.SetListener(listener);
167
168 var arguments = serviceProvider.GetService<ICommandLineArguments>();
169 arguments.Populate(commandLineString);
170
171 var context = serviceProvider.GetService<ICommandLineContext>();
172 context.Messaging = messaging;
173 context.ExtensionManager = this.CreateExtensionManagerWithStandardBackends(serviceProvider, arguments.Extensions);
174 context.Arguments = arguments;
175
176 var commandLine = serviceProvider.GetService<ICommandLine>();
177 var command = commandLine.ParseStandardCommandLine(context);
178 command?.Execute();
179 }
180
181 private IExtensionManager CreateExtensionManagerWithStandardBackends(IServiceProvider serviceProvider, string[] extensions)
182 {
183 var extensionManager = serviceProvider.GetService<IExtensionManager>();
184
185 foreach (var type in new[] { typeof(WixToolset.Core.Burn.WixToolsetStandardBackend), typeof(WixToolset.Core.WindowsInstaller.WixToolsetStandardBackend) })
186 {
187 extensionManager.Add(type.Assembly);
188 }
189
190 foreach (var extension in extensions)
191 {
192 extensionManager.Load(extension);
193 }
194
195 return extensionManager;
196 }
197
198 private void DisplayMessage(object sender, DisplayEventArgs e)
199 {
200 this.Log.LogMessageFromText(e.Message, MessageImportance.Normal);
201 }
202
203 private IEnumerable<string> CalculateBindPathStrings()
204 {
205 if (null != this.BindInputPaths)
206 {
207 foreach (var item in this.BindInputPaths)
208 {
209 var path = item.GetMetadata("FullPath");
210
211 var bindName = item.GetMetadata("BindName");
212 if (!String.IsNullOrEmpty(bindName))
213 {
214 yield return String.Concat(bindName, "=", path);
215 }
216 else
217 {
218 yield return path;
219 }
220 }
221 }
222 }
223
224 ///// <summary>
225 ///// Builds a command line from options in this task.
226 ///// </summary>
227 //protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
228 //{
229 // base.BuildCommandLine(commandLineBuilder);
230
231 // commandLineBuilder.AppendIfTrue("-p", this.PreprocessToStdOut);
232 // commandLineBuilder.AppendSwitchIfNotNull("-p", this.PreprocessToFile);
233 // commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
234 // commandLineBuilder.AppendArrayIfNotNull("-d", this.DefineConstants);
235 // commandLineBuilder.AppendArrayIfNotNull("-I", this.IncludeSearchPaths);
236 // commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
237 // commandLineBuilder.AppendSwitchIfNotNull("-arch ", this.InstallerPlatform);
238 // commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
239 // commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
240
241 // // Support per-source-file output by looking at the SourceFiles items to
242 // // see if there is any "CandleOutput" metadata. If there is, we do our own
243 // // appending, otherwise we fall back to the built-in "append file names" code.
244 // // Note also that the wix.targets "Compile" target does *not* automagically
245 // // fix the "@(CompileObjOutput)" list to include these new output names.
246 // // If you really want to use this, you're going to have to clone the target
247 // // in your own .targets file and create the output list yourself.
248 // bool usePerSourceOutput = false;
249 // if (this.SourceFiles != null)
250 // {
251 // foreach (ITaskItem item in this.SourceFiles)
252 // {
253 // if (!String.IsNullOrEmpty(item.GetMetadata("CandleOutput")))
254 // {
255 // usePerSourceOutput = true;
256 // break;
257 // }
258 // }
259 // }
260
261 // if (usePerSourceOutput)
262 // {
263 // string[] newSourceNames = new string[this.SourceFiles.Length];
264 // for (int iSource = 0; iSource < this.SourceFiles.Length; ++iSource)
265 // {
266 // ITaskItem item = this.SourceFiles[iSource];
267 // if (null == item)
268 // {
269 // newSourceNames[iSource] = null;
270 // }
271 // else
272 // {
273 // string output = item.GetMetadata("CandleOutput");
274
275 // if (!String.IsNullOrEmpty(output))
276 // {
277 // newSourceNames[iSource] = String.Concat(item.ItemSpec, ";", output);
278 // }
279 // else
280 // {
281 // newSourceNames[iSource] = item.ItemSpec;
282 // }
283 // }
284 // }
285
286 // commandLineBuilder.AppendFileNamesIfNotNull(newSourceNames, " ");
287 // }
288 // else
289 // {
290 // commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
291 // }
292 //}
293
294 private class MsbuildMessageListener : IMessageListener
295 {
296 public MsbuildMessageListener(TaskLoggingHelper logger, string shortName, string longName)
297 {
298 this.Logger = logger;
299 this.ShortAppName = shortName;
300 this.LongAppName = longName;
301 }
302
303 public string ShortAppName { get; }
304
305 public string LongAppName { get; }
306
307 private TaskLoggingHelper Logger { get; }
308
309 public void Write(Message message)
310 {
311 switch (message.Level)
312 {
313 case MessageLevel.Error:
314 this.Logger.LogError(null, this.ShortAppName + message.Id.ToString(), null, message.SourceLineNumbers?.FileName ?? this.LongAppName, message.SourceLineNumbers?.LineNumber ?? 0, 0, 0, 0, message.ResourceNameOrFormat, message.MessageArgs);
315 break;
316
317 case MessageLevel.Warning:
318 this.Logger.LogWarning(null, this.ShortAppName + message.Id.ToString(), null, message.SourceLineNumbers?.FileName ?? this.LongAppName, message.SourceLineNumbers?.LineNumber ?? 0, 0, 0, 0, message.ResourceNameOrFormat, message.MessageArgs);
319 break;
320
321 default:
322 // TODO: Revisit this because something is going horribly awry. The commented out LogMessage call is crashing saying that the "message" parameter is null. When you look at the call stack, the code
323 // is in the wrong LogMessage override and the "null" subcategory was passed in as the message. Not clear why it is picking the wrong overload.
324 //if (message.Id > 0)
325 //{
326 // this.Logger.LogMessage(null, code, null, message.SourceLineNumber?.FileName, message.SourceLineNumber?.LineNumber ?? 0, 0, 0, 0, MessageImportance.Normal, message.Format, message.FormatData);
327 //}
328 //else
329 //{
330 this.Logger.LogMessage(MessageImportance.Normal, message.ResourceNameOrFormat, message.MessageArgs);
331 //}
332 break;
333 }
334 }
335
336 public void Write(string message)
337 {
338 this.Logger.LogMessage(MessageImportance.Low, message);
339 }
340 }
341 }
342}
diff --git a/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
new file mode 100644
index 00000000..6cc804eb
--- /dev/null
+++ b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
@@ -0,0 +1,60 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics.CodeAnalysis;
8 using System.IO;
9 using System.Text;
10 using Microsoft.Build.Framework;
11
12 /// <summary>
13 /// Contains helper methods on searching for files
14 /// </summary>
15 public static class FileSearchHelperMethods
16 {
17 /// <summary>
18 /// Searches for the existence of a file in multiple directories.
19 /// Search is satisfied if default file path is valid and exists. If not,
20 /// file name is extracted from default path and combined with each of the directories
21 /// looking to see if it exists. If not found, input default path is returned.
22 /// </summary>
23 /// <param name="directories">Array of directories to look in, without filenames in them</param>
24 /// <param name="defaultFullPath">Default path - to use if not found</param>
25 /// <returns>File path if file found. Empty string if not found</returns>
26 public static string SearchFilePaths(string[] directories, string defaultFullPath)
27 {
28 if (String.IsNullOrEmpty(defaultFullPath))
29 {
30 return String.Empty;
31 }
32
33 if (File.Exists(defaultFullPath))
34 {
35 return defaultFullPath;
36 }
37
38 if (directories == null)
39 {
40 return string.Empty;
41 }
42
43 string fileName = Path.GetFileName(defaultFullPath);
44 foreach (string currentPath in directories)
45 {
46 if (String.IsNullOrEmpty(currentPath) || String.IsNullOrEmpty(currentPath.Trim()))
47 {
48 continue;
49 }
50
51 if (File.Exists(Path.Combine(currentPath, fileName)))
52 {
53 return Path.Combine(currentPath, fileName);
54 }
55 }
56
57 return String.Empty;
58 }
59 }
60}
diff --git a/src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs b/src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs
new file mode 100644
index 00000000..06c8b98a
--- /dev/null
+++ b/src/WixToolset.BuildTasks/GenerateCompileWithObjectPath.cs
@@ -0,0 +1,146 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics.CodeAnalysis;
8 using System.Globalization;
9 using System.IO;
10 using System.Security.Cryptography;
11 using System.Text;
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14
15 /// <summary>
16 /// This task generates metadata on the for compile output objects.
17 /// </summary>
18 public class GenerateCompileWithObjectPath : Task
19 {
20 /// <summary>
21 /// The list of files to generate outputs for.
22 /// </summary>
23 [Required]
24 public ITaskItem[] Compile
25 {
26 get;
27 set;
28 }
29
30 /// <summary>
31 /// The list of files with ObjectPath metadata.
32 /// </summary>
33 [Output]
34 public ITaskItem[] CompileWithObjectPath
35 {
36 get;
37 private set;
38 }
39
40 /// <summary>
41 /// The folder under which all ObjectPaths should reside.
42 /// </summary>
43 [Required]
44 public string IntermediateOutputPath
45 {
46 get;
47 set;
48 }
49
50 /// <summary>
51 /// Generate an identifier by hashing data from the row.
52 /// </summary>
53 /// <param name="prefix">Three letter or less prefix for generated row identifier.</param>
54 /// <param name="args">Information to hash.</param>
55 /// <returns>The generated identifier.</returns>
56 [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")]
57 public static string GenerateIdentifier(string prefix, params string[] args)
58 {
59 string stringData = String.Join("|", args);
60 byte[] data = Encoding.Unicode.GetBytes(stringData);
61
62 // hash the data
63 byte[] hash;
64
65 using (MD5 md5 = new MD5CryptoServiceProvider())
66 {
67 hash = md5.ComputeHash(data);
68 }
69
70 // build up the identifier
71 StringBuilder identifier = new StringBuilder(35, 35);
72 identifier.Append(prefix);
73
74 // hard coded to 16 as that is the most bytes that can be used to meet the length requirements. SHA1 is 20 bytes.
75 for (int i = 0; i < 16; i++)
76 {
77 identifier.Append(hash[i].ToString("X2", CultureInfo.InvariantCulture.NumberFormat));
78 }
79
80 return identifier.ToString();
81 }
82
83 /// <summary>
84 /// Gets the full path of the directory in which the file is found.
85 /// </summary>
86 /// <param name='file'>The file from which to extract the directory.</param>
87 /// <returns>The generated identifier.</returns>
88 private static string GetDirectory(ITaskItem file)
89 {
90 return file.GetMetadata("RootDir") + file.GetMetadata("Directory");
91 }
92
93 /// <summary>
94 /// Sets the object path to use for the file.
95 /// </summary>
96 /// <param name='file'>The file on which to set the ObjectPath metadata.</param>
97 /// <remarks>
98 /// For the same input path it will return the same ObjectPath. Case is not ignored, however that isn't a problem.
99 /// </remarks>
100 private void SetObjectPath(ITaskItem file)
101 {
102 // If the source file is in the project directory or in the intermediate directory, use the intermediate directory.
103 if (string.IsNullOrEmpty(file.GetMetadata("RelativeDir")) || string.Compare(file.GetMetadata("RelativeDir"), this.IntermediateOutputPath, StringComparison.OrdinalIgnoreCase) == 0)
104 {
105 file.SetMetadata("ObjectPath", this.IntermediateOutputPath);
106 }
107 // Otherwise use a subdirectory of the intermediate directory. The subfolder's name is based on the full path of the folder containing the source file.
108 else
109 {
110 file.SetMetadata("ObjectPath", Path.Combine(this.IntermediateOutputPath, GenerateIdentifier("pth", GetDirectory(file))) + Path.DirectorySeparatorChar);
111 }
112 }
113
114 /// <summary>
115 /// Gets a complete list of external cabs referenced by the given installer database file.
116 /// </summary>
117 /// <returns>True upon completion of the task execution.</returns>
118 public override bool Execute()
119 {
120 if (string.IsNullOrEmpty(this.IntermediateOutputPath))
121 {
122 this.Log.LogError("IntermediateOutputPath parameter is required and cannot be empty");
123 return false;
124 }
125
126 if (this.Compile == null || this.Compile.Length == 0)
127 {
128 return true;
129 }
130
131 this.CompileWithObjectPath = new ITaskItem[this.Compile.Length];
132 for (int i = 0; i < this.Compile.Length; ++i)
133 {
134 this.CompileWithObjectPath[i] = new TaskItem(this.Compile[i].ItemSpec, this.Compile[i].CloneCustomMetadata());
135
136 // Do not overwrite the ObjectPath metadata if it already was set.
137 if (string.IsNullOrEmpty(this.CompileWithObjectPath[i].GetMetadata("ObjectPath")))
138 {
139 SetObjectPath(this.CompileWithObjectPath[i]);
140 }
141 }
142
143 return true;
144 }
145 }
146}
diff --git a/src/WixToolset.BuildTasks/GetCabList.cs b/src/WixToolset.BuildTasks/GetCabList.cs
new file mode 100644
index 00000000..e97538af
--- /dev/null
+++ b/src/WixToolset.BuildTasks/GetCabList.cs
@@ -0,0 +1,87 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Diagnostics;
9 using System.IO;
10 using System.Reflection;
11 using System.Xml;
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14 using WixToolset.Dtf.WindowsInstaller;
15 using Microsoft.Win32;
16
17 /// <summary>
18 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the
19 /// WixLocalization element inside the file.
20 /// </summary>
21 public class GetCabList : Task
22 {
23 private ITaskItem database;
24 private ITaskItem[] cabList;
25
26 /// <summary>
27 /// The list of database files to find cabs in
28 /// </summary>
29 [Required]
30 public ITaskItem Database
31 {
32 get { return this.database; }
33 set { this.database = value; }
34 }
35
36 /// <summary>
37 /// The total list of cabs in this database
38 /// </summary>
39 [Output]
40 public ITaskItem[] CabList
41 {
42 get { return this.cabList; }
43 }
44
45 /// <summary>
46 /// Gets a complete list of external cabs referenced by the given installer database file.
47 /// </summary>
48 /// <returns>True upon completion of the task execution.</returns>
49 public override bool Execute()
50 {
51 string databaseFile = this.database.ItemSpec;
52 Object []args = { };
53 System.Collections.Generic.List<ITaskItem> cabNames = new System.Collections.Generic.List<ITaskItem>();
54
55 // If the file doesn't exist, no cabs to return, so exit now
56 if (!File.Exists(databaseFile))
57 {
58 return true;
59 }
60
61 using (Database database = new Database(databaseFile))
62 {
63 // If the media table doesn't exist, no cabs to return, so exit now
64 if (null == database.Tables["Media"])
65 {
66 return true;
67 }
68
69 System.Collections.IList records = database.ExecuteQuery("SELECT `Cabinet` FROM `Media`", args);
70
71 foreach (string cabName in records)
72 {
73 if (String.IsNullOrEmpty(cabName) || cabName.StartsWith("#", StringComparison.Ordinal))
74 {
75 continue;
76 }
77
78 cabNames.Add(new TaskItem(Path.Combine(Path.GetDirectoryName(databaseFile), cabName)));
79 }
80 }
81
82 this.cabList = cabNames.ToArray();
83
84 return true;
85 }
86 }
87}
diff --git a/src/WixToolset.BuildTasks/GetLooseFileList.cs b/src/WixToolset.BuildTasks/GetLooseFileList.cs
new file mode 100644
index 00000000..bd403426
--- /dev/null
+++ b/src/WixToolset.BuildTasks/GetLooseFileList.cs
@@ -0,0 +1,230 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Diagnostics;
9 using System.IO;
10 using System.Reflection;
11 using System.Xml;
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14 using WixToolset.Dtf.WindowsInstaller;
15 using Microsoft.Win32;
16
17 /// <summary>
18 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the
19 /// WixLocalization element inside the file.
20 /// </summary>
21 public class GetLooseFileList : Task
22 {
23 private ITaskItem database;
24 private ITaskItem[] looseFileList;
25
26 internal const int MsidbFileAttributesNoncompressed = 8192;
27 internal const int MsidbFileAttributesCompressed = 16384;
28
29 /// <summary>
30 /// The list of database files to find Loose Files in
31 /// </summary>
32 [Required]
33 public ITaskItem Database
34 {
35 get { return this.database; }
36 set { this.database = value; }
37 }
38
39 /// <summary>
40 /// The total list of Loose Files in this database
41 /// </summary>
42 [Output]
43 public ITaskItem[] LooseFileList
44 {
45 get { return this.looseFileList; }
46 }
47
48 /// <summary>
49 /// Takes the "defaultDir" column
50 /// </summary>
51 /// <returns>Returns the corresponding sourceDir.</returns>
52 public string SourceDirFromDefaultDir(string defaultDir)
53 {
54 string sourceDir;
55
56 string[] splitted = defaultDir.Split(':');
57
58 if (1 == splitted.Length)
59 {
60 sourceDir = splitted[0];
61 }
62 else
63 {
64 sourceDir = splitted[1];
65 }
66
67 splitted = sourceDir.Split('|');
68
69 if (1 == splitted.Length)
70 {
71 sourceDir = splitted[0];
72 }
73 else
74 {
75 sourceDir = splitted[1];
76 }
77
78 return sourceDir;
79 }
80
81 /// <summary>
82 /// Takes the "FileName" column
83 /// </summary>
84 /// <returns>Returns the corresponding source file name.</returns>
85 public string SourceFileFromFileName(string fileName)
86 {
87 string sourceFile;
88
89 string[] splitted = fileName.Split('|');
90
91 if (1 == splitted.Length)
92 {
93 sourceFile = splitted[0];
94 }
95 else
96 {
97 sourceFile = splitted[1];
98 }
99
100 return sourceFile;
101 }
102
103 /// <summary>
104 /// Gets a complete list of external Loose Files referenced by the given installer database file.
105 /// </summary>
106 /// <returns>True upon completion of the task execution.</returns>
107 public override bool Execute()
108 {
109 string databaseFile = this.database.ItemSpec;
110 Object []emptyArgs = { };
111 System.Collections.Generic.List<ITaskItem> looseFileNames = new System.Collections.Generic.List<ITaskItem>();
112 Dictionary<string, string> ComponentFullDirectory = new Dictionary<string, string>();
113 Dictionary<string, string> DirectoryIdDefaultDir = new Dictionary<string, string>();
114 Dictionary<string, string> DirectoryIdParent = new Dictionary<string, string>();
115 Dictionary<string, string> DirectoryIdFullSource = new Dictionary<string, string>();
116 int i;
117 string databaseDir = Path.GetDirectoryName(databaseFile);
118
119 // If the file doesn't exist, no Loose Files to return, so exit now
120 if (!File.Exists(databaseFile))
121 {
122 return true;
123 }
124
125 using (Database database = new Database(databaseFile))
126 {
127 bool compressed = false;
128 if (2 == (database.SummaryInfo.WordCount & 2))
129 {
130 compressed = true;
131 }
132
133 // If the media table doesn't exist, no Loose Files to return, so exit now
134 if (null == database.Tables["File"])
135 {
136 return true;
137 }
138
139 // Only setup all these helpful indexes if the database is marked as uncompressed. If it's marked as compressed, files are stored at the root,
140 // so none of these indexes will be used
141 if (!compressed)
142 {
143 if (null == database.Tables["Directory"] || null == database.Tables["Component"])
144 {
145 return true;
146 }
147
148 System.Collections.IList directoryRecords = database.ExecuteQuery("SELECT `Directory`,`Directory_Parent`,`DefaultDir` FROM `Directory`", emptyArgs);
149
150 // First setup a simple index from DirectoryId to DefaultDir
151 for (i = 0; i < directoryRecords.Count; i += 3)
152 {
153 string directoryId = (string)(directoryRecords[i]);
154 string directoryParent = (string)(directoryRecords[i + 1]);
155 string defaultDir = (string)(directoryRecords[i + 2]);
156
157 string sourceDir = SourceDirFromDefaultDir(defaultDir);
158
159 DirectoryIdDefaultDir[directoryId] = sourceDir;
160 DirectoryIdParent[directoryId] = directoryParent;
161 }
162
163 // Setup an index from directory Id to the full source path
164 for (i = 0; i < directoryRecords.Count; i += 3)
165 {
166 string directoryId = (string)(directoryRecords[i]);
167 string directoryParent = (string)(directoryRecords[i + 1]);
168 string defaultDir = (string)(directoryRecords[i + 2]);
169
170 string sourceDir = DirectoryIdDefaultDir[directoryId];
171
172 // The TARGETDIR case
173 if (String.IsNullOrEmpty(directoryParent))
174 {
175 DirectoryIdFullSource[directoryId] = databaseDir;
176 }
177 else
178 {
179 string tempDirectoryParent = directoryParent;
180
181 while (!String.IsNullOrEmpty(tempDirectoryParent) && !String.IsNullOrEmpty(DirectoryIdParent[tempDirectoryParent]))
182 {
183 sourceDir = Path.Combine(DirectoryIdDefaultDir[tempDirectoryParent], sourceDir);
184
185 tempDirectoryParent = DirectoryIdParent[tempDirectoryParent];
186 }
187
188 DirectoryIdFullSource[directoryId] = Path.Combine(databaseDir, sourceDir);
189 }
190 }
191
192 // Setup an index from component Id to full directory path
193 System.Collections.IList componentRecords = database.ExecuteQuery("SELECT `Component`,`Directory_` FROM `Component`", emptyArgs);
194
195 for (i = 0; i < componentRecords.Count; i += 2)
196 {
197 string componentId = (string)(componentRecords[i]);
198 string componentDir = (string)(componentRecords[i + 1]);
199
200 ComponentFullDirectory[componentId] = DirectoryIdFullSource[componentDir];
201 }
202 }
203
204 System.Collections.IList fileRecords = database.ExecuteQuery("SELECT `Component_`,`FileName`,`Attributes` FROM `File`", emptyArgs);
205
206 for (i = 0; i < fileRecords.Count; i += 3)
207 {
208 string componentId = (string)(fileRecords[i]);
209 string fileName = SourceFileFromFileName((string)(fileRecords[i + 1]));
210 int attributes = (int)(fileRecords[i + 2]);
211
212 // If the whole database is marked uncompressed, use the directory layout made above
213 if ((!compressed && MsidbFileAttributesCompressed != (attributes & MsidbFileAttributesCompressed)))
214 {
215 looseFileNames.Add(new TaskItem(Path.GetFullPath(Path.Combine(ComponentFullDirectory[componentId], fileName))));
216 }
217 // If the database is marked as compressed, put files at the root
218 else if (compressed && (MsidbFileAttributesNoncompressed == (attributes & MsidbFileAttributesNoncompressed)))
219 {
220 looseFileNames.Add(new TaskItem(Path.GetFullPath(Path.Combine(databaseDir, fileName))));
221 }
222 }
223 }
224
225 this.looseFileList = looseFileNames.ToArray();
226
227 return true;
228 }
229 }
230}
diff --git a/src/WixToolset.BuildTasks/GlobalSuppressions.cs b/src/WixToolset.BuildTasks/GlobalSuppressions.cs
new file mode 100644
index 00000000..65c34c13
--- /dev/null
+++ b/src/WixToolset.BuildTasks/GlobalSuppressions.cs
@@ -0,0 +1,8 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "WixToolset")]
4
5[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Msi", Scope = "namespace", Target = "WixToolset.BuildTasks")]
6[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "wix")]
7[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wix")]
8[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "wix")]
diff --git a/src/WixToolset.BuildTasks/HeatDirectory.cs b/src/WixToolset.BuildTasks/HeatDirectory.cs
new file mode 100644
index 00000000..1d5f104a
--- /dev/null
+++ b/src/WixToolset.BuildTasks/HeatDirectory.cs
@@ -0,0 +1,103 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using Microsoft.Build.Framework;
6
7 public sealed class HeatDirectory : HeatTask
8 {
9 private string directory;
10 private bool keepEmptyDirectories;
11 private bool suppressCom;
12 private bool suppressRootDirectory;
13 private bool suppressRegistry;
14 private string template;
15 private string componentGroupName;
16 private string directoryRefId;
17 private string preprocessorVariable;
18
19 public string ComponentGroupName
20 {
21 get { return this.componentGroupName; }
22 set { this.componentGroupName = value; }
23 }
24
25 [Required]
26 public string Directory
27 {
28 get { return this.directory; }
29 set { this.directory = value; }
30 }
31
32 public string DirectoryRefId
33 {
34 get { return this.directoryRefId; }
35 set { this.directoryRefId = value; }
36 }
37
38 public bool KeepEmptyDirectories
39 {
40 get { return this.keepEmptyDirectories; }
41 set { this.keepEmptyDirectories = value; }
42 }
43
44 public string PreprocessorVariable
45 {
46 get { return this.preprocessorVariable; }
47 set { this.preprocessorVariable = value; }
48 }
49
50 public bool SuppressCom
51 {
52 get { return this.suppressCom; }
53 set { this.suppressCom = value; }
54 }
55
56 public bool SuppressRootDirectory
57 {
58 get { return this.suppressRootDirectory; }
59 set { this.suppressRootDirectory = value; }
60 }
61
62 public bool SuppressRegistry
63 {
64 get { return this.suppressRegistry; }
65 set { this.suppressRegistry = value; }
66 }
67
68 public string Template
69 {
70 get { return this.template; }
71 set { this.template = value; }
72 }
73
74 protected override string OperationName
75 {
76 get { return "dir"; }
77 }
78
79 /// <summary>
80 /// Generate the command line arguments to write to the response file from the properties.
81 /// </summary>
82 /// <returns>Command line string.</returns>
83 protected override string GenerateResponseFileCommands()
84 {
85 WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
86
87 commandLineBuilder.AppendSwitch(this.OperationName);
88 commandLineBuilder.AppendFileNameIfNotNull(this.Directory);
89
90 commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName);
91 commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId);
92 commandLineBuilder.AppendIfTrue("-ke", this.KeepEmptyDirectories);
93 commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom);
94 commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry);
95 commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory);
96 commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template);
97 commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable);
98
99 base.BuildCommandLine(commandLineBuilder);
100 return commandLineBuilder.ToString();
101 }
102 }
103}
diff --git a/src/WixToolset.BuildTasks/HeatFile.cs b/src/WixToolset.BuildTasks/HeatFile.cs
new file mode 100644
index 00000000..69e11b88
--- /dev/null
+++ b/src/WixToolset.BuildTasks/HeatFile.cs
@@ -0,0 +1,95 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using Microsoft.Build.Framework;
6
7 public sealed class HeatFile : HeatTask
8 {
9 private string file;
10 private bool suppressCom;
11 private bool suppressRegistry;
12 private bool suppressRootDirectory;
13 private string template;
14 private string componentGroupName;
15 private string directoryRefId;
16 private string preprocessorVariable;
17
18 public string ComponentGroupName
19 {
20 get { return this.componentGroupName; }
21 set { this.componentGroupName = value; }
22 }
23
24 public string DirectoryRefId
25 {
26 get { return this.directoryRefId; }
27 set { this.directoryRefId = value; }
28 }
29
30 [Required]
31 public string File
32 {
33 get { return this.file; }
34 set { this.file = value; }
35 }
36
37 public string PreprocessorVariable
38 {
39 get { return this.preprocessorVariable; }
40 set { this.preprocessorVariable = value; }
41 }
42
43 public bool SuppressCom
44 {
45 get { return this.suppressCom; }
46 set { this.suppressCom = value; }
47 }
48
49 public bool SuppressRegistry
50 {
51 get { return this.suppressRegistry; }
52 set { this.suppressRegistry = value; }
53 }
54
55 public bool SuppressRootDirectory
56 {
57 get { return this.suppressRootDirectory; }
58 set { this.suppressRootDirectory = value; }
59 }
60
61 public string Template
62 {
63 get { return this.template; }
64 set { this.template = value; }
65 }
66
67 protected override string OperationName
68 {
69 get { return "file"; }
70 }
71
72 /// <summary>
73 /// Generate the command line arguments to write to the response file from the properties.
74 /// </summary>
75 /// <returns>Command line string.</returns>
76 protected override string GenerateResponseFileCommands()
77 {
78 WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
79
80 commandLineBuilder.AppendSwitch(this.OperationName);
81 commandLineBuilder.AppendFileNameIfNotNull(this.File);
82
83 commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName);
84 commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId);
85 commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom);
86 commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory);
87 commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry);
88 commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template);
89 commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable);
90
91 base.BuildCommandLine(commandLineBuilder);
92 return commandLineBuilder.ToString();
93 }
94 }
95}
diff --git a/src/WixToolset.BuildTasks/HeatProject.cs b/src/WixToolset.BuildTasks/HeatProject.cs
new file mode 100644
index 00000000..8620ffa3
--- /dev/null
+++ b/src/WixToolset.BuildTasks/HeatProject.cs
@@ -0,0 +1,108 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using Microsoft.Build.Framework;
6
7 public sealed class HeatProject : HeatTask
8 {
9 private string configuration;
10 private string directoryIds;
11 private string generateType;
12 private bool generateWixVariables;
13 private string platform;
14 private string project;
15 private string projectName;
16 private string[] projectOutputGroups;
17
18 public string Configuration
19 {
20 get { return this.configuration; }
21 set { this.configuration = value; }
22 }
23
24 public string DirectoryIds
25 {
26 get { return this.directoryIds; }
27 set { this.directoryIds = value; }
28 }
29
30 public bool GenerateWixVariables
31 {
32 get { return this.generateWixVariables; }
33 set { this.generateWixVariables = value; }
34 }
35
36 public string GenerateType
37 {
38 get { return this.generateType; }
39 set { this.generateType = value; }
40 }
41
42 public string Platform
43 {
44 get { return this.platform; }
45 set { this.platform = value; }
46 }
47
48 [Required]
49 public string Project
50 {
51 get { return this.project; }
52 set { this.project = value; }
53 }
54
55 public string ProjectName
56 {
57 get { return this.projectName; }
58 set { this.projectName = value; }
59 }
60
61 public string[] ProjectOutputGroups
62 {
63 get
64 {
65 return this.projectOutputGroups;
66 }
67 set
68 {
69 this.projectOutputGroups = value;
70
71 // If it's just one string and it contains semicolons, let's
72 // split it into separate items.
73 if (this.projectOutputGroups.Length == 1)
74 {
75 this.projectOutputGroups = this.projectOutputGroups[0].Split(new char[] { ';' });
76 }
77 }
78 }
79
80 protected override string OperationName
81 {
82 get { return "project"; }
83 }
84
85 /// <summary>
86 /// Generate the command line arguments to write to the response file from the properties.
87 /// </summary>
88 /// <returns>Command line string.</returns>
89 protected override string GenerateResponseFileCommands()
90 {
91 WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
92
93 commandLineBuilder.AppendSwitch(this.OperationName);
94 commandLineBuilder.AppendFileNameIfNotNull(this.Project);
95
96 commandLineBuilder.AppendSwitchIfNotNull("-configuration ", this.Configuration);
97 commandLineBuilder.AppendSwitchIfNotNull("-directoryid ", this.DirectoryIds);
98 commandLineBuilder.AppendSwitchIfNotNull("-generate ", this.GenerateType);
99 commandLineBuilder.AppendSwitchIfNotNull("-platform ", this.Platform);
100 commandLineBuilder.AppendArrayIfNotNull("-pog ", this.ProjectOutputGroups);
101 commandLineBuilder.AppendSwitchIfNotNull("-projectname ", this.ProjectName);
102 commandLineBuilder.AppendIfTrue("-wixvar", this.GenerateWixVariables);
103
104 base.BuildCommandLine(commandLineBuilder);
105 return commandLineBuilder.ToString();
106 }
107 }
108}
diff --git a/src/WixToolset.BuildTasks/HeatTask.cs b/src/WixToolset.BuildTasks/HeatTask.cs
new file mode 100644
index 00000000..bf0a2ad3
--- /dev/null
+++ b/src/WixToolset.BuildTasks/HeatTask.cs
@@ -0,0 +1,121 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Diagnostics;
7 using System.Globalization;
8 using System.IO;
9 using System.Text;
10
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// A base MSBuild task to run the WiX harvester.
16 /// Specific harvester tasks should extend this class.
17 /// </summary>
18 public abstract class HeatTask : WixToolTask
19 {
20 private const string HeatToolName = "Heat.exe";
21
22 private bool autogenerageGuids;
23 private bool generateGuidsNow;
24 private ITaskItem outputFile;
25 private bool suppressFragments;
26 private bool suppressUniqueIds;
27 private string[] transforms;
28
29 public bool AutogenerateGuids
30 {
31 get { return this.autogenerageGuids; }
32 set { this.autogenerageGuids = value; }
33 }
34
35 public bool GenerateGuidsNow
36 {
37 get { return this.generateGuidsNow; }
38 set { this.generateGuidsNow = value; }
39 }
40
41 [Required]
42 [Output]
43 public ITaskItem OutputFile
44 {
45 get { return this.outputFile; }
46 set { this.outputFile = value; }
47 }
48
49 public bool SuppressFragments
50 {
51 get { return this.suppressFragments; }
52 set { this.suppressFragments = value; }
53 }
54
55 public bool SuppressUniqueIds
56 {
57 get { return this.suppressUniqueIds; }
58 set { this.suppressUniqueIds = value; }
59 }
60
61 public string[] Transforms
62 {
63 get { return this.transforms; }
64 set { this.transforms = value; }
65 }
66
67 /// <summary>
68 /// Get the name of the executable.
69 /// </summary>
70 /// <remarks>The ToolName is used with the ToolPath to get the location of heat.exe.</remarks>
71 /// <value>The name of the executable.</value>
72 protected override string ToolName
73 {
74 get { return HeatToolName; }
75 }
76
77 /// <summary>
78 /// Gets the name of the heat operation performed by the task.
79 /// </summary>
80 /// <remarks>This is the first parameter passed on the heat.exe command-line.</remarks>
81 /// <value>The name of the heat operation performed by the task.</value>
82 protected abstract string OperationName
83 {
84 get;
85 }
86
87 /// <summary>
88 /// Get the path to the executable.
89 /// </summary>
90 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
91 /// <returns>The full path to the executable or simply heat.exe if it's expected to be in the system path.</returns>
92 protected override string GenerateFullPathToTool()
93 {
94 // If there's not a ToolPath specified, it has to be in the system path.
95 if (String.IsNullOrEmpty(this.ToolPath))
96 {
97 return HeatToolName;
98 }
99
100 return Path.Combine(Path.GetFullPath(this.ToolPath), HeatToolName);
101 }
102
103 /// <summary>
104 /// Builds a command line from options in this task.
105 /// </summary>
106 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
107 {
108 base.BuildCommandLine(commandLineBuilder);
109
110 commandLineBuilder.AppendIfTrue("-ag", this.AutogenerateGuids);
111 commandLineBuilder.AppendIfTrue("-gg", this.GenerateGuidsNow);
112 commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
113 commandLineBuilder.AppendIfTrue("-sfrag", this.SuppressFragments);
114 commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds);
115 commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings);
116 commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms);
117 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
118 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
119 }
120 }
121}
diff --git a/src/WixToolset.BuildTasks/Insignia.cs b/src/WixToolset.BuildTasks/Insignia.cs
new file mode 100644
index 00000000..ba30963a
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Insignia.cs
@@ -0,0 +1,118 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Diagnostics;
7 using System.Globalization;
8 using System.IO;
9 using System.Text;
10
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// An MSBuild task to run the WiX transform generator.
16 /// </summary>
17 public sealed class Insignia : WixToolTask
18 {
19 private const string InsigniaToolName = "insignia.exe";
20
21 /// <summary>
22 /// Gets or sets the path to the database to inscribe.
23 /// </summary>
24 public ITaskItem DatabaseFile { get; set; }
25
26 /// <summary>
27 /// Gets or sets the path to the bundle to inscribe.
28 /// </summary>
29 public ITaskItem BundleFile { get; set; }
30
31 /// <summary>
32 /// Gets or sets the path to the original bundle that contains the attached container.
33 /// </summary>
34 public ITaskItem OriginalBundleFile { get; set; }
35
36 /// <summary>
37 /// Gets or sets the path to output the inscribed result.
38 /// </summary>
39 [Required]
40 public ITaskItem OutputFile { get; set; }
41
42 /// <summary>
43 /// Gets or sets the output. Only set if insignia does work.
44 /// </summary>
45 [Output]
46 public ITaskItem Output { get; set; }
47
48 /// <summary>
49 /// Get the name of the executable.
50 /// </summary>
51 /// <remarks>The ToolName is used with the ToolPath to get the location of Insignia.exe.</remarks>
52 /// <value>The name of the executable.</value>
53 protected override string ToolName
54 {
55 get { return InsigniaToolName; }
56 }
57
58 /// <summary>
59 /// Get the path to the executable.
60 /// </summary>
61 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
62 /// <returns>The full path to the executable or simply Insignia.exe if it's expected to be in the system path.</returns>
63 protected override string GenerateFullPathToTool()
64 {
65 // If there's not a ToolPath specified, it has to be in the system path.
66 if (String.IsNullOrEmpty(this.ToolPath))
67 {
68 return InsigniaToolName;
69 }
70
71 return Path.Combine(Path.GetFullPath(this.ToolPath), InsigniaToolName);
72 }
73
74 /// <summary>
75 /// Builds a command line from options in this task.
76 /// </summary>
77 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
78 {
79 base.BuildCommandLine(commandLineBuilder);
80
81 commandLineBuilder.AppendSwitchIfNotNull("-im ", this.DatabaseFile);
82 if (null != this.OriginalBundleFile)
83 {
84 commandLineBuilder.AppendSwitchIfNotNull("-ab ", this.BundleFile);
85 commandLineBuilder.AppendFileNameIfNotNull(this.OriginalBundleFile);
86 }
87 else
88 {
89 commandLineBuilder.AppendSwitchIfNotNull("-ib ", this.BundleFile);
90 }
91
92 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
93 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
94 }
95
96 /// <summary>
97 /// Executes a tool in-process by loading the tool assembly and invoking its entrypoint.
98 /// </summary>
99 /// <param name="pathToTool">Path to the tool to be executed; must be a managed executable.</param>
100 /// <param name="responseFileCommands">Commands to be written to a response file.</param>
101 /// <param name="commandLineCommands">Commands to be passed directly on the command-line.</param>
102 /// <returns>The tool exit code.</returns>
103 protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
104 {
105 int returnCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
106 if (0 == returnCode) // successfully did work.
107 {
108 this.Output = this.OutputFile;
109 }
110 else if (-1 == returnCode) // no work done.
111 {
112 returnCode = 0;
113 }
114
115 return returnCode;
116 }
117 }
118}
diff --git a/src/WixToolset.BuildTasks/Light.cs b/src/WixToolset.BuildTasks/Light.cs
new file mode 100644
index 00000000..b7d0b4f7
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Light.cs
@@ -0,0 +1,488 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.Diagnostics.CodeAnalysis;
9 using System.Globalization;
10 using System.IO;
11 using System.Text;
12
13 using Microsoft.Build.Framework;
14 using Microsoft.Build.Utilities;
15
16 /// <summary>
17 /// An MSBuild task to run the WiX linker.
18 /// </summary>
19 public sealed class Light : WixToolTask
20 {
21 private const string LightToolName = "Light.exe";
22
23 private string additionalCub;
24 private bool allowIdenticalRows;
25 private bool allowUnresolvedReferences;
26 private string[] baseInputPaths;
27 private ITaskItem[] bindInputPaths;
28 private bool backwardsCompatibleGuidGeneration;
29 private bool bindFiles;
30 private ITaskItem builtOutputsFile;
31 private string cabinetCachePath;
32 private int cabinetCreationThreadCount = WixCommandLineBuilder.Unspecified;
33 private ITaskItem contentsFile;
34 private string cultures;
35 private string customBinder;
36 private string defaultCompressionLevel;
37 private ITaskItem[] extensions;
38 private string[] ices;
39 private bool leaveTemporaryFiles;
40 private ITaskItem[] localizationFiles;
41 private ITaskItem[] objectFiles;
42 private bool outputAsXml;
43 private ITaskItem outputsFile;
44 private ITaskItem outputFile;
45 private ITaskItem pdbOutputFile;
46 private ITaskItem wixProjectFile;
47 private bool pedantic;
48 private bool reuseCabinetCache;
49 private bool suppressAclReset;
50 private bool suppressAssemblies;
51 private bool suppressDefaultAdminSequenceActions;
52 private bool suppressDefaultAdvSequenceActions;
53 private bool suppressDefaultUISequenceActions;
54 private bool dropUnrealTables;
55 private bool exactAssemblyVersions;
56 private bool suppressFileHashAndInfo;
57 private bool suppressFiles;
58 private bool suppressIntermediateFileVersionMatching;
59 private string[] suppressIces;
60 private bool suppressLayout;
61 private bool suppressLocalization;
62 private bool suppressMsiAssemblyTableProcessing;
63 private bool suppressPdbOutput;
64 private bool suppressSchemaValidation;
65 private bool suppressValidation;
66 private bool suppressTagSectionIdAttributeOnTuples;
67 private ITaskItem unreferencedSymbolsFile;
68 private string[] wixVariables;
69 private string extensionDirectory;
70 private string[] referencePaths;
71
72 /// <summary>
73 /// Creates a new light task.
74 /// </summary>
75 /// <remarks>
76 /// Defaults to running the task as a separate process, instead of in-proc
77 /// which is the default for WixToolTasks. This allows the Win32 manifest file
78 /// embedded in light.exe to enable reg-free COM interop with mergemod.dll.
79 /// </remarks>
80 public Light()
81 {
82 }
83
84 public string AdditionalCub
85 {
86 get { return this.additionalCub; }
87 set { this.additionalCub = value; }
88 }
89
90 public bool AllowIdenticalRows
91 {
92 get { return this.allowIdenticalRows; }
93 set { this.allowIdenticalRows = value; }
94 }
95
96 public bool AllowUnresolvedReferences
97 {
98 get { return this.allowUnresolvedReferences; }
99 set { this.allowUnresolvedReferences = value; }
100 }
101
102 // TODO: remove this property entirely in v4.0
103 [Obsolete("Use BindInputPaths instead of BaseInputPaths.")]
104 public string[] BaseInputPaths
105 {
106 get { return this.baseInputPaths; }
107 set { this.baseInputPaths = value; }
108 }
109
110 public ITaskItem[] BindInputPaths
111 {
112 get { return this.bindInputPaths; }
113 set { this.bindInputPaths = value; }
114 }
115
116 public bool BackwardsCompatibleGuidGeneration
117 {
118 get { return this.backwardsCompatibleGuidGeneration; }
119 set { this.backwardsCompatibleGuidGeneration = value; }
120 }
121
122 public bool BindFiles
123 {
124 get { return this.bindFiles; }
125 set { this.bindFiles = value; }
126 }
127
128 public string CabinetCachePath
129 {
130 get { return this.cabinetCachePath; }
131 set { this.cabinetCachePath = value; }
132 }
133
134 public int CabinetCreationThreadCount
135 {
136 get { return this.cabinetCreationThreadCount; }
137 set { this.cabinetCreationThreadCount = value; }
138 }
139
140 public ITaskItem BindBuiltOutputsFile
141 {
142 get { return this.builtOutputsFile; }
143 set { this.builtOutputsFile = value; }
144 }
145
146 public ITaskItem BindContentsFile
147 {
148 get { return this.contentsFile; }
149 set { this.contentsFile = value; }
150 }
151
152 public ITaskItem BindOutputsFile
153 {
154 get { return this.outputsFile; }
155 set { this.outputsFile = value; }
156 }
157
158 public string Cultures
159 {
160 get { return this.cultures; }
161 set { this.cultures = value; }
162 }
163
164 public string CustomBinder
165 {
166 get { return this.customBinder; }
167 set { this.customBinder = value; }
168 }
169
170 public string DefaultCompressionLevel
171 {
172 get { return this.defaultCompressionLevel; }
173 set { this.defaultCompressionLevel = value; }
174 }
175
176 public bool DropUnrealTables
177 {
178 get { return this.dropUnrealTables; }
179 set { this.dropUnrealTables = value; }
180 }
181
182 public bool ExactAssemblyVersions
183 {
184 get { return this.exactAssemblyVersions; }
185 set { this.exactAssemblyVersions = value; }
186 }
187
188 public ITaskItem[] Extensions
189 {
190 get { return this.extensions; }
191 set { this.extensions = value; }
192 }
193
194 public string[] Ices
195 {
196 get { return this.ices; }
197 set { this.ices = value; }
198 }
199
200 public bool LeaveTemporaryFiles
201 {
202 get { return this.leaveTemporaryFiles; }
203 set { this.leaveTemporaryFiles = value; }
204 }
205
206 public ITaskItem[] LocalizationFiles
207 {
208 get { return this.localizationFiles; }
209 set { this.localizationFiles = value; }
210 }
211
212 [Required]
213 public ITaskItem[] ObjectFiles
214 {
215 get { return this.objectFiles; }
216 set { this.objectFiles = value; }
217 }
218
219 public bool OutputAsXml
220 {
221 get { return this.outputAsXml; }
222 set { this.outputAsXml = value; }
223 }
224
225 [Required]
226 [Output]
227 public ITaskItem OutputFile
228 {
229 get { return this.outputFile; }
230 set { this.outputFile = value; }
231 }
232
233 [Output]
234 public ITaskItem PdbOutputFile
235 {
236 get { return this.pdbOutputFile; }
237 set { this.pdbOutputFile = value; }
238 }
239
240 public bool Pedantic
241 {
242 get { return this.pedantic; }
243 set { this.pedantic = value; }
244 }
245
246 public bool ReuseCabinetCache
247 {
248 get { return this.reuseCabinetCache; }
249 set { this.reuseCabinetCache = value; }
250 }
251
252 public bool SuppressAclReset
253 {
254 get { return this.suppressAclReset; }
255 set { this.suppressAclReset = value; }
256 }
257
258 public bool SuppressAssemblies
259 {
260 get { return this.suppressAssemblies; }
261 set { this.suppressAssemblies = value; }
262 }
263
264 public bool SuppressDefaultAdminSequenceActions
265 {
266 get { return this.suppressDefaultAdminSequenceActions; }
267 set { this.suppressDefaultAdminSequenceActions = value; }
268 }
269
270 public bool SuppressDefaultAdvSequenceActions
271 {
272 get { return this.suppressDefaultAdvSequenceActions; }
273 set { this.suppressDefaultAdvSequenceActions = value; }
274 }
275
276 public bool SuppressDefaultUISequenceActions
277 {
278 get { return this.suppressDefaultUISequenceActions; }
279 set { this.suppressDefaultUISequenceActions = value; }
280 }
281
282 public bool SuppressFileHashAndInfo
283 {
284 get { return this.suppressFileHashAndInfo; }
285 set { this.suppressFileHashAndInfo = value; }
286 }
287
288 public bool SuppressFiles
289 {
290 get { return this.suppressFiles; }
291 set { this.suppressFiles = value; }
292 }
293
294 public bool SuppressIntermediateFileVersionMatching
295 {
296 get { return this.suppressIntermediateFileVersionMatching; }
297 set { this.suppressIntermediateFileVersionMatching = value; }
298 }
299
300 public string[] SuppressIces
301 {
302 get { return this.suppressIces; }
303 set { this.suppressIces = value; }
304 }
305
306 public bool SuppressLayout
307 {
308 get { return this.suppressLayout; }
309 set { this.suppressLayout = value; }
310 }
311
312 public bool SuppressLocalization
313 {
314 get { return this.suppressLocalization; }
315 set { this.suppressLocalization = value; }
316 }
317
318 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
319 public bool SuppressMsiAssemblyTableProcessing
320 {
321 get { return this.suppressMsiAssemblyTableProcessing; }
322 set { this.suppressMsiAssemblyTableProcessing = value; }
323 }
324
325 public bool SuppressPdbOutput
326 {
327 get { return this.suppressPdbOutput; }
328 set { this.suppressPdbOutput = value; }
329 }
330
331 public bool SuppressSchemaValidation
332 {
333 get { return this.suppressSchemaValidation; }
334 set { this.suppressSchemaValidation = value; }
335 }
336
337 public bool SuppressValidation
338 {
339 get { return this.suppressValidation; }
340 set { this.suppressValidation = value; }
341 }
342
343 public bool SuppressTagSectionIdAttributeOnTuples
344 {
345 get { return this.suppressTagSectionIdAttributeOnTuples; }
346 set { this.suppressTagSectionIdAttributeOnTuples = value; }
347 }
348
349 [Output]
350 public ITaskItem UnreferencedSymbolsFile
351 {
352 get { return this.unreferencedSymbolsFile; }
353 set { this.unreferencedSymbolsFile = value; }
354 }
355
356 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
357 public ITaskItem WixProjectFile
358 {
359 get { return this.wixProjectFile; }
360 set { this.wixProjectFile = value; }
361 }
362
363 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
364 public string[] WixVariables
365 {
366 get { return this.wixVariables; }
367 set { this.wixVariables = value; }
368 }
369
370 public string ExtensionDirectory
371 {
372 get { return this.extensionDirectory; }
373 set { this.extensionDirectory = value; }
374 }
375
376 public string[] ReferencePaths
377 {
378 get { return this.referencePaths; }
379 set { this.referencePaths = value; }
380 }
381
382 /// <summary>
383 /// Get the name of the executable.
384 /// </summary>
385 /// <remarks>The ToolName is used with the ToolPath to get the location of light.exe.</remarks>
386 /// <value>The name of the executable.</value>
387 protected override string ToolName
388 {
389 get { return LightToolName; }
390 }
391
392 /// <summary>
393 /// Get the path to the executable.
394 /// </summary>
395 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
396 /// <returns>The full path to the executable or simply light.exe if it's expected to be in the system path.</returns>
397 protected override string GenerateFullPathToTool()
398 {
399 // If there's not a ToolPath specified, it has to be in the system path.
400 if (String.IsNullOrEmpty(this.ToolPath))
401 {
402 return LightToolName;
403 }
404
405 return Path.Combine(Path.GetFullPath(this.ToolPath), LightToolName);
406 }
407
408 /// <summary>
409 /// Builds a command line from options in this task.
410 /// </summary>
411 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
412 {
413 // Always put the output first so it is easy to find in the log.
414 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
415 commandLineBuilder.AppendSwitchIfNotNull("-pdbout ", this.PdbOutputFile);
416
417 base.BuildCommandLine(commandLineBuilder);
418
419 commandLineBuilder.AppendIfTrue("-ai", this.AllowIdenticalRows);
420 commandLineBuilder.AppendIfTrue("-au", this.AllowUnresolvedReferences);
421 commandLineBuilder.AppendArrayIfNotNull("-b ", this.baseInputPaths);
422
423 if (null != this.BindInputPaths)
424 {
425 Queue<String> formattedBindInputPaths = new Queue<String>();
426 foreach (ITaskItem item in this.BindInputPaths)
427 {
428 String formattedPath = string.Empty;
429 String bindName = item.GetMetadata("BindName");
430 if (!String.IsNullOrEmpty(bindName))
431 {
432 formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
433 }
434 else
435 {
436 formattedPath = item.GetMetadata("FullPath");
437 }
438 formattedBindInputPaths.Enqueue(formattedPath);
439 }
440 commandLineBuilder.AppendArrayIfNotNull("-b ", formattedBindInputPaths.ToArray());
441 }
442
443 commandLineBuilder.AppendIfTrue("-bcgg", this.BackwardsCompatibleGuidGeneration);
444 commandLineBuilder.AppendIfTrue("-bf", this.BindFiles);
445 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
446 commandLineBuilder.AppendIfSpecified("-ct ", this.CabinetCreationThreadCount);
447 commandLineBuilder.AppendSwitchIfNotNull("-cub ", this.AdditionalCub);
448 commandLineBuilder.AppendSwitchIfNotNull("-cultures:", this.Cultures);
449 commandLineBuilder.AppendSwitchIfNotNull("-binder ", this.CustomBinder);
450 commandLineBuilder.AppendArrayIfNotNull("-d", this.WixVariables);
451 commandLineBuilder.AppendSwitchIfNotNull("-dcl:", this.DefaultCompressionLevel);
452 commandLineBuilder.AppendIfTrue("-dut", this.DropUnrealTables);
453 commandLineBuilder.AppendIfTrue("-eav", this.ExactAssemblyVersions);
454 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.referencePaths);
455 commandLineBuilder.AppendArrayIfNotNull("-ice:", this.Ices);
456 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
457 commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles);
458 commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
459 commandLineBuilder.AppendIfTrue("-reusecab", this.ReuseCabinetCache);
460 commandLineBuilder.AppendIfTrue("-sa", this.SuppressAssemblies);
461 commandLineBuilder.AppendIfTrue("-sacl", this.SuppressAclReset);
462 commandLineBuilder.AppendIfTrue("-sadmin", this.SuppressDefaultAdminSequenceActions);
463 commandLineBuilder.AppendIfTrue("-sadv", this.SuppressDefaultAdvSequenceActions);
464 commandLineBuilder.AppendArrayIfNotNull("-sice:", this.SuppressIces);
465 commandLineBuilder.AppendIfTrue("-sma", this.SuppressMsiAssemblyTableProcessing);
466 commandLineBuilder.AppendIfTrue("-sf", this.SuppressFiles);
467 commandLineBuilder.AppendIfTrue("-sh", this.SuppressFileHashAndInfo);
468 commandLineBuilder.AppendIfTrue("-sl", this.SuppressLayout);
469 commandLineBuilder.AppendIfTrue("-sloc", this.SuppressLocalization);
470 commandLineBuilder.AppendIfTrue("-spdb", this.SuppressPdbOutput);
471 commandLineBuilder.AppendIfTrue("-ss", this.SuppressSchemaValidation);
472 commandLineBuilder.AppendIfTrue("-sts", this.SuppressTagSectionIdAttributeOnTuples);
473 commandLineBuilder.AppendIfTrue("-sui", this.SuppressDefaultUISequenceActions);
474 commandLineBuilder.AppendIfTrue("-sv", this.SuppressIntermediateFileVersionMatching);
475 commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation);
476 commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile);
477 commandLineBuilder.AppendIfTrue("-xo", this.OutputAsXml);
478 commandLineBuilder.AppendSwitchIfNotNull("-contentsfile ", this.BindContentsFile);
479 commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile);
480 commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile);
481 commandLineBuilder.AppendSwitchIfNotNull("-wixprojectfile ", this.WixProjectFile);
482 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
483
484 List<string> objectFilePaths = AdjustFilePaths(this.objectFiles, this.ReferencePaths);
485 commandLineBuilder.AppendFileNamesIfNotNull(objectFilePaths.ToArray(), " ");
486 }
487 }
488}
diff --git a/src/WixToolset.BuildTasks/Lit.cs b/src/WixToolset.BuildTasks/Lit.cs
new file mode 100644
index 00000000..1df964ae
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Lit.cs
@@ -0,0 +1,178 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.Globalization;
9 using System.IO;
10 using System.Text;
11
12 using Microsoft.Build.Framework;
13 using Microsoft.Build.Utilities;
14
15 /// <summary>
16 /// An MSBuild task to run the WiX lib tool.
17 /// </summary>
18 public sealed class Lit : WixToolTask
19 {
20 private const string LitToolName = "lit.exe";
21
22 private string[] baseInputPaths;
23 private ITaskItem[] bindInputPaths;
24 private bool bindFiles;
25 private ITaskItem[] extensions;
26 private ITaskItem[] localizationFiles;
27 private ITaskItem[] objectFiles;
28 private ITaskItem outputFile;
29 private bool pedantic;
30 private bool suppressIntermediateFileVersionMatching;
31 private bool suppressSchemaValidation;
32 private string extensionDirectory;
33 private string[] referencePaths;
34
35 // TODO: remove this property entirely in v4.0
36 [Obsolete("Use BindInputPaths instead of BaseInputPaths.")]
37 public string[] BaseInputPaths
38 {
39 get { return this.baseInputPaths; }
40 set { this.baseInputPaths = value; }
41 }
42
43 public ITaskItem[] BindInputPaths
44 {
45 get { return this.bindInputPaths; }
46 set { this.bindInputPaths = value; }
47 }
48
49 public bool BindFiles
50 {
51 get { return this.bindFiles; }
52 set { this.bindFiles = value; }
53 }
54
55 public ITaskItem[] Extensions
56 {
57 get { return this.extensions; }
58 set { this.extensions = value; }
59 }
60
61 public ITaskItem[] LocalizationFiles
62 {
63 get { return this.localizationFiles; }
64 set { this.localizationFiles = value; }
65 }
66
67 [Required]
68 public ITaskItem[] ObjectFiles
69 {
70 get { return this.objectFiles; }
71 set { this.objectFiles = value; }
72 }
73
74 [Required]
75 [Output]
76 public ITaskItem OutputFile
77 {
78 get { return this.outputFile; }
79 set { this.outputFile = value; }
80 }
81
82 public bool Pedantic
83 {
84 get { return this.pedantic; }
85 set { this.pedantic = value; }
86 }
87
88 public bool SuppressIntermediateFileVersionMatching
89 {
90 get { return this.suppressIntermediateFileVersionMatching; }
91 set { this.suppressIntermediateFileVersionMatching = value; }
92 }
93
94 public bool SuppressSchemaValidation
95 {
96 get { return this.suppressSchemaValidation; }
97 set { this.suppressSchemaValidation = value; }
98 }
99
100 public string ExtensionDirectory
101 {
102 get { return this.extensionDirectory; }
103 set { this.extensionDirectory = value; }
104 }
105
106 public string[] ReferencePaths
107 {
108 get { return this.referencePaths; }
109 set { this.referencePaths = value; }
110 }
111
112 /// <summary>
113 /// Get the name of the executable.
114 /// </summary>
115 /// <remarks>The ToolName is used with the ToolPath to get the location of lit.exe</remarks>
116 /// <value>The name of the executable.</value>
117 protected override string ToolName
118 {
119 get { return LitToolName; }
120 }
121
122 /// <summary>
123 /// Get the path to the executable.
124 /// </summary>
125 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
126 /// <returns>The full path to the executable or simply lit.exe if it's expected to be in the system path.</returns>
127 protected override string GenerateFullPathToTool()
128 {
129 // If there's not a ToolPath specified, it has to be in the system path.
130 if (String.IsNullOrEmpty(this.ToolPath))
131 {
132 return LitToolName;
133 }
134
135 return Path.Combine(Path.GetFullPath(this.ToolPath), LitToolName);
136 }
137
138 /// <summary>
139 /// Builds a command line from options in this task.
140 /// </summary>
141 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
142 {
143 base.BuildCommandLine(commandLineBuilder);
144
145 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
146 commandLineBuilder.AppendArrayIfNotNull("-b ", this.baseInputPaths);
147 if (null != this.BindInputPaths)
148 {
149 Queue<String> formattedBindInputPaths = new Queue<String>();
150 foreach (ITaskItem item in this.BindInputPaths)
151 {
152 String formattedPath = string.Empty;
153 String bindName = item.GetMetadata("BindName");
154 if (!String.IsNullOrEmpty(item.GetMetadata("BindName")))
155 {
156 formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
157 }
158 else
159 {
160 formattedPath = item.GetMetadata("FullPath");
161 }
162 formattedBindInputPaths.Enqueue(formattedPath);
163 }
164 commandLineBuilder.AppendArrayIfNotNull("-b ", formattedBindInputPaths.ToArray());
165 }
166 commandLineBuilder.AppendIfTrue("-bf", this.BindFiles);
167 commandLineBuilder.AppendExtensions(this.extensions, this.ExtensionDirectory, this.referencePaths);
168 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
169 commandLineBuilder.AppendIfTrue("-pedantic", this.Pedantic);
170 commandLineBuilder.AppendIfTrue("-ss", this.SuppressSchemaValidation);
171 commandLineBuilder.AppendIfTrue("-sv", this.SuppressIntermediateFileVersionMatching);
172 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
173
174 List<string> objectFilePaths = AdjustFilePaths(this.objectFiles, this.ReferencePaths);
175 commandLineBuilder.AppendFileNamesIfNotNull(objectFilePaths.ToArray(), " ");
176 }
177 }
178}
diff --git a/src/WixToolset.BuildTasks/Pyro.cs b/src/WixToolset.BuildTasks/Pyro.cs
new file mode 100644
index 00000000..f6b069da
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Pyro.cs
@@ -0,0 +1,140 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using Microsoft.Build.Framework;
9
10 /// <summary>
11 /// An MSBuild task to run the WiX patch builder.
12 /// </summary>
13 public sealed class Pyro : WixToolTask
14 {
15 private const string PyroToolName = "pyro.exe";
16
17 public bool BinaryDeltaPatch { get; set; }
18 public string CabinetCachePath { get; set; }
19 public string ExtensionDirectory { get; set; }
20 public ITaskItem[] Extensions { get; set; }
21 public bool LeaveTemporaryFiles { get; set; }
22 public string[] ReferencePaths { get; set; }
23 public bool ReuseCabinetCache { get; set; }
24 public bool SuppressAssemblies { get; set; }
25 public bool SuppressFiles { get; set; }
26 public bool SuppressFileHashAndInfo { get; set; }
27 public bool SuppressPdbOutput { get; set; }
28
29 [Required]
30 public string DefaultBaselineId { get; set; }
31
32 public ITaskItem[] BindInputPathsForTarget { get; set; }
33 public ITaskItem[] BindInputPathsForUpdated { get; set; }
34
35 [Required]
36 public ITaskItem InputFile { get; set; }
37
38 [Required]
39 [Output]
40 public ITaskItem OutputFile { get; set; }
41
42 [Output]
43 public ITaskItem PdbOutputFile { get; set; }
44
45 [Required]
46 public ITaskItem[] Transforms { get; set; }
47
48 /// <summary>
49 /// Get the name of the executable.
50 /// </summary>
51 /// <remarks>The ToolName is used with the ToolPath to get the location of pyro.exe.</remarks>
52 /// <value>The name of the executable.</value>
53 protected override string ToolName
54 {
55 get { return PyroToolName; }
56 }
57
58 /// <summary>
59 /// Get the path to the executable.
60 /// </summary>
61 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
62 /// <returns>The full path to the executable or simply torch.exe if it's expected to be in the system path.</returns>
63 protected override string GenerateFullPathToTool()
64 {
65 // If there's not a ToolPath specified, it has to be in the system path.
66 if (String.IsNullOrEmpty(this.ToolPath))
67 {
68 return PyroToolName;
69 }
70
71 return Path.Combine(Path.GetFullPath(this.ToolPath), PyroToolName);
72 }
73
74 /// <summary>
75 /// Builds a command line for bind-input paths (-bt and -bu switches).
76 /// </summary>
77 private void AppendBindInputPaths(WixCommandLineBuilder commandLineBuilder, IEnumerable<ITaskItem> bindInputPaths, string switchName)
78 {
79 if (null != bindInputPaths)
80 {
81 Queue<String> formattedBindInputPaths = new Queue<String>();
82 foreach (ITaskItem item in bindInputPaths)
83 {
84 String formattedPath = string.Empty;
85 String bindName = item.GetMetadata("BindName");
86 if (!String.IsNullOrEmpty(bindName))
87 {
88 formattedPath = String.Concat(bindName, "=", item.GetMetadata("FullPath"));
89 }
90 else
91 {
92 formattedPath = item.GetMetadata("FullPath");
93 }
94 formattedBindInputPaths.Enqueue(formattedPath);
95 }
96
97 commandLineBuilder.AppendArrayIfNotNull(switchName, formattedBindInputPaths.ToArray());
98 }
99 }
100
101 /// <summary>
102 /// Builds a command line from options in this task.
103 /// </summary>
104 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
105 {
106 // Always put the output first so it is easy to find in the log.
107 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
108 commandLineBuilder.AppendSwitchIfNotNull("-pdbout ", this.PdbOutputFile);
109
110 base.BuildCommandLine(commandLineBuilder);
111
112 this.AppendBindInputPaths(commandLineBuilder, this.BindInputPathsForTarget, "-bt ");
113 this.AppendBindInputPaths(commandLineBuilder, this.BindInputPathsForUpdated, "-bu ");
114
115 commandLineBuilder.AppendFileNameIfNotNull(this.InputFile);
116 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
117 commandLineBuilder.AppendIfTrue("-delta", this.BinaryDeltaPatch);
118 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths);
119 commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles);
120 commandLineBuilder.AppendIfTrue("-reusecab", this.ReuseCabinetCache);
121 commandLineBuilder.AppendIfTrue("-sa", this.SuppressAssemblies);
122 commandLineBuilder.AppendIfTrue("-sf", this.SuppressFiles);
123 commandLineBuilder.AppendIfTrue("-sh", this.SuppressFileHashAndInfo);
124 commandLineBuilder.AppendIfTrue("-spdb", this.SuppressPdbOutput);
125 foreach (ITaskItem transform in this.Transforms)
126 {
127 string transformPath = transform.ItemSpec;
128 string baselineId = transform.GetMetadata("OverrideBaselineId");
129 if (String.IsNullOrEmpty(baselineId))
130 {
131 baselineId = this.DefaultBaselineId;
132 }
133
134 commandLineBuilder.AppendTextIfNotNull(String.Format("-t {0} {1}", baselineId, transformPath));
135 }
136
137 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
138 }
139 }
140}
diff --git a/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs b/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs
new file mode 100644
index 00000000..5445e0cd
--- /dev/null
+++ b/src/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs
@@ -0,0 +1,132 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections;
7 using System.Globalization;
8 using System.IO;
9 using System.Text.RegularExpressions;
10 using System.Xml;
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// This task refreshes the generated file for bundle projects.
16 /// </summary>
17 public class RefreshBundleGeneratedFile : Task
18 {
19 private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled);
20 private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters
21
22 private ITaskItem[] generatedFiles;
23 private ITaskItem[] projectReferencePaths;
24
25 /// <summary>
26 /// The list of files to generate.
27 /// </summary>
28 [Required]
29 public ITaskItem[] GeneratedFiles
30 {
31 get { return this.generatedFiles; }
32 set { this.generatedFiles = value; }
33 }
34
35 /// <summary>
36 /// All the project references in the project.
37 /// </summary>
38 [Required]
39 public ITaskItem[] ProjectReferencePaths
40 {
41 get { return this.projectReferencePaths; }
42 set { this.projectReferencePaths = value; }
43 }
44
45 /// <summary>
46 /// Gets a complete list of external cabs referenced by the given installer database file.
47 /// </summary>
48 /// <returns>True upon completion of the task execution.</returns>
49 public override bool Execute()
50 {
51 ArrayList payloadGroupRefs = new ArrayList();
52 ArrayList packageGroupRefs = new ArrayList();
53 for (int i = 0; i < this.ProjectReferencePaths.Length; i++)
54 {
55 ITaskItem item = this.ProjectReferencePaths[i];
56
57 if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest)))
58 {
59 continue;
60 }
61
62 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i);
63 string projectName = Path.GetFileNameWithoutExtension(projectPath);
64 string referenceName = Common.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName));
65
66 string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';');
67 foreach (string pog in pogs)
68 {
69 if (!String.IsNullOrEmpty(pog))
70 {
71 // TODO: Add payload group references and package group references once heat is generating them
72 ////payloadGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog));
73 packageGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog));
74 }
75 }
76 }
77
78 XmlDocument doc = new XmlDocument();
79
80 XmlProcessingInstruction head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
81 doc.AppendChild(head);
82
83 XmlElement rootElement = doc.CreateElement("Wix");
84 rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs");
85 doc.AppendChild(rootElement);
86
87 XmlElement fragment = doc.CreateElement("Fragment");
88 rootElement.AppendChild(fragment);
89
90 XmlElement payloadGroup = doc.CreateElement("PayloadGroup");
91 payloadGroup.SetAttribute("Id", "Bundle.Generated.Payloads");
92 fragment.AppendChild(payloadGroup);
93
94 XmlElement packageGroup = doc.CreateElement("PackageGroup");
95 packageGroup.SetAttribute("Id", "Bundle.Generated.Packages");
96 fragment.AppendChild(packageGroup);
97
98 foreach (string payloadGroupRef in payloadGroupRefs)
99 {
100 XmlElement payloadGroupRefElement = doc.CreateElement("PayloadGroupRef");
101 payloadGroupRefElement.SetAttribute("Id", payloadGroupRef);
102 payloadGroup.AppendChild(payloadGroupRefElement);
103 }
104
105 foreach (string packageGroupRef in packageGroupRefs)
106 {
107 XmlElement packageGroupRefElement = doc.CreateElement("PackageGroupRef");
108 packageGroupRefElement.SetAttribute("Id", packageGroupRef);
109 packageGroup.AppendChild(packageGroupRefElement);
110 }
111
112 foreach (ITaskItem item in this.GeneratedFiles)
113 {
114 string fullPath = item.GetMetadata("FullPath");
115
116 payloadGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Payloads");
117 packageGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Packages");
118 try
119 {
120 doc.Save(fullPath);
121 }
122 catch (Exception e)
123 {
124 // e.Message will be something like: "Access to the path 'fullPath' is denied."
125 this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message);
126 }
127 }
128
129 return true;
130 }
131 }
132}
diff --git a/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs b/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs
new file mode 100644
index 00000000..fdfc4774
--- /dev/null
+++ b/src/WixToolset.BuildTasks/RefreshGeneratedFile.cs
@@ -0,0 +1,118 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections;
7 using System.Globalization;
8 using System.IO;
9 using System.Text.RegularExpressions;
10 using System.Xml;
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// This task refreshes the generated file that contains ComponentGroupRefs
16 /// to harvested output.
17 /// </summary>
18 public class RefreshGeneratedFile : Task
19 {
20 private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]", RegexOptions.Compiled);
21 private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}", RegexOptions.Compiled); // non 'words' and assorted valid characters
22
23 private ITaskItem[] generatedFiles;
24 private ITaskItem[] projectReferencePaths;
25
26 /// <summary>
27 /// The list of files to generate.
28 /// </summary>
29 [Required]
30 public ITaskItem[] GeneratedFiles
31 {
32 get { return this.generatedFiles; }
33 set { this.generatedFiles = value; }
34 }
35
36 /// <summary>
37 /// All the project references in the project.
38 /// </summary>
39 [Required]
40 public ITaskItem[] ProjectReferencePaths
41 {
42 get { return this.projectReferencePaths; }
43 set { this.projectReferencePaths = value; }
44 }
45
46 /// <summary>
47 /// Gets a complete list of external cabs referenced by the given installer database file.
48 /// </summary>
49 /// <returns>True upon completion of the task execution.</returns>
50 public override bool Execute()
51 {
52 ArrayList componentGroupRefs = new ArrayList();
53 for (int i = 0; i < this.ProjectReferencePaths.Length; i++)
54 {
55 ITaskItem item = this.ProjectReferencePaths[i];
56
57 if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest)))
58 {
59 continue;
60 }
61
62 string projectPath = CreateProjectReferenceDefineConstants.GetProjectPath(this.ProjectReferencePaths, i);
63 string projectName = Path.GetFileNameWithoutExtension(projectPath);
64 string referenceName = Common.GetIdentifierFromName(CreateProjectReferenceDefineConstants.GetReferenceName(item, projectName));
65
66 string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';');
67 foreach (string pog in pogs)
68 {
69 if (!String.IsNullOrEmpty(pog))
70 {
71 componentGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog));
72 }
73 }
74 }
75
76 XmlDocument doc = new XmlDocument();
77
78 XmlProcessingInstruction head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
79 doc.AppendChild(head);
80
81 XmlElement rootElement = doc.CreateElement("Wix");
82 rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs");
83 doc.AppendChild(rootElement);
84
85 XmlElement fragment = doc.CreateElement("Fragment");
86 rootElement.AppendChild(fragment);
87
88 XmlElement componentGroup = doc.CreateElement("ComponentGroup");
89 componentGroup.SetAttribute("Id", "Product.Generated");
90 fragment.AppendChild(componentGroup);
91
92 foreach (string componentGroupRef in componentGroupRefs)
93 {
94 XmlElement componentGroupRefElement = doc.CreateElement("ComponentGroupRef");
95 componentGroupRefElement.SetAttribute("Id", componentGroupRef);
96 componentGroup.AppendChild(componentGroupRefElement);
97 }
98
99 foreach (ITaskItem item in this.GeneratedFiles)
100 {
101 string fullPath = item.GetMetadata("FullPath");
102
103 componentGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath));
104 try
105 {
106 doc.Save(fullPath);
107 }
108 catch (Exception e)
109 {
110 // e.Message will be something like: "Access to the path 'fullPath' is denied."
111 this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message);
112 }
113 }
114
115 return true;
116 }
117 }
118}
diff --git a/src/WixToolset.BuildTasks/ReplaceString.cs b/src/WixToolset.BuildTasks/ReplaceString.cs
new file mode 100644
index 00000000..e5041923
--- /dev/null
+++ b/src/WixToolset.BuildTasks/ReplaceString.cs
@@ -0,0 +1,54 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using Microsoft.Build.Framework;
7 using Microsoft.Build.Utilities;
8
9 /// <summary>
10 /// Replaces occurances of OldValues with NewValues in String.
11 /// </summary>
12 public class ReplaceString : Task
13 {
14 /// <summary>
15 /// Text to operate on.
16 /// </summary>
17 [Output]
18 [Required]
19 public string Text { get; set; }
20
21 /// <summary>
22 /// List of old values to replace.
23 /// </summary>
24 [Required]
25 public string OldValue { get; set; }
26
27 /// <summary>
28 /// List of new values to replace old values with. If not specified, occurances of OldValue will be removed.
29 /// </summary>
30 public string NewValue { get; set; }
31
32 /// <summary>
33 /// Does the string replacement.
34 /// </summary>
35 /// <returns></returns>
36 public override bool Execute()
37 {
38 if (String.IsNullOrEmpty(this.Text))
39 {
40 return true;
41 }
42
43 if (String.IsNullOrEmpty(this.OldValue))
44 {
45 Log.LogError("OldValue must be specified");
46 return false;
47 }
48
49 this.Text = this.Text.Replace(this.OldValue, this.NewValue);
50
51 return true;
52 }
53 }
54}
diff --git a/src/WixToolset.BuildTasks/ResolveWixReferences.cs b/src/WixToolset.BuildTasks/ResolveWixReferences.cs
new file mode 100644
index 00000000..9b8cfe6f
--- /dev/null
+++ b/src/WixToolset.BuildTasks/ResolveWixReferences.cs
@@ -0,0 +1,212 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using Microsoft.Build.Utilities;
8 using Microsoft.Build.Framework;
9 using System.IO;
10
11 /// <summary>
12 /// This task searches for paths to references using the order specified in SearchPaths.
13 /// </summary>
14 public class ResolveWixReferences : Task
15 {
16 /// <summary>
17 /// Token value used in SearchPaths to indicate that the item's HintPath metadata should
18 /// be searched as a full file path to resolve the reference.
19 /// Must match wix.targets, case sensitive.
20 /// </summary>
21 private const string HintPathToken = "{HintPathFromItem}";
22
23 /// <summary>
24 /// Token value used in SearchPaths to indicate that the item's Identity should
25 /// be searched as a full file path to resolve the reference.
26 /// Must match wix.targets, case sensitive.
27 /// </summary>
28 private const string RawFileNameToken = "{RawFileName}";
29
30 /// <summary>
31 /// The list of references to resolve.
32 /// </summary>
33 [Required]
34 public ITaskItem[] WixReferences
35 {
36 get;
37 set;
38 }
39
40 /// <summary>
41 /// The directories or special locations that are searched to find the files
42 /// on disk that represent the references. The order in which the search paths are listed
43 /// is important. For each reference, the list of paths is searched from left to right.
44 /// When a file that represents the reference is found, that search stops and the search
45 /// for the next reference starts.
46 ///
47 /// This parameter accepts the following types of values:
48 /// A directory path.
49 /// {HintPathFromItem}: Specifies that the task will examine the HintPath metadata
50 /// of the base item.
51 /// TODO : {CandidateAssemblyFiles}: Specifies that the task will examine the files
52 /// passed in through the CandidateAssemblyFiles parameter.
53 /// TODO : {Registry:_AssemblyFoldersBase_, _RuntimeVersion_, _AssemblyFoldersSuffix_}:
54 /// TODO : {AssemblyFolders}: Specifies the task will use the Visual Studio.NET 2003
55 /// finding-assemblies-from-registry scheme.
56 /// TODO : {GAC}: Specifies the task will search in the GAC.
57 /// {RawFileName}: Specifies the task will consider the Include value of the item to be
58 /// an exact path and file name.
59 /// </summary>
60 public string[] SearchPaths
61 {
62 get;
63 set;
64 }
65
66 /// <summary>
67 /// The filename extension(s) to be checked when searching.
68 /// </summary>
69 public string[] SearchFilenameExtensions
70 {
71 get;
72 set;
73 }
74
75 /// <summary>
76 /// Output items that contain the same metadata as input references and have been resolved to full paths.
77 /// </summary>
78 [Output]
79 public ITaskItem[] ResolvedWixReferences
80 {
81 get;
82 private set;
83 }
84
85 /// <summary>
86 /// Resolves reference paths by searching for referenced items using the specified SearchPaths.
87 /// </summary>
88 /// <returns>True on success, or throws an exception on failure.</returns>
89 public override bool Execute()
90 {
91 List<ITaskItem> resolvedReferences = new List<ITaskItem>();
92
93 foreach (ITaskItem reference in this.WixReferences)
94 {
95 ITaskItem resolvedReference = ResolveWixReferences.ResolveReference(reference, this.SearchPaths, this.SearchFilenameExtensions, this.Log);
96
97 this.Log.LogMessage(MessageImportance.Low, "Resolved path {0}", resolvedReference.ItemSpec);
98 resolvedReferences.Add(resolvedReference);
99 }
100
101 this.ResolvedWixReferences = resolvedReferences.ToArray();
102 return true;
103 }
104
105 /// <summary>
106 /// Resolves a single reference item by searcheing for referenced items using the specified SearchPaths.
107 /// This method is made public so the resolution logic can be reused by other tasks.
108 /// </summary>
109 /// <param name="reference">The referenced item.</param>
110 /// <param name="searchPaths">The paths to search.</param>
111 /// <param name="searchFilenameExtensions">Filename extensions to check.</param>
112 /// <param name="log">Logging helper.</param>
113 /// <returns>The resolved reference item, or the original reference if it could not be resolved.</returns>
114 public static ITaskItem ResolveReference(ITaskItem reference, string[] searchPaths, string[] searchFilenameExtensions, TaskLoggingHelper log)
115 {
116 if (reference == null)
117 {
118 throw new ArgumentNullException("reference");
119 }
120
121 if (searchPaths == null)
122 {
123 // Nothing to search, so just return the original reference item.
124 return reference;
125 }
126
127 if (searchFilenameExtensions == null)
128 {
129 searchFilenameExtensions = new string[] { };
130 }
131
132 // Copy all the metadata from the source
133 TaskItem resolvedReference = new TaskItem(reference);
134 log.LogMessage(MessageImportance.Low, "WixReference: {0}", reference.ItemSpec);
135
136 // Now find the resolved path based on our order of precedence
137 foreach (string searchPath in searchPaths)
138 {
139 log.LogMessage(MessageImportance.Low, "Trying {0}", searchPath);
140 if (searchPath.Equals(HintPathToken, StringComparison.Ordinal))
141 {
142 string path = reference.GetMetadata("HintPath");
143 log.LogMessage(MessageImportance.Low, "Trying path {0}", path);
144 if (File.Exists(path))
145 {
146 resolvedReference.ItemSpec = path;
147 break;
148 }
149 }
150 else if (searchPath.Equals(RawFileNameToken, StringComparison.Ordinal))
151 {
152 log.LogMessage(MessageImportance.Low, "Trying path {0}", resolvedReference.ItemSpec);
153 if (File.Exists(resolvedReference.ItemSpec))
154 {
155 break;
156 }
157
158 if (ResolveWixReferences.ResolveFilenameExtensions(resolvedReference,
159 resolvedReference.ItemSpec, searchFilenameExtensions, log))
160 {
161 break;
162 }
163 }
164 else
165 {
166 string path = Path.Combine(searchPath, Path.GetFileName(reference.ItemSpec));
167 log.LogMessage(MessageImportance.Low, "Trying path {0}", path);
168 if (File.Exists(path))
169 {
170 resolvedReference.ItemSpec = path;
171 break;
172 }
173
174 if (ResolveWixReferences.ResolveFilenameExtensions(resolvedReference,
175 path, searchFilenameExtensions, log))
176 {
177 break;
178 }
179 }
180 }
181
182 // Normalize the item path
183 resolvedReference.ItemSpec = resolvedReference.GetMetadata("FullPath");
184
185 return resolvedReference;
186 }
187
188 /// <summary>
189 /// Helper method for checking filename extensions when resolving references.
190 /// </summary>
191 /// <param name="reference">The reference being resolved.</param>
192 /// <param name="basePath">Full filename path without extension.</param>
193 /// <param name="filenameExtensions">Filename extensions to check.</param>
194 /// <param name="log">Logging helper.</param>
195 /// <returns>True if the item was resolved, else false.</returns>
196 private static bool ResolveFilenameExtensions(ITaskItem reference, string basePath, string[] filenameExtensions, TaskLoggingHelper log)
197 {
198 foreach (string filenameExtension in filenameExtensions)
199 {
200 string path = basePath + filenameExtension;
201 log.LogMessage(MessageImportance.Low, "Trying path {0}", path);
202 if (File.Exists(path))
203 {
204 reference.ItemSpec = path;
205 return true;
206 }
207 }
208
209 return false;
210 }
211 }
212}
diff --git a/src/WixToolset.BuildTasks/TaskBase.cs b/src/WixToolset.BuildTasks/TaskBase.cs
new file mode 100644
index 00000000..3d58fc06
--- /dev/null
+++ b/src/WixToolset.BuildTasks/TaskBase.cs
@@ -0,0 +1,65 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using Microsoft.Build.Utilities;
6
7 public abstract class TaskBase : Task
8 {
9 public string ToolPath { get; set; }
10
11 public string AdditionalOptions { get; set; }
12
13 public bool RunAsSeparateProcess { get; set; }
14
15 /// <summary>
16 /// Gets or sets whether all warnings should be suppressed.
17 /// </summary>
18 public bool SuppressAllWarnings { get; set; }
19
20 /// <summary>
21 /// Gets or sets a list of specific warnings to be suppressed.
22 /// </summary>
23 public string[] SuppressSpecificWarnings { get; set; }
24
25 /// <summary>
26 /// Gets or sets whether all warnings should be treated as errors.
27 /// </summary>
28 public bool TreatWarningsAsErrors { get; set; }
29
30 /// <summary>
31 /// Gets or sets a list of specific warnings to treat as errors.
32 /// </summary>
33 public string[] TreatSpecificWarningsAsErrors { get; set; }
34
35 /// <summary>
36 /// Gets or sets whether to display verbose output.
37 /// </summary>
38 public bool VerboseOutput { get; set; }
39
40 /// <summary>
41 /// Gets or sets whether to display the logo.
42 /// </summary>
43 public bool NoLogo { get; set; }
44
45 public override bool Execute()
46 {
47 try
48 {
49 this.ExecuteCore();
50 }
51 catch (BuildException e)
52 {
53 this.Log.LogErrorFromException(e);
54 }
55 catch (Data.WixException e)
56 {
57 this.Log.LogErrorFromException(e);
58 }
59
60 return !this.Log.HasLoggedErrors;
61 }
62
63 protected abstract void ExecuteCore();
64 }
65}
diff --git a/src/WixToolset.BuildTasks/Torch.cs b/src/WixToolset.BuildTasks/Torch.cs
new file mode 100644
index 00000000..e18ed315
--- /dev/null
+++ b/src/WixToolset.BuildTasks/Torch.cs
@@ -0,0 +1,159 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Diagnostics;
7 using System.Globalization;
8 using System.IO;
9 using System.Text;
10
11 using Microsoft.Build.Framework;
12 using Microsoft.Build.Utilities;
13
14 /// <summary>
15 /// An MSBuild task to run the WiX transform generator.
16 /// </summary>
17 public sealed class Torch : WixToolTask
18 {
19 private const string TorchToolName = "Torch.exe";
20
21 private bool adminImage;
22 private ITaskItem baselineFile;
23 private string binaryExtractionPath;
24 private bool inputIsXml;
25 private bool leaveTemporaryFiles;
26 private bool outputAsXml;
27 private ITaskItem outputFile;
28 private bool preserveUnmodifiedContent;
29 private string suppressTransformErrorFlags;
30 private string transformValidationFlags;
31 private string transformValidationType;
32 private ITaskItem updateFile;
33
34 public bool AdminImage
35 {
36 get { return this.adminImage; }
37 set { this.adminImage = value; }
38 }
39
40
41 [Required]
42 public ITaskItem BaselineFile
43 {
44 get { return this.baselineFile; }
45 set { this.baselineFile = value; }
46 }
47
48 public string BinaryExtractionPath
49 {
50 get { return this.binaryExtractionPath; }
51 set { this.binaryExtractionPath = value; }
52 }
53
54 public bool LeaveTemporaryFiles
55 {
56 get { return this.leaveTemporaryFiles; }
57 set { this.leaveTemporaryFiles = value; }
58 }
59
60 public bool InputIsXml
61 {
62 get { return this.inputIsXml; }
63 set { this.inputIsXml = value; }
64 }
65
66 public bool OutputAsXml
67 {
68 get { return this.outputAsXml; }
69 set { this.outputAsXml = value; }
70 }
71
72 public bool PreserveUnmodifiedContent
73 {
74 get { return this.preserveUnmodifiedContent; }
75 set { this.preserveUnmodifiedContent = value; }
76 }
77
78 [Required]
79 [Output]
80 public ITaskItem OutputFile
81 {
82 get { return this.outputFile; }
83 set { this.outputFile = value; }
84 }
85
86 public string SuppressTransformErrorFlags
87 {
88 get { return this.suppressTransformErrorFlags; }
89 set { this.suppressTransformErrorFlags = value; }
90 }
91
92 public string TransformValidationType
93 {
94 get { return this.transformValidationType; }
95 set { this.transformValidationType = value; }
96 }
97
98 public string TransformValidationFlags
99 {
100 get { return this.transformValidationFlags; }
101 set { this.transformValidationFlags = value; }
102 }
103
104 [Required]
105 public ITaskItem UpdateFile
106 {
107 get { return this.updateFile; }
108 set { this.updateFile = value; }
109 }
110
111 /// <summary>
112 /// Get the name of the executable.
113 /// </summary>
114 /// <remarks>The ToolName is used with the ToolPath to get the location of torch.exe.</remarks>
115 /// <value>The name of the executable.</value>
116 protected override string ToolName
117 {
118 get { return TorchToolName; }
119 }
120
121 /// <summary>
122 /// Get the path to the executable.
123 /// </summary>
124 /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
125 /// <returns>The full path to the executable or simply torch.exe if it's expected to be in the system path.</returns>
126 protected override string GenerateFullPathToTool()
127 {
128 // If there's not a ToolPath specified, it has to be in the system path.
129 if (String.IsNullOrEmpty(this.ToolPath))
130 {
131 return TorchToolName;
132 }
133
134 return Path.Combine(Path.GetFullPath(this.ToolPath), TorchToolName);
135 }
136
137 /// <summary>
138 /// Builds a command line from options in this task.
139 /// </summary>
140 protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
141 {
142 base.BuildCommandLine(commandLineBuilder);
143
144 commandLineBuilder.AppendIfTrue("-notidy", this.LeaveTemporaryFiles);
145 commandLineBuilder.AppendIfTrue("-xo", this.OutputAsXml);
146 commandLineBuilder.AppendIfTrue("-xi", this.InputIsXml);
147 commandLineBuilder.AppendIfTrue("-p", this.PreserveUnmodifiedContent);
148 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
149 commandLineBuilder.AppendFileNameIfNotNull(this.BaselineFile);
150 commandLineBuilder.AppendFileNameIfNotNull(this.UpdateFile);
151 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
152 commandLineBuilder.AppendIfTrue("-a", this.adminImage);
153 commandLineBuilder.AppendSwitchIfNotNull("-x ", this.BinaryExtractionPath);
154 commandLineBuilder.AppendSwitchIfNotNull("-serr ", this.SuppressTransformErrorFlags);
155 commandLineBuilder.AppendSwitchIfNotNull("-t ", this.TransformValidationType);
156 commandLineBuilder.AppendSwitchIfNotNull("-val ", this.TransformValidationFlags);
157 }
158 }
159}
diff --git a/src/WixToolset.BuildTasks/WixAssignCulture.cs b/src/WixToolset.BuildTasks/WixAssignCulture.cs
new file mode 100644
index 00000000..a8baa62f
--- /dev/null
+++ b/src/WixToolset.BuildTasks/WixAssignCulture.cs
@@ -0,0 +1,229 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.IO;
9 using System.Xml;
10 using Microsoft.Build.Framework;
11 using Microsoft.Build.Utilities;
12
13 /// <summary>
14 /// This task assigns Culture metadata to files based on the value of the Culture attribute on the
15 /// WixLocalization element inside the file.
16 /// </summary>
17 public class WixAssignCulture : Task
18 {
19 private const string CultureAttributeName = "Culture";
20 private const string OutputFolderMetadataName = "OutputFolder";
21 private const string InvariantCultureIdentifier = "neutral";
22 private const string NullCultureIdentifier = "null";
23
24 /// <summary>
25 /// The list of cultures to build. Cultures are specified in the following form:
26 /// primary culture,first fallback culture, second fallback culture;...
27 /// Culture groups are seperated by semi-colons
28 /// Culture precedence within a culture group is evaluated from left to right where fallback cultures are
29 /// separated with commas.
30 /// The first (primary) culture in a culture group will be used as the output sub-folder.
31 /// </summary>
32 public string Cultures { get; set; }
33
34 /// <summary>
35 /// The list of files to apply culture information to.
36 /// </summary>
37 [Required]
38 public ITaskItem[] Files
39 {
40 get;
41 set;
42 }
43
44 /// <summary>
45 /// The files that had culture information applied
46 /// </summary>
47 [Output]
48 public ITaskItem[] CultureGroups
49 {
50 get;
51 private set;
52 }
53
54 /// <summary>
55 /// Applies culture information to the files specified by the Files property.
56 /// This task intentionally does not validate that strings are valid Cultures so that we can support
57 /// psuedo-loc.
58 /// </summary>
59 /// <returns>True upon completion of the task execution.</returns>
60 public override bool Execute()
61 {
62 // First, process the culture group list the user specified in the cultures property
63 List<CultureGroup> cultureGroups = new List<CultureGroup>();
64
65 if (!String.IsNullOrEmpty(this.Cultures))
66 {
67 // Get rid of extra quotes
68 this.Cultures = this.Cultures.Trim('\"');
69
70 foreach (string cultureGroupString in this.Cultures.Split(';'))
71 {
72 if (0 == cultureGroupString.Length)
73 {
74 // MSBuild v2.0.50727 cannnot handle "" items
75 // for the invariant culture we require the neutral keyword
76 continue;
77 }
78 CultureGroup cultureGroup = new CultureGroup(cultureGroupString);
79 cultureGroups.Add(cultureGroup);
80 }
81 }
82 else
83 {
84 // Only process the EmbeddedResource items if cultures was unspecified
85 foreach (ITaskItem file in this.Files)
86 {
87 // Ignore non-wxls
88 if (!String.Equals(file.GetMetadata("Extension"), ".wxl", StringComparison.OrdinalIgnoreCase))
89 {
90 Log.LogError("Unable to retrieve the culture for EmbeddedResource {0}. The file type is not supported.", file.ItemSpec);
91 return false;
92 }
93 XmlDocument wxlFile = new XmlDocument();
94
95 try
96 {
97 wxlFile.Load(file.ItemSpec);
98 }
99 catch (FileNotFoundException)
100 {
101 Log.LogError("Unable to retrieve the culture for EmbeddedResource {0}. The file was not found.", file.ItemSpec);
102 return false;
103 }
104 catch (Exception e)
105 {
106 Log.LogError("Unable to retrieve the culture for EmbeddedResource {0}: {1}", file.ItemSpec, e.Message);
107 return false;
108 }
109
110 // Take the culture value and try using it to create a culture.
111 XmlAttribute cultureAttr = wxlFile.DocumentElement.Attributes[WixAssignCulture.CultureAttributeName];
112 string wxlCulture = null == cultureAttr ? String.Empty : cultureAttr.Value;
113 if (0 == wxlCulture.Length)
114 {
115 // We use a keyword for the invariant culture because MSBuild v2.0.50727 cannnot handle "" items
116 wxlCulture = InvariantCultureIdentifier;
117 }
118
119 // We found the culture for the WXL, we now need to determine if it maps to a culture group specified
120 // in the Cultures property or if we need to create a new one.
121 Log.LogMessage(MessageImportance.Low, "Culture \"{0}\" from EmbeddedResource {1}.", wxlCulture, file.ItemSpec);
122
123 bool cultureGroupExists = false;
124 foreach (CultureGroup cultureGroup in cultureGroups)
125 {
126 foreach (string culture in cultureGroup.Cultures)
127 {
128 if (String.Equals(wxlCulture, culture, StringComparison.OrdinalIgnoreCase))
129 {
130 cultureGroupExists = true;
131 break;
132 }
133 }
134 }
135
136 // The WXL didn't match a culture group we already have so create a new one.
137 if (!cultureGroupExists)
138 {
139 cultureGroups.Add(new CultureGroup(wxlCulture));
140 }
141 }
142 }
143
144 // If we didn't create any culture groups the culture was unspecificed and no WXLs were included
145 // Build an unlocalized target in the output folder
146 if (cultureGroups.Count == 0)
147 {
148 cultureGroups.Add(new CultureGroup());
149 }
150
151 List<TaskItem> cultureGroupItems = new List<TaskItem>();
152
153 if (1 == cultureGroups.Count && 0 == this.Files.Length)
154 {
155 // Maintain old behavior, if only one culturegroup is specified and no WXL, output to the default folder
156 TaskItem cultureGroupItem = new TaskItem(cultureGroups[0].ToString());
157 cultureGroupItem.SetMetadata(OutputFolderMetadataName, CultureGroup.DefaultFolder);
158 cultureGroupItems.Add(cultureGroupItem);
159 }
160 else
161 {
162 foreach (CultureGroup cultureGroup in cultureGroups)
163 {
164 TaskItem cultureGroupItem = new TaskItem(cultureGroup.ToString());
165 cultureGroupItem.SetMetadata(OutputFolderMetadataName, cultureGroup.OutputFolder);
166 cultureGroupItems.Add(cultureGroupItem);
167 Log.LogMessage("Culture: {0}", cultureGroup.ToString());
168 }
169 }
170
171 this.CultureGroups = cultureGroupItems.ToArray();
172 return true;
173 }
174
175 private class CultureGroup
176 {
177 /// <summary>
178 /// TargetPath already has a '\', do not double it!
179 /// </summary>
180 public const string DefaultFolder = "";
181
182 /// <summary>
183 /// Initialize a null culture group
184 /// </summary>
185 public CultureGroup()
186 {
187 }
188
189 public CultureGroup(string cultureGroupString)
190 {
191 Debug.Assert(!String.IsNullOrEmpty(cultureGroupString));
192 foreach (string cultureString in cultureGroupString.Split(','))
193 {
194 this.Cultures.Add(cultureString);
195 }
196 }
197
198 public List<string> Cultures { get; } = new List<string>();
199
200 public string OutputFolder
201 {
202 get
203 {
204 string result = DefaultFolder;
205 if (this.Cultures.Count > 0 &&
206 !this.Cultures[0].Equals(InvariantCultureIdentifier, StringComparison.OrdinalIgnoreCase))
207 {
208 result = this.Cultures[0] + "\\";
209 }
210
211 return result;
212 }
213 }
214
215 public override string ToString()
216 {
217 if (this.Cultures.Count > 0)
218 {
219 return String.Join(";", this.Cultures);
220 }
221
222 // We use a keyword for a null culture because MSBuild cannnot handle "" items
223 // Null is different from neutral. For neutral we still want to do WXL
224 // filtering in Light.
225 return NullCultureIdentifier;
226 }
227 }
228 }
229}
diff --git a/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs b/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs
new file mode 100644
index 00000000..a979dbb0
--- /dev/null
+++ b/src/WixToolset.BuildTasks/WixCommandLineBuilder.cs
@@ -0,0 +1,177 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Globalization;
8 using System.IO;
9
10 using Microsoft.Build.Framework;
11 using Microsoft.Build.Utilities;
12
13 /// <summary>
14 /// Helper class for appending the command line arguments.
15 /// </summary>
16 public class WixCommandLineBuilder : CommandLineBuilder
17 {
18 internal const int Unspecified = -1;
19
20 /// <summary>
21 /// Append a switch to the command line if the value has been specified.
22 /// </summary>
23 /// <param name="switchName">Switch to append.</param>
24 /// <param name="value">Value specified by the user.</param>
25 public void AppendIfSpecified(string switchName, int value)
26 {
27 if (value != Unspecified)
28 {
29 this.AppendSwitchIfNotNull(switchName, value.ToString(CultureInfo.InvariantCulture));
30 }
31 }
32
33 /// <summary>
34 /// Append a switch to the command line if the condition is true.
35 /// </summary>
36 /// <param name="switchName">Switch to append.</param>
37 /// <param name="condition">Condition specified by the user.</param>
38 public void AppendIfTrue(string switchName, bool condition)
39 {
40 if (condition)
41 {
42 this.AppendSwitch(switchName);
43 }
44 }
45
46 /// <summary>
47 /// Append a switch to the command line if any values in the array have been specified.
48 /// </summary>
49 /// <param name="switchName">Switch to append.</param>
50 /// <param name="values">Values specified by the user.</param>
51 public void AppendArrayIfNotNull(string switchName, IEnumerable<ITaskItem> values)
52 {
53 if (values != null)
54 {
55 foreach (ITaskItem value in values)
56 {
57 this.AppendSwitchIfNotNull(switchName, value);
58 }
59 }
60 }
61
62 /// <summary>
63 /// Append a switch to the command line if any values in the array have been specified.
64 /// </summary>
65 /// <param name="switchName">Switch to append.</param>
66 /// <param name="values">Values specified by the user.</param>
67 public void AppendArrayIfNotNull(string switchName, IEnumerable<string> values)
68 {
69 if (values != null)
70 {
71 foreach (string value in values)
72 {
73 this.AppendSwitchIfNotNull(switchName, value);
74 }
75 }
76 }
77
78 /// <summary>
79 /// Build the extensions argument. Each extension is searched in the current folder, user defined search
80 /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order.
81 /// The order of precedence is based off of that described in Microsoft.Common.Targets's SearchPaths
82 /// property for the ResolveAssemblyReferences task.
83 /// </summary>
84 /// <param name="extensions">The list of extensions to include.</param>
85 /// <param name="wixExtensionDirectory">Evaluated default folder for Wix Extensions</param>
86 /// <param name="referencePaths">User defined reference directories to search in</param>
87 public void AppendExtensions(ITaskItem[] extensions, string wixExtensionDirectory, string [] referencePaths)
88 {
89 if (extensions == null)
90 {
91 return;
92 }
93
94 foreach (ITaskItem extension in extensions)
95 {
96 string className = extension.GetMetadata("Class");
97
98 string fileName = Path.GetFileName(extension.ItemSpec);
99
100 if (String.IsNullOrEmpty(Path.GetExtension(fileName)))
101 {
102 fileName += ".dll";
103 }
104
105 // First try reference paths
106 var resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName);
107
108 if (String.IsNullOrEmpty(resolvedPath))
109 {
110 // Now try HintPath
111 resolvedPath = extension.GetMetadata("HintPath");
112
113 if (!File.Exists(resolvedPath))
114 {
115 // Now try the item itself
116 resolvedPath = extension.ItemSpec;
117
118 if (String.IsNullOrEmpty(Path.GetExtension(resolvedPath)))
119 {
120 resolvedPath += ".dll";
121 }
122
123 if (!File.Exists(resolvedPath))
124 {
125 if (!String.IsNullOrEmpty(wixExtensionDirectory))
126 {
127 // Now try the extension directory
128 resolvedPath = Path.Combine(wixExtensionDirectory, Path.GetFileName(resolvedPath));
129 }
130
131 if (!File.Exists(resolvedPath))
132 {
133 // Extension wasn't found, just set it to the extension name passed in
134 resolvedPath = extension.ItemSpec;
135 }
136 }
137 }
138 }
139
140 if (String.IsNullOrEmpty(className))
141 {
142 this.AppendSwitchIfNotNull("-ext ", resolvedPath);
143 }
144 else
145 {
146 this.AppendSwitchIfNotNull("-ext ", className + ", " + resolvedPath);
147 }
148 }
149 }
150
151 /// <summary>
152 /// Append arbitrary text to the command-line if specified.
153 /// </summary>
154 /// <param name="textToAppend">Text to append.</param>
155 public void AppendTextIfNotNull(string textToAppend)
156 {
157 if (!String.IsNullOrEmpty(textToAppend))
158 {
159 this.AppendSpaceIfNotEmpty();
160 this.AppendTextUnquoted(textToAppend);
161 }
162 }
163
164 /// <summary>
165 /// Append arbitrary text to the command-line if specified.
166 /// </summary>
167 /// <param name="textToAppend">Text to append.</param>
168 public void AppendTextIfNotWhitespace(string textToAppend)
169 {
170 if (!String.IsNullOrWhiteSpace(textToAppend))
171 {
172 this.AppendSpaceIfNotEmpty();
173 this.AppendTextUnquoted(textToAppend);
174 }
175 }
176 }
177}
diff --git a/src/WixToolset.BuildTasks/WixToolTask.cs b/src/WixToolset.BuildTasks/WixToolTask.cs
new file mode 100644
index 00000000..60305e00
--- /dev/null
+++ b/src/WixToolset.BuildTasks/WixToolTask.cs
@@ -0,0 +1,403 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics.CodeAnalysis;
8 using System.Globalization;
9 using System.IO;
10 using System.Reflection;
11 using System.Text;
12 using System.Threading;
13
14 using Microsoft.Build.Framework;
15 using Microsoft.Build.Utilities;
16 using WixToolset.Core.CommandLine;
17
18 /// <summary>
19 /// Base class for WiX tool tasks; executes tools in-process
20 /// so that repeated invocations are much faster.
21 /// </summary>
22 public abstract class WixToolTask : ToolTask, IDisposable
23 {
24 private string additionalOptions;
25 private bool disposed;
26 private bool noLogo;
27 private bool runAsSeparateProcess;
28 private bool suppressAllWarnings;
29 private string[] suppressSpecificWarnings;
30 private string[] treatSpecificWarningsAsErrors;
31 private bool treatWarningsAsErrors;
32 private bool verboseOutput;
33 private Queue<string> messageQueue;
34 private ManualResetEvent messagesAvailable;
35 private ManualResetEvent toolExited;
36 private int exitCode;
37
38 /// <summary>
39 /// Gets or sets additional options that are appended the the tool command-line.
40 /// </summary>
41 /// <remarks>
42 /// This allows the task to support extended options in the tool which are not
43 /// explicitly implemented as properties on the task.
44 /// </remarks>
45 public string AdditionalOptions
46 {
47 get { return this.additionalOptions; }
48 set { this.additionalOptions = value; }
49 }
50
51 /// <summary>
52 /// Gets or sets a flag indicating whether the task should be run as separate
53 /// process instead of in-proc with MSBuild which is the default.
54 /// </summary>
55 public bool RunAsSeparateProcess
56 {
57 get { return this.runAsSeparateProcess; }
58 set { this.runAsSeparateProcess = value; }
59 }
60
61#region Common Options
62 /// <summary>
63 /// Gets or sets whether all warnings should be suppressed.
64 /// </summary>
65 public bool SuppressAllWarnings
66 {
67 get { return this.suppressAllWarnings; }
68 set { this.suppressAllWarnings = value; }
69 }
70
71 /// <summary>
72 /// Gets or sets a list of specific warnings to be suppressed.
73 /// </summary>
74 public string[] SuppressSpecificWarnings
75 {
76 get { return this.suppressSpecificWarnings; }
77 set { this.suppressSpecificWarnings = value; }
78 }
79
80 /// <summary>
81 /// Gets or sets whether all warnings should be treated as errors.
82 /// </summary>
83 public bool TreatWarningsAsErrors
84 {
85 get { return this.treatWarningsAsErrors; }
86 set { this.treatWarningsAsErrors = value; }
87 }
88
89 /// <summary>
90 /// Gets or sets a list of specific warnings to treat as errors.
91 /// </summary>
92 public string[] TreatSpecificWarningsAsErrors
93 {
94 get { return this.treatSpecificWarningsAsErrors; }
95 set { this.treatSpecificWarningsAsErrors = value; }
96 }
97
98 /// <summary>
99 /// Gets or sets whether to display verbose output.
100 /// </summary>
101 public bool VerboseOutput
102 {
103 get { return this.verboseOutput; }
104 set { this.verboseOutput = value; }
105 }
106
107 /// <summary>
108 /// Gets or sets whether to display the logo.
109 /// </summary>
110 public bool NoLogo
111 {
112 get { return this.noLogo; }
113 set { this.noLogo = value; }
114 }
115#endregion
116
117 /// <summary>
118 /// Cleans up the ManualResetEvent members
119 /// </summary>
120 public void Dispose()
121 {
122 if (!this.disposed)
123 {
124 this.Dispose(true);
125 GC.SuppressFinalize(this);
126 disposed = true;
127 }
128 }
129
130 /// <summary>
131 /// Cleans up the ManualResetEvent members
132 /// </summary>
133 protected virtual void Dispose(bool disposing)
134 {
135 if (disposing)
136 {
137 messagesAvailable.Close();
138 toolExited.Close();
139 }
140 }
141
142 /// <summary>
143 /// Generate the command line arguments to write to the response file from the properties.
144 /// </summary>
145 /// <returns>Command line string.</returns>
146 protected override string GenerateResponseFileCommands()
147 {
148 WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
149 this.BuildCommandLine(commandLineBuilder);
150 return commandLineBuilder.ToString();
151 }
152
153 /// <summary>
154 /// Builds a command line from options in this and derivative tasks.
155 /// </summary>
156 /// <remarks>
157 /// Derivative classes should call BuildCommandLine() on the base class to ensure that common command line options are added to the command.
158 /// </remarks>
159 protected virtual void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
160 {
161 commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
162 commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings);
163 commandLineBuilder.AppendIfTrue("-sw", this.SuppressAllWarnings);
164 commandLineBuilder.AppendIfTrue("-v", this.VerboseOutput);
165 commandLineBuilder.AppendArrayIfNotNull("-wx", this.TreatSpecificWarningsAsErrors);
166 commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors);
167 }
168
169 /// <summary>
170 /// Executes a tool in-process by loading the tool assembly and invoking its entrypoint.
171 /// </summary>
172 /// <param name="pathToTool">Path to the tool to be executed; must be a managed executable.</param>
173 /// <param name="responseFileCommands">Commands to be written to a response file.</param>
174 /// <param name="commandLineCommands">Commands to be passed directly on the command-line.</param>
175 /// <returns>The tool exit code.</returns>
176 protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
177 {
178 if (this.RunAsSeparateProcess)
179 {
180 return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
181 }
182
183 this.messageQueue = new Queue<string>();
184 this.messagesAvailable = new ManualResetEvent(false);
185 this.toolExited = new ManualResetEvent(false);
186
187 WixToolTaskLogger logger = new WixToolTaskLogger(this.messageQueue, this.messagesAvailable);
188 TextWriter saveConsoleOut = Console.Out;
189 TextWriter saveConsoleError = Console.Error;
190 Console.SetOut(logger);
191 Console.SetError(logger);
192
193 string responseFile = null;
194 try
195 {
196 responseFile = this.GetTemporaryResponseFile(responseFileCommands, out var responseFileSwitch);
197 if (!String.IsNullOrEmpty(responseFileSwitch))
198 {
199 commandLineCommands = commandLineCommands + " " + responseFileSwitch;
200 }
201
202 string[] arguments = CommandLineResponseFile.ParseArgumentsToArray(commandLineCommands);
203
204 Thread toolThread = new Thread(new ParameterizedThreadStart(this.ExecuteToolThread));
205 toolThread.Start(new object[] { pathToTool, arguments });
206
207 this.HandleToolMessages();
208
209 if (this.exitCode == 0 && this.Log.HasLoggedErrors)
210 {
211 this.exitCode = -1;
212 }
213
214 return this.exitCode;
215 }
216 finally
217 {
218 if (responseFile != null)
219 {
220 File.Delete(responseFile);
221 }
222
223 Console.SetOut(saveConsoleOut);
224 Console.SetError(saveConsoleError);
225 }
226 }
227
228 /// <summary>
229 /// Called by a new thread to execute the tool in that thread.
230 /// </summary>
231 /// <param name="parameters">Tool path and arguments array.</param>
232 private void ExecuteToolThread(object parameters)
233 {
234 try
235 {
236 object[] pathAndArguments = (object[])parameters;
237 Assembly toolAssembly = Assembly.LoadFrom((string)pathAndArguments[0]);
238 this.exitCode = (int)toolAssembly.EntryPoint.Invoke(null, new object[] { pathAndArguments[1] });
239 }
240 catch (FileNotFoundException fnfe)
241 {
242 Log.LogError("Unable to load tool from path {0}. Consider setting the ToolPath parameter to $(WixToolPath).", fnfe.FileName);
243 this.exitCode = -1;
244 }
245 catch (Exception ex)
246 {
247 this.exitCode = -1;
248 this.LogEventsFromTextOutput(ex.Message, MessageImportance.High);
249 foreach (string stackTraceLine in ex.StackTrace.Split('\n'))
250 {
251 this.LogEventsFromTextOutput(stackTraceLine.TrimEnd(), MessageImportance.High);
252 }
253
254 throw;
255 }
256 finally
257 {
258 this.toolExited.Set();
259 }
260 }
261
262 /// <summary>
263 /// Waits for messages from the tool thread and sends them to the MSBuild logger on the original thread.
264 /// Returns when the tool thread exits.
265 /// </summary>
266 private void HandleToolMessages()
267 {
268 WaitHandle[] waitHandles = new WaitHandle[] { this.messagesAvailable, this.toolExited };
269 while (WaitHandle.WaitAny(waitHandles) == 0)
270 {
271 lock (this.messageQueue)
272 {
273 while (this.messageQueue.Count > 0)
274 {
275 this.LogEventsFromTextOutput(messageQueue.Dequeue(), MessageImportance.Normal);
276 }
277
278 this.messagesAvailable.Reset();
279 }
280 }
281 }
282
283 /// <summary>
284 /// Creates a temporary response file for tool execution.
285 /// </summary>
286 /// <returns>Path to the response file.</returns>
287 /// <remarks>
288 /// The temporary file should be deleted after the tool execution is finished.
289 /// </remarks>
290 private string GetTemporaryResponseFile(string responseFileCommands, out string responseFileSwitch)
291 {
292 string responseFile = null;
293 responseFileSwitch = null;
294
295 if (!String.IsNullOrEmpty(responseFileCommands))
296 {
297 responseFile = Path.GetTempFileName();
298 using (StreamWriter writer = new StreamWriter(responseFile, false, this.ResponseFileEncoding))
299 {
300 writer.Write(responseFileCommands);
301 }
302 responseFileSwitch = this.GetResponseFileSwitch(responseFile);
303 }
304 return responseFile;
305 }
306
307 /// <summary>
308 /// Cycles thru each task to find correct path of the file in question.
309 /// Looks at item spec, hintpath and then in user defined Reference Paths
310 /// </summary>
311 /// <param name="tasks">Input task array</param>
312 /// <param name="referencePaths">SemiColon delimited directories to search</param>
313 /// <returns>List of task item file paths</returns>
314 [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
315 protected static List<string> AdjustFilePaths(ITaskItem[] tasks, string[] referencePaths)
316 {
317 List<string> sourceFilePaths = new List<string>();
318
319 if (tasks == null)
320 {
321 return sourceFilePaths;
322 }
323
324 foreach (ITaskItem task in tasks)
325 {
326 string filePath = task.ItemSpec;
327 if (!File.Exists(filePath))
328 {
329 filePath = task.GetMetadata("HintPath");
330 if (!File.Exists(filePath))
331 {
332 string searchPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, filePath);
333 if (!String.IsNullOrEmpty(searchPath))
334 {
335 filePath = searchPath;
336 }
337 }
338 }
339 sourceFilePaths.Add(filePath);
340 }
341
342 return sourceFilePaths;
343 }
344
345 /// <summary>
346 /// Used as a replacement for Console.Out to capture output from a tool
347 /// and redirect it to the MSBuild logging system.
348 /// </summary>
349 private class WixToolTaskLogger : TextWriter
350 {
351 private StringBuilder buffer;
352 private Queue<string> messageQueue;
353 private ManualResetEvent messagesAvailable;
354
355 /// <summary>
356 /// Creates a new logger that sends tool output to the tool task's log handler.
357 /// </summary>
358 public WixToolTaskLogger(Queue<string> messageQueue, ManualResetEvent messagesAvailable) : base(CultureInfo.CurrentCulture)
359 {
360 this.messageQueue = messageQueue;
361 this.messagesAvailable = messagesAvailable;
362 this.buffer = new StringBuilder();
363 }
364
365 /// <summary>
366 /// Gets the encoding of the logger.
367 /// </summary>
368 public override Encoding Encoding
369 {
370 get { return Encoding.Unicode; }
371 }
372
373 /// <summary>
374 /// Redirects output to a buffer; watches for newlines and sends each line to the
375 /// MSBuild logging system.
376 /// </summary>
377 /// <param name="value">Character being written.</param>
378 /// <remarks>All other Write() variants eventually call into this one.</remarks>
379 public override void Write(char value)
380 {
381 lock (this.messageQueue)
382 {
383 if (value == '\n')
384 {
385 if (this.buffer.Length > 0 && this.buffer[this.buffer.Length - 1] == '\r')
386 {
387 this.buffer.Length = this.buffer.Length - 1;
388 }
389
390 this.messageQueue.Enqueue(this.buffer.ToString());
391 this.messagesAvailable.Set();
392
393 this.buffer.Length = 0;
394 }
395 else
396 {
397 this.buffer.Append(value);
398 }
399 }
400 }
401 }
402 }
403}
diff --git a/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
new file mode 100644
index 00000000..ec16f8b1
--- /dev/null
+++ b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
@@ -0,0 +1,51 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
7 <Description></Description>
8 <Title>WiX Toolset MSBuild Tasks</Title>
9 <DebugType>embedded</DebugType>
10 <PublishRepositoryUrl>true</PublishRepositoryUrl>
11 </PropertyGroup>
12
13 <PropertyGroup>
14 <NoWarn>NU1701</NoWarn>
15 </PropertyGroup>
16
17 <PropertyGroup>
18 <!-- <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> -->
19 </PropertyGroup>
20
21 <ItemGroup>
22 <Content Include="redirects\wix.targets" CopyToOutputDirectory="PreserveNewest" />
23 <Content Include="redirects\wix.ca.targets" CopyToOutputDirectory="PreserveNewest" />
24 <Content Include="wix.targets" CopyToOutputDirectory="PreserveNewest" />
25 <Content Include="wix.ca.targets" CopyToOutputDirectory="PreserveNewest" />
26 <Content Include="wix.harvest.targets" CopyToOutputDirectory="PreserveNewest" />
27 <Content Include="wix.signing.targets" CopyToOutputDirectory="PreserveNewest" />
28 </ItemGroup>
29
30 <ItemGroup>
31 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core\WixToolset.Core.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
32 <PackageReference Include="WixToolset.Core" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
33
34 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core.Burn\WixToolset.Core.Burn.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
35 <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
36
37 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core.WindowsInstaller\WixToolset.Core.WindowsInstaller.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
38 <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
39 </ItemGroup>
40
41 <ItemGroup>
42 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" Condition="'$(TargetFramework)'=='net461' " />
43 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.3.409" Condition="'$(TargetFramework)'=='netcoreapp2.1' " />
44 <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" />
45 </ItemGroup>
46
47 <ItemGroup>
48 <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All"/>
49 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
50 </ItemGroup>
51</Project>
diff --git a/src/WixToolset.BuildTasks/redirects/wix.ca.targets b/src/WixToolset.BuildTasks/redirects/wix.ca.targets
new file mode 100644
index 00000000..ecb6e09f
--- /dev/null
+++ b/src/WixToolset.BuildTasks/redirects/wix.ca.targets
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
5 <PropertyGroup>
6 <WixInstallFolder>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\WiX Toolset\v4', 'InstallFolder', null, RegistryView.Registry32))</WixInstallFolder>
7 </PropertyGroup>
8
9 <Import Project="$(WixInstallFolder)sdk\wix.ca.targets" />
10</Project>
diff --git a/src/WixToolset.BuildTasks/redirects/wix.targets b/src/WixToolset.BuildTasks/redirects/wix.targets
new file mode 100644
index 00000000..ba354b65
--- /dev/null
+++ b/src/WixToolset.BuildTasks/redirects/wix.targets
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
5 <PropertyGroup>
6 <WixInstallFolder>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\WiX Toolset\v4', 'InstallFolder', null, RegistryView.Registry32))</WixInstallFolder>
7 </PropertyGroup>
8
9 <Import Project="$(WixInstallFolder)bin\wix.targets" />
10</Project>
diff --git a/src/WixToolset.BuildTasks/wix.ca.targets b/src/WixToolset.BuildTasks/wix.ca.targets
new file mode 100644
index 00000000..4578c2d8
--- /dev/null
+++ b/src/WixToolset.BuildTasks/wix.ca.targets
@@ -0,0 +1,123 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
6
7 <Import Project="$(CustomBeforeWixCATargets)" Condition=" '$(CustomBeforeWixCATargets)' != '' and Exists('$(CustomBeforeWixCATargets)')" />
8
9 <PropertyGroup>
10 <WixCATargetsImported>true</WixCATargetsImported>
11
12 <TargetCAFileName Condition=" '$(TargetCAFileName)' == '' ">$(TargetName).CA$(TargetExt)</TargetCAFileName>
13
14 <WixSdkPath Condition=" '$(WixSdkPath)' == '' ">$(MSBuildThisFileDirectory)</WixSdkPath>
15 <WixSdkX86Path Condition=" '$(WixSdkX86Path)' == '' ">$(WixSdkPath)x86\</WixSdkX86Path>
16 <WixSdkX64Path Condition=" '$(WixSdkX64Path)' == '' ">$(WixSdkPath)x64\</WixSdkX64Path>
17
18 <MakeSfxCA Condition=" '$(MakeSfxCA)' == '' ">$(WixSdkPath)MakeSfxCA.exe</MakeSfxCA>
19 <SfxCADll Condition=" '$(SfxCADll)' == '' and '$(Platform)' == 'x64' ">$(WixSdkX64Path)SfxCA.dll</SfxCADll>
20 <SfxCADll Condition=" '$(SfxCADll)' == '' ">$(WixSdkX86Path)SfxCA.dll</SfxCADll>
21 </PropertyGroup>
22
23 <!--
24 ==================================================================================================
25 PackCustomAction
26
27 Creates an MSI managed custom action package that includes the custom action assembly,
28 local assembly dependencies, and project content files.
29
30 [IN]
31 @(IntermediateAssembly) - Managed custom action assembly.
32 @(Content) - Project items of type Content will be included in the package.
33 $(CustomActionContents) - Optional space-delimited list of additional files to include.
34
35 [OUT]
36 $(IntermediateOutputPath)$(TargetCAFileName) - Managed custom action package with unmanaged stub.
37 ==================================================================================================
38 -->
39 <Target Name="PackCustomAction"
40 Inputs="@(IntermediateAssembly);@(Content);$(CustomActionContents)"
41 Outputs="$(IntermediateOutputPath)$(TargetCAFileName)">
42
43 <!-- Find all referenced items marked CopyLocal, but exclude non-binary files. -->
44 <ItemGroup>
45 <CustomActionReferenceContents Include="@(ReferenceCopyLocalPaths)"
46 Condition=" '%(Extension)' == '.dll' or '%(Extension)' == '.exe' " />
47 <CustomActionReferenceContents Include="@(ReferenceComWrappersToCopyLocal)"
48 Condition=" '%(Extension)' == '.dll' or '%(Extension)' == '.exe' " />
49
50 <!-- include PDBs for Debug only -->
51 <CustomActionReferenceContents Include="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).pdb')"
52 Condition=" Exists('%(RootDir)%(Directory)%(Filename).pdb') and '$(Configuration)' == 'Debug' " />
53 <CustomActionReferenceContents Include="@(ReferenceCopyLocalPaths)"
54 Condition=" '%(Extension)' == '.pdb' and '$(Configuration)' == 'Debug' " />
55 <CustomActionReferenceContents Include="@(ReferenceComWrappersToCopyLocal)"
56 Condition=" '%(Extension)' == '.pdb' and '$(Configuration)' == 'Debug' " />
57 </ItemGroup>
58
59 <!--
60 Items to include in the CA package:
61 - Reference assemblies marked CopyLocal
62 - Project items of type Content
63 - Additional items in the CustomActionContents property
64 -->
65 <PropertyGroup>
66 <CustomActionContents>@(CustomActionReferenceContents);@(Content->'%(FullPath)');$(CustomActionContents)</CustomActionContents>
67 </PropertyGroup>
68
69 <ItemGroup>
70 <IntermediateCAAssembly Include="@(IntermediateAssembly->'%(FullPath)')" />
71 <IntermediateCAPackage Include="@(IntermediateAssembly->'%(RootDir)%(Directory)$(TargetCAFileName)')" />
72 </ItemGroup>
73
74 <!-- Run the MakeSfxCA.exe CA packaging tool. -->
75 <Exec Command='"$(MakeSfxCA)" "@(IntermediateCAPackage)" "$(SfxCADll)" "@(IntermediateCAAssembly)" "$(CustomActionContents)"'
76 WorkingDirectory="$(ProjectDir)" />
77
78 <!-- Add modules to be copied to output dir. -->
79 <ItemGroup>
80 <AddModules Include="@(IntermediateCAPackage)" />
81 </ItemGroup>
82 </Target>
83
84 <!--
85 ==================================================================================================
86 CleanCustomAction
87
88 Cleans the .CA.dll binary created by the PackCustomAction target.
89
90 ==================================================================================================
91 -->
92 <Target Name="CleanCustomAction">
93 <Delete Files="$(IntermediateOutputPath)$(TargetCAFileName)"
94 TreatErrorsAsWarnings="true" />
95 </Target>
96
97 <!--
98 ==================================================================================================
99 AfterCompile (redefinition)
100
101 Calls the PackCustomAction target after compiling.
102 Overrides the empty AfterCompile target from Microsoft.Common.targets.
103
104 ==================================================================================================
105 -->
106 <Target Name="AfterCompile"
107 DependsOnTargets="PackCustomAction" />
108
109 <!--
110 ==================================================================================================
111 BeforeClean (redefinition)
112
113 Calls the CleanCustomAction target before cleaning.
114 Overrides the empty AfterCompile target from Microsoft.Common.targets.
115
116 ==================================================================================================
117 -->
118 <Target Name="BeforeClean"
119 DependsOnTargets="CleanCustomAction" />
120
121 <Import Project="$(CustomAfterWixCATargets)" Condition=" '$(CustomAfterWixCATargets)' != '' and Exists('$(CustomAfterWixCATargets)')" />
122
123</Project>
diff --git a/src/WixToolset.BuildTasks/wix.harvest.targets b/src/WixToolset.BuildTasks/wix.harvest.targets
new file mode 100644
index 00000000..e94dfcea
--- /dev/null
+++ b/src/WixToolset.BuildTasks/wix.harvest.targets
@@ -0,0 +1,511 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6
7 <!-- These properties can be overridden to support non-default installations. -->
8 <PropertyGroup>
9 <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileFullPath)</WixTargetsPath>
10 <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixTasks.dll</WixTasksPath>
11 </PropertyGroup>
12
13 <!-- These tasks are extensions for harvesting WiX source code from other sources. -->
14 <UsingTask TaskName="HeatFile" AssemblyFile="$(WixTasksPath)" />
15 <UsingTask TaskName="HeatDirectory" AssemblyFile="$(WixTasksPath)" />
16 <UsingTask TaskName="HeatProject" AssemblyFile="$(WixTasksPath)" />
17
18 <UsingTask TaskName="RefreshGeneratedFile" AssemblyFile="$(WixTasksPath)"/>
19 <UsingTask TaskName="RefreshBundleGeneratedFile" AssemblyFile="$(WixTasksPath)"/>
20
21 <!-- Default Harvester properties-->
22 <PropertyGroup>
23 <HarvestNoLogo Condition=" '$(HarvestNoLogo)' == '' ">$(NoLogo)</HarvestNoLogo>
24 <HarvestSuppressAllWarnings Condition=" '$(HarvestSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</HarvestSuppressAllWarnings>
25 <HarvestSuppressSpecificWarnings Condition=" '$(HarvestSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</HarvestSuppressSpecificWarnings>
26 <HarvestTreatWarningsAsErrors Condition=" '$(HarvestTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</HarvestTreatWarningsAsErrors>
27 <HarvestTreatSpecificWarningsAsErrors Condition=" '$(HarvestTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</HarvestTreatSpecificWarningsAsErrors>
28 <HarvestVerboseOutput Condition=" '$(HarvestVerboseOutput)' == '' ">$(VerboseOutput)</HarvestVerboseOutput>
29 <HarvestAutogenerateGuids Condition=" '$(HarvestAutogenerateGuids)' == '' ">true</HarvestAutogenerateGuids>
30 <HarvestGenerateGuidsNow Condition=" '$(HarvestGenerateGuidsNow)' == '' ">false</HarvestGenerateGuidsNow>
31 <HarvestSuppressFragments Condition=" '$(HarvestSuppressFragments)' == '' ">true</HarvestSuppressFragments>
32 <HarvestSuppressUniqueIds Condition=" '$(HarvestSuppressUniqueIds)' == '' ">false</HarvestSuppressUniqueIds>
33 </PropertyGroup>
34
35 <!-- Default HarvestProjects properties -->
36 <PropertyGroup>
37 <!-- Project harvesting is defaulted to off until it works more consistently. -->
38 <EnableProjectHarvesting Condition=" '$(EnableProjectHarvesting)'=='' ">false</EnableProjectHarvesting>
39
40 <HarvestProjectsNoLogo Condition=" '$(HarvestProjectsNoLogo)' == '' ">$(HarvestNoLogo)</HarvestProjectsNoLogo>
41 <HarvestProjectsSuppressAllWarnings Condition=" '$(HarvestProjectsSuppressAllWarnings)' == '' ">$(HarvestSuppressAllWarnings)</HarvestProjectsSuppressAllWarnings>
42 <HarvestProjectsSuppressSpecificWarnings Condition=" '$(HarvestProjectsSuppressSpecificWarnings)' == '' ">$(HarvestSuppressSpecificWarnings)</HarvestProjectsSuppressSpecificWarnings>
43 <HarvestProjectsTreatWarningsAsErrors Condition=" '$(HarvestProjectsTreatWarningsAsErrors)' == '' ">$(HarvestTreatWarningsAsErrors)</HarvestProjectsTreatWarningsAsErrors>
44 <HarvestProjectsTreatSpecificWarningsAsErrors Condition=" '$(HarvestProjectsTreatSpecificWarningsAsErrors)' == '' ">$(HarvestTreatSpecificWarningsAsErrors)</HarvestProjectsTreatSpecificWarningsAsErrors>
45 <HarvestProjectsVerboseOutput Condition=" '$(HarvestProjectsVerboseOutput)' == '' ">$(HarvestVerboseOutput)</HarvestProjectsVerboseOutput>
46 <HarvestProjectsAutogenerateGuids Condition=" '$(HarvestProjectsAutogenerateGuids)' == '' ">$(HarvestAutogenerateGuids)</HarvestProjectsAutogenerateGuids>
47 <HarvestProjectsGenerateGuidsNow Condition=" '$(HarvestProjectsGenerateGuidsNow)' == '' ">$(HarvestGenerateGuidsNow)</HarvestProjectsGenerateGuidsNow>
48 <HarvestProjectsSuppressFragments Condition=" '$(HarvestProjectsSuppressFragments)' == '' ">$(HarvestSuppressFragments)</HarvestProjectsSuppressFragments>
49 <HarvestProjectsSuppressUniqueIds Condition=" '$(HarvestProjectsSuppressUniqueIds)' == '' ">$(HarvestSuppressUniqueIds)</HarvestProjectsSuppressUniqueIds>
50 <HarvestProjectsTransforms Condition=" '$(HarvestProjectsTransforms)' == '' ">$(HarvestTransforms)</HarvestProjectsTransforms>
51 <HarvestProjectsGeneratedFile Condition=" '$(HarvestProjectsGeneratedFile)' == '' and '$(OutputType)' != 'Bundle' ">$(IntermediateOutputPath)Product.Generated.wxs</HarvestProjectsGeneratedFile>
52 <HarvestProjectsGeneratedFile Condition=" '$(HarvestProjectsGeneratedFile)' == '' and '$(OutputType)' == 'Bundle' ">$(IntermediateOutputPath)Bundle.Generated.wxs</HarvestProjectsGeneratedFile>
53 </PropertyGroup>
54
55 <!-- Default HarvestDirectory properties -->
56 <PropertyGroup>
57 <HarvestDirectoryNoLogo Condition=" '$(HarvestDirectoryNoLogo)' == '' ">$(HarvestNoLogo)</HarvestDirectoryNoLogo>
58 <HarvestDirectorySuppressAllWarnings Condition=" '$(HarvestDirectorySuppressAllWarnings)' == '' ">$(HarvestSuppressAllWarnings)</HarvestDirectorySuppressAllWarnings>
59 <HarvestDirectorySuppressSpecificWarnings Condition=" '$(HarvestDirectorySuppressSpecificWarnings)' == '' ">$(HarvestSuppressSpecificWarnings)</HarvestDirectorySuppressSpecificWarnings>
60 <HarvestDirectoryTreatWarningsAsErrors Condition=" '$(HarvestDirectoryTreatWarningsAsErrors)' == '' ">$(HarvestTreatWarningsAsErrors)</HarvestDirectoryTreatWarningsAsErrors>
61 <HarvestDirectoryTreatSpecificWarningsAsErrors Condition=" '$(HarvestDirectoryTreatSpecificWarningsAsErrors)' == '' ">$(HarvestTreatSpecificWarningsAsErrors)</HarvestDirectoryTreatSpecificWarningsAsErrors>
62 <HarvestDirectoryVerboseOutput Condition=" '$(HarvestDirectoryVerboseOutput)' == '' ">$(HarvestVerboseOutput)</HarvestDirectoryVerboseOutput>
63 <HarvestDirectoryAutogenerateGuids Condition=" '$(HarvestDirectoryAutogenerateGuids)' == '' ">$(HarvestAutogenerateGuids)</HarvestDirectoryAutogenerateGuids>
64 <HarvestDirectoryGenerateGuidsNow Condition=" '$(HarvestDirectoryGenerateGuidsNow)' == '' ">$(HarvestGenerateGuidsNow)</HarvestDirectoryGenerateGuidsNow>
65 <HarvestDirectorySuppressFragments Condition=" '$(HarvestDirectorySuppressFragments)' == '' ">$(HarvestSuppressFragments)</HarvestDirectorySuppressFragments>
66 <HarvestDirectorySuppressUniqueIds Condition=" '$(HarvestDirectorySuppressUniqueIds)' == '' ">$(HarvestSuppressUniqueIds)</HarvestDirectorySuppressUniqueIds>
67 <HarvestDirectoryTransforms Condition=" '$(HarvestDirectoryTransforms)' == '' ">$(HarvestTransforms)</HarvestDirectoryTransforms>
68 </PropertyGroup>
69
70 <!-- Default HarvestFile properties -->
71 <PropertyGroup>
72 <HarvestFileNoLogo Condition=" '$(HarvestFileNoLogo)' == '' ">$(HarvestNoLogo)</HarvestFileNoLogo>
73 <HarvestFileSuppressAllWarnings Condition=" '$(HarvestFileSuppressAllWarnings)' == '' ">$(HarvestSuppressAllWarnings)</HarvestFileSuppressAllWarnings>
74 <HarvestFileSuppressSpecificWarnings Condition=" '$(HarvestFileSuppressSpecificWarnings)' == '' ">$(HarvestSuppressSpecificWarnings)</HarvestFileSuppressSpecificWarnings>
75 <HarvestFileTreatWarningsAsErrors Condition=" '$(HarvestFileTreatWarningsAsErrors)' == '' ">$(HarvestTreatWarningsAsErrors)</HarvestFileTreatWarningsAsErrors>
76 <HarvestFileTreatSpecificWarningsAsErrors Condition=" '$(HarvestFileTreatSpecificWarningsAsErrors)' == '' ">$(HarvestTreatSpecificWarningsAsErrors)</HarvestFileTreatSpecificWarningsAsErrors>
77 <HarvestFileVerboseOutput Condition=" '$(HarvestFileVerboseOutput)' == '' ">$(HarvestVerboseOutput)</HarvestFileVerboseOutput>
78 <HarvestFileAutogenerateGuids Condition=" '$(HarvestFileAutogenerateGuids)' == '' ">$(HarvestAutogenerateGuids)</HarvestFileAutogenerateGuids>
79 <HarvestFileGenerateGuidsNow Condition=" '$(HarvestFileGenerateGuidsNow)' == '' ">$(HarvestGenerateGuidsNow)</HarvestFileGenerateGuidsNow>
80 <HarvestFileSuppressFragments Condition=" '$(HarvestFileSuppressFragments)' == '' ">$(HarvestSuppressFragments)</HarvestFileSuppressFragments>
81 <HarvestFileSuppressUniqueIds Condition=" '$(HarvestFileSuppressUniqueIds)' == '' ">$(HarvestSuppressUniqueIds)</HarvestFileSuppressUniqueIds>
82 <HarvestFileTransforms Condition=" '$(HarvestFileTransforms)' == '' ">$(HarvestTransforms)</HarvestFileTransforms>
83 </PropertyGroup>
84
85 <!--
86 ==================================================================================================
87 Harvest
88 ==================================================================================================
89 -->
90 <PropertyGroup>
91 <HarvestDependsOn>
92 ConvertReferences;
93 ConvertBundleReferences;
94 HarvestProjects;
95 HarvestDirectory;
96 HarvestFile;
97 GenerateCode;
98 </HarvestDependsOn>
99 </PropertyGroup>
100 <Target
101 Name="Harvest"
102 DependsOnTargets="$(HarvestDependsOn)" />
103
104 <!--
105 ==================================================================================================
106 GenerateCode
107 ==================================================================================================
108 -->
109 <PropertyGroup>
110 <GenerateCodeDependsOn>
111 RefreshGeneratedFile;
112 RefreshBundleGeneratedFile
113 </GenerateCodeDependsOn>
114 </PropertyGroup>
115 <Target
116 Name="GenerateCode"
117 DependsOnTargets="$(GenerateCodeDependsOn)" />
118
119 <!--
120 ================================================================================================
121 ConvertReferences
122
123 Converts project references to HeatProject items to auto generate authoring.
124 ================================================================================================
125 -->
126 <Target
127 Name="ConvertReferences"
128 Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module') ">
129
130 <ItemGroup>
131 <_HeatProjectReference Include="@(_MSBuildProjectReferenceExistent)" Condition=" '%(_MSBuildProjectReferenceExistent.DoNotHarvest)' == '' ">
132 <DirectoryIds>%(_MSBuildProjectReferenceExistent.RefTargetDir)</DirectoryIds>
133 <ProjectOutputGroups>Binaries;Symbols;Sources;Content;Satellites;Documents</ProjectOutputGroups>
134 <ProjectName>%(_MSBuildProjectReferenceExistent.Name)</ProjectName>
135 <HeatOutput>$(IntermediateOutputPath)_%(_MSBuildProjectReferenceExistent.Filename).wxs</HeatOutput>
136 </_HeatProjectReference>
137 <HeatProject Include="@(_HeatProjectReference)" />
138 </ItemGroup>
139
140 <Error
141 Text="The following files are deprecated and should be removed from your project(s): @(Compile->'%(Identity)', ', ')"
142 Condition=" '%(Compile.GenerateComponentGroups)' != '' " />
143
144 <ItemGroup>
145 <!-- Unconditionally generate Compile items so they are always linked in. -->
146 <Compile Include="$(HarvestProjectsGeneratedFile)" />
147 <_GeneratedFiles Include="$(HarvestProjectsGeneratedFile)" />
148 </ItemGroup>
149
150 </Target>
151
152 <!--
153 ================================================================================================
154 ConvertBundleReferences
155
156 Converts project references in Bundle projects to HeatProject items to auto generate authoring.
157 ================================================================================================
158 -->
159 <Target
160 Name="ConvertBundleReferences"
161 Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Bundle') ">
162
163 <ItemGroup>
164 <_HeatProjectReference Include="@(_MSBuildProjectReferenceExistent)" Condition=" '%(_MSBuildProjectReferenceExistent.DoNotHarvest)' == '' ">
165 <ProjectOutputGroups>Binaries;Symbols;Sources;Content;Satellites;Documents</ProjectOutputGroups>
166 <GenerateType>payloadgroup</GenerateType>
167 <HeatOutput>$(IntermediateOutputPath)_%(_MSBuildProjectReferenceExistent.Filename).wxs</HeatOutput>
168 </_HeatProjectReference>
169 <HeatProject Include="@(_HeatProjectReference)" />
170 </ItemGroup>
171
172 <Error
173 Text="The following files are deprecated and should be removed from your project(s): @(Compile->'%(Identity)', ', ')"
174 Condition=" '%(Compile.GenerateComponentGroups)' != '' " />
175
176 <ItemGroup>
177 <!-- Unconditionally generate Compile items so they are always linked in. -->
178 <Compile Include="$(HarvestProjectsGeneratedFile)" />
179 <_GeneratedFiles Include="$(HarvestProjectsGeneratedFile)" />
180 </ItemGroup>
181
182 </Target>
183
184 <!--
185 ================================================================================================
186 CombineHarvestProjects
187
188 Combines HeatProject and HarvestProject items together and ensures each has HeatOutput metadata.
189 ================================================================================================
190 -->
191 <Target
192 Name="CombineHarvestProjects"
193 Condition=" '@(HeatProject)' != '' or '@(HarvestProject)' != '' ">
194
195 <!-- Add default HeatOutputs for those without one specified -->
196 <CreateItem Include="@(HeatProject)" Condition= " '%(HeatProject.HeatOutput)' == '' "
197 AdditionalMetadata="HeatOutput=$(IntermediateOutputPath)_%(HeatProject.Filename).wxs">
198 <Output TaskParameter="Include" ItemName="_AllHeatProjects" />
199 </CreateItem>
200 <CreateItem Include="@(HarvestProject)" Condition= " '%(HarvestProject.HeatOutput)' == '' "
201 AdditionalMetadata="HeatOutput=$(IntermediateOutputPath)_%(HarvestProject.Filename).wxs">
202 <Output TaskParameter="Include" ItemName="_AllHeatProjects" />
203 </CreateItem>
204
205
206 <CreateItem Include="@(HeatProject)" Condition= " '%(HeatProject.HeatOutput)' != '' ">
207 <Output TaskParameter="Include" ItemName="_AllHeatProjects" />
208 </CreateItem>
209 <CreateItem Include="@(HarvestProject)" Condition= " '%(HarvestProject.HeatOutput)' != '' ">
210 <Output TaskParameter="Include" ItemName="_AllHeatProjects" />
211 </CreateItem>
212
213 </Target>
214
215 <!--
216 ================================================================================================
217 HarvestProjects
218
219 Harvests outputs of other MSBuild projects files using the VS project extension to heat.exe.
220
221 [IN]
222 @(HarvestProject)
223 @(HeatProject)
224 - The list of projects to harvest. HeatProject is provided for backward compatibility.
225 You should use HarvestProject instead.
226
227 %(HarvestProject.Transforms)
228 %(HeatProject.Transforms)
229 - XSL transforms to apply to the harvested WiX.
230
231 %(HarvestProject.ProjectOutputGroups)
232 %(HeatProjects.ProjectOutputGroups)
233 - The project output groups to harvest
234
235 [OUT]
236 %(HeatOutput)
237 - The generated .wxs files which are added to the @(Compile) item list.
238 ================================================================================================
239 -->
240 <ItemDefinitionGroup>
241 <HeatProject>
242 <Transforms>$(HarvestProjectsTransforms)</Transforms>
243 <ProjectOutputGroups>$(HarvestProjectsProjectOutputGroups)</ProjectOutputGroups>
244 <DirectoryIds>$(HarvestProjectsDirectoryIds)</DirectoryIds>
245 </HeatProject>
246 <HarvestProject>
247 <Transforms>$(HarvestProjectsTransforms)</Transforms>
248 <ProjectOutputGroups>$(HarvestProjectsProjectOutputGroups)</ProjectOutputGroups>
249 <DirectoryIds>$(HarvestProjectsDirectoryIds)</DirectoryIds>
250 </HarvestProject>
251 </ItemDefinitionGroup>
252
253 <PropertyGroup>
254 <HarvestProjectsDependsOn>CombineHarvestProjects</HarvestProjectsDependsOn>
255 </PropertyGroup>
256 <Target Name="HarvestProjects"
257 DependsOnTargets="$(HarvestProjectsDependsOn)"
258 Inputs="@(_AllHeatProjects);%(_AllHeatProjects.Transforms);$(MSBuildAllProjects);$(ProjectPath)"
259 Outputs="@(_AllHeatProjects -> '%(HeatOutput)')"
260 Condition=" $(EnableProjectHarvesting) and ('@(HeatProject)' != '' or '@(HarvestProject)' != '') ">
261
262 <HeatProject
263 NoLogo="$(HarvestProjectsNoLogo)"
264 SuppressAllWarnings="$(HarvestProjectsSuppressAllWarnings)"
265 SuppressSpecificWarnings="$(HarvestProjectsSuppressSpecificWarnings)"
266 ToolPath="$(WixToolPath)"
267 TreatWarningsAsErrors="$(HarvestProjectsTreatWarningsAsErrors)"
268 TreatSpecificWarningsAsErrors="$(HarvestProjectsTreatSpecificWarningsAsErrors)"
269 VerboseOutput="$(HarvestProjectsVerboseOutput)"
270 AutogenerateGuids="$(HarvestProjectsAutogenerateGuids)"
271 GenerateGuidsNow="$(HarvestProjectsGenerateGuidsNow)"
272 OutputFile="%(_AllHeatProjects.HeatOutput)"
273 SuppressFragments="$(HarvestProjectsSuppressFragments)"
274 SuppressUniqueIds="$(HarvestProjectsSuppressUniqueIds)"
275 Transforms="%(_AllHeatProjects.Transforms)"
276 Project="%(_AllHeatProjects.FullPath)"
277 ProjectOutputGroups="%(_AllHeatProjects.ProjectOutputGroups)"
278 GenerateType="%(_AllHeatProjects.GenerateType)"
279 DirectoryIds="%(_AllHeatProjects.DirectoryIds)"
280 ProjectName="%(_AllHeatProjects.ProjectName)"
281 Configuration="%(_AllHeatProjects.Configuration)"
282 Platform="%(_AllHeatProjects.Platform)"
283 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
284 GenerateWixVariables="$(HarvestProjectsGenerateWixVariables)"
285 AdditionalOptions="$(HarvestProjectsAdditionalOptions)">
286
287 <Output TaskParameter="OutputFile" ItemName="Compile" />
288 <Output TaskParameter="OutputFile" ItemName="FileWrites" />
289
290 </HeatProject>
291
292 </Target>
293
294 <!--
295 ================================================================================================
296 HarvestDirectory
297
298 Harvests directories using heat.exe.
299
300 [IN]
301 @(HarvestDirectory) - The list of directories to harvest.
302 %(HarvestDirectory.Transforms) - XSL transforms to apply to the harvested WiX.
303 %(HarvestDirectory.ComponentGroupName) - The name of the ComponentGroup to create.
304 %(HarvestDirectory.DirectoryRefId) - The ID of the directory to reference instead of TARGETDIR.
305 %(HarvestDirectory.KeepEmptyDirectories) - Whether to create Directory entries for empty directories.
306 %(HarvestDirectory.PreprocessorVariable) - Substitute SourceDir for another variable name (ex: var.Dir).
307 %(HarvestDirectory.SuppressCom) - Suppress COM elements.
308 %(HarvestDirectory.SuppressRootDirectory) - Suppress a Directory element for the root directory.
309 $(HarvestDirectory.SuppressRegistry) - Suppress registry harvesting.
310
311 [OUT]
312 $(IntermediateOutputPath)_%(HarvestDirectory.ComponentGroupName)_dir.wxs
313 - The generated .wxs files which are added to the @(Compile) item list.
314 ================================================================================================
315 -->
316
317 <ItemDefinitionGroup>
318 <HarvestDirectory>
319 <Transforms>$(HarvestDirectoryTransforms)</Transforms>
320 <ComponentGroupName>$(HarvestDirectoryComponentGroupName)</ComponentGroupName>
321 <DirectoryRefId>$(HarvestDirectoryDirectoryRefId)</DirectoryRefId>
322 <KeepEmptyDirectories>$(HarvestDirectoryKeepEmptyDirectories)</KeepEmptyDirectories>
323 <PreprocessorVariable>$(HarvestDirectoryPreprocessorVariable)</PreprocessorVariable>
324 <SuppressCom>$(HarvestDirectorySuppressCom)</SuppressCom>
325 <SuppressRootDirectory>$(HarvestDirectorySuppressRootDirectory)</SuppressRootDirectory>
326 <SuppressRegistry>$(HarvestDirectorySuppressRegistry)</SuppressRegistry>
327 </HarvestDirectory>
328 </ItemDefinitionGroup>
329
330 <PropertyGroup>
331 <HarvestDirectoryDependsOn>
332 GetHarvestDirectoryContent
333 </HarvestDirectoryDependsOn>
334 </PropertyGroup>
335
336 <!-- Creates items to include content since wildcards will not work in Target/@Inputs. -->
337 <Target Name="GetHarvestDirectoryContent">
338 <CreateItem Include="@(HarvestDirectory->'%(FullPath)\**\*')">
339 <Output TaskParameter="Include" ItemName="_HarvestDirectoryContent" />
340 </CreateItem>
341 </Target>
342
343 <Target Name="HarvestDirectory"
344 DependsOnTargets="$(HarvestDirectoryDependsOn)"
345 Inputs="@(_HarvestDirectoryContent);%(HarvestDirectory.Transforms)"
346 Outputs="$(IntermediateOutputPath)_%(HarvestDirectory.ComponentGroupName)_dir.wxs"
347 Condition=" '@(HarvestDirectory)' != '' ">
348
349 <HeatDirectory
350 NoLogo="$(HarvestDirectoryNoLogo)"
351 SuppressAllWarnings="$(HarvestDirectorySuppressAllWarnings)"
352 SuppressSpecificWarnings="$(HarvestDirectorySuppressSpecificWarnings)"
353 ToolPath="$(WixToolPath)"
354 TreatWarningsAsErrors="$(HarvestDirectoryTreatWarningsAsErrors)"
355 TreatSpecificWarningsAsErrors="$(HarvestDirectoryTreatSpecificWarningsAsErrors)"
356 VerboseOutput="$(HarvestDirectoryVerboseOutput)"
357 AutogenerateGuids="$(HarvestDirectoryAutogenerateGuids)"
358 GenerateGuidsNow="$(HarvestDirectoryGenerateGuidsNow)"
359 OutputFile="$(IntermediateOutputPath)_%(HarvestDirectory.ComponentGroupName)_dir.wxs"
360 SuppressFragments="$(HarvestDirectorySuppressFragments)"
361 SuppressUniqueIds="$(HarvestDirectorySuppressUniqueIds)"
362 Transforms="%(HarvestDirectory.Transforms)"
363 Directory="@(HarvestDirectory)"
364 ComponentGroupName="%(HarvestDirectory.ComponentGroupName)"
365 DirectoryRefId="%(HarvestDirectory.DirectoryRefId)"
366 KeepEmptyDirectories="%(HarvestDirectory.KeepEmptyDirectories)"
367 PreprocessorVariable="%(HarvestDirectory.PreprocessorVariable)"
368 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
369 SuppressCom="%(HarvestDirectory.SuppressCom)"
370 SuppressRootDirectory="%(HarvestDirectory.SuppressRootDirectory)"
371 SuppressRegistry="%(HarvestDirectory.SuppressRegistry)"
372 AdditionalOptions="$(HarvestDirectoryAdditionalOptions)">
373
374 <Output TaskParameter="OutputFile" ItemName="Compile" />
375 <Output TaskParameter="OutputFile" ItemName="FileWrites" />
376
377 </HeatDirectory>
378
379 </Target>
380
381 <!--
382 ================================================================================================
383 HarvestFile
384
385 Harvests files of different types using heat.exe. This can harvest registry from
386 self-registering files, files with typelibs, and more.
387
388 [IN]
389 @(HarvestFile) - The list of files to harvest.
390 %(HarvestFile.Transforms) - XSL transforms to apply to the harvested WiX.
391 %(HarvestFile.ComponentGroupName) - The name of the ComponentGroup to create.
392 %(HarvestFile.DirectoryRefId) - The ID of the directory to reference instead of TARGETDIR.
393 %(HarvestFile.PreprocessorVariable) - Substitute SourceDir for another variable name (ex: var.Dir).
394 %(HarvestFile.SuppressCom) - Suppress COM elements.
395 %(HarvestFile.SuppressRootDirectory) - Suppress a Directory element for the root directory.
396 $(HarvestFile.SuppressRegistry) - Suppress registry harvesting.
397
398 [OUT]
399 $(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs
400 - The generated .wxs files which are added to the @(Compile) item list.
401 ================================================================================================
402 -->
403
404 <ItemDefinitionGroup>
405 <HarvestFile>
406 <Transforms>$(HarvestFileTransforms)</Transforms>
407 <ComponentGroupName>$(HarvestFileComponentGroupName)</ComponentGroupName>
408 <DirectoryRefId>$(HarvestFileDirectoryRefId)</DirectoryRefId>
409 <PreprocessorVariable>$(HarvestFilePreprocessorVariable)</PreprocessorVariable>
410 <SuppressCom>$(HarvestFileSuppressCom)</SuppressCom>
411 <SuppressRegistry>$(HarvestFileSuppressRegistry)</SuppressRegistry>
412 <SuppressRootDirectory>$(HarvestFileSuppressRootDirectory)</SuppressRootDirectory>
413 </HarvestFile>
414 </ItemDefinitionGroup>
415
416 <PropertyGroup>
417 <HarvestFileDependsOn></HarvestFileDependsOn>
418 </PropertyGroup>
419 <Target Name="HarvestFile"
420 DependsOnTargets="$(HarvestFileDependsOn)"
421 Inputs="@(HarvestFile);%(HarvestFile.Transforms)"
422 Outputs="$(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs"
423 Condition=" '@(HarvestFile)' != '' ">
424
425 <HeatFile
426 NoLogo="$(HarvestFileNoLogo)"
427 SuppressAllWarnings="$(HarvestFileSuppressAllWarnings)"
428 SuppressSpecificWarnings="$(HarvestFileSuppressSpecificWarnings)"
429 ToolPath="$(WixToolPath)"
430 TreatWarningsAsErrors="$(HarvestFileTreatWarningsAsErrors)"
431 TreatSpecificWarningsAsErrors="$(HarvestFileTreatSpecificWarningsAsErrors)"
432 VerboseOutput="$(HarvestFileVerboseOutput)"
433 AutogenerateGuids="$(HarvestFileAutogenerateGuids)"
434 GenerateGuidsNow="$(HarvestFileGenerateGuidsNow)"
435 OutputFile="$(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs"
436 SuppressFragments="$(HarvestFileSuppressFragments)"
437 SuppressUniqueIds="$(HarvestFileSuppressUniqueIds)"
438 Transforms="%(HarvestFile.Transforms)"
439 File="@(HarvestFile)"
440 ComponentGroupName="%(HarvestFile.ComponentGroupName)"
441 DirectoryRefId="%(HarvestFile.DirectoryRefId)"
442 PreprocessorVariable="%(HarvestFile.PreprocessorVariable)"
443 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
444 SuppressCom="%(HarvestFile.SuppressCom)"
445 SuppressRegistry="%(HarvestFile.SuppressRegistry)"
446 SuppressRootDirectory="%(HarvestFile.SuppressRootDirectory)"
447 AdditionalOptions="$(HarvestFileAdditionalOptions)">
448
449 <Output TaskParameter="OutputFile" ItemName="Compile" />
450 <Output TaskParameter="OutputFile" ItemName="FileWrites" />
451
452 </HeatFile>
453
454 </Target>
455
456 <!--
457 ================================================================================================
458 RefreshGeneratedFile
459
460 Generates code based on metadata defined in project references.
461
462 [IN]
463 @(_MSBuildResolvedProjectReferencePaths) - The list of MSBuildable project references.
464
465 [OUT]
466 @(_GeneratedFiles) - The generated source file.
467 ================================================================================================
468 -->
469 <PropertyGroup>
470 <RefreshGeneratedFileDependsOn></RefreshGeneratedFileDependsOn>
471 </PropertyGroup>
472 <Target Name="RefreshGeneratedFile"
473 DependsOnTargets="$(RefreshGeneratedFileDependsOn)"
474 Inputs="@(_MSBuildResolvedProjectReferencePaths);@(Compile);$(ProjectPath)"
475 Outputs="@(_GeneratedFiles)"
476 Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module') and '@(_GeneratedFiles)' != '' ">
477
478 <RefreshGeneratedFile
479 GeneratedFiles="@(_GeneratedFiles)"
480 ProjectReferencePaths="@(_MSBuildResolvedProjectReferencePaths)" />
481
482 </Target>
483
484 <!--
485 ================================================================================================
486 RefreshBundleGeneratedFile
487
488 Generates code for bundle projects based on metadata defined in project references.
489
490 [IN]
491 @(_MSBuildResolvedProjectReferencePaths) - The list of MSBuildable project references.
492
493 [OUT]
494 @(_GeneratedFiles) - The generated source file.
495 ================================================================================================
496 -->
497 <PropertyGroup>
498 <RefreshBundleGeneratedFileDependsOn></RefreshBundleGeneratedFileDependsOn>
499 </PropertyGroup>
500 <Target Name="RefreshBundleGeneratedFile"
501 DependsOnTargets="$(RefreshBundleGeneratedFileDependsOn)"
502 Inputs="@(_MSBuildResolvedProjectReferencePaths);@(Compile);$(ProjectPath)"
503 Outputs="@(_GeneratedFiles)"
504 Condition=" $(EnableProjectHarvesting) and ('$(OutputType)' == 'Bundle' and '@(_GeneratedFiles)' != '') ">
505
506 <RefreshBundleGeneratedFile
507 GeneratedFiles="@(_GeneratedFiles)"
508 ProjectReferencePaths="@(_MSBuildResolvedProjectReferencePaths)" />
509 </Target>
510
511</Project>
diff --git a/src/WixToolset.BuildTasks/wix.signing.targets b/src/WixToolset.BuildTasks/wix.signing.targets
new file mode 100644
index 00000000..6351cc8b
--- /dev/null
+++ b/src/WixToolset.BuildTasks/wix.signing.targets
@@ -0,0 +1,378 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6
7 <!-- These properties can be overridden to support non-default installations. -->
8 <PropertyGroup>
9 <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileFullPath)</WixTargetsPath>
10 <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixTasks.dll</WixTasksPath>
11
12 <SignedFile Condition=" '$(SignedFile)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFile>
13 </PropertyGroup>
14
15 <UsingTask TaskName="Insignia" AssemblyFile="$(WixTasksPath)" />
16
17 <!-- Default Inscribe properties. -->
18 <PropertyGroup>
19 <InscribeNoLogo Condition=" '$(InscribeNoLogo)' == '' ">$(NoLogo)</InscribeNoLogo>
20 <InscribeSuppressAllWarnings Condition=" '$(InscribeSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</InscribeSuppressAllWarnings>
21 <InscribeSuppressSpecificWarnings Condition=" '$(InscribeSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</InscribeSuppressSpecificWarnings>
22 <InscribeTreatWarningsAsErrors Condition=" '$(InscribeTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</InscribeTreatWarningsAsErrors>
23 <InscribeTreatSpecificWarningsAsErrors Condition=" '$(InscribeTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</InscribeTreatSpecificWarningsAsErrors>
24 <InscribeVerboseOutput Condition=" '$(InscribeVerboseOutput)' == '' ">$(VerboseOutput)</InscribeVerboseOutput>
25 </PropertyGroup>
26
27 <!--
28 ==================================================================================================
29 Signing
30 ==================================================================================================
31 -->
32 <PropertyGroup>
33 <InternalSignDependsOn Condition=" '$(OutputType)' == 'Module' ">
34 GetMsmsToSign;
35 InternalSignMsm;
36 </InternalSignDependsOn>
37 <InternalSignDependsOn Condition=" '$(OutputType)' == 'Package' ">
38 GetCabsToSign;
39 GetMsiToSign;
40 InternalSignCabs;
41 InscribeMsi;
42 InternalSignMsi;
43 </InternalSignDependsOn>
44 <InternalSignDependsOn Condition=" '$(OutputType)' == 'Bundle' ">
45 GetContainersToSign;
46 InternalSignContainers;
47 InscribeBundleEngine;
48 InternalSignBundleEngine;
49 InscribeBundle;
50 InternalSignBundle;
51 </InternalSignDependsOn>
52
53 <SigningDependsOn>
54 CompileAndLink;
55 BeforeSigning;
56 $(InternalSignDependsOn);
57 AfterSigning
58 </SigningDependsOn>
59 </PropertyGroup>
60 <Target
61 Name="Signing"
62 DependsOnTargets="$(SigningDependsOn)"
63 Inputs="@(SignTargetPath)"
64 Outputs="$(IntermediateOutputPath)$(SignedFile)"
65 Condition=" '@(SignTargetPath)' != '' ">
66
67 <CreateItem Include="$(IntermediateOutputPath)$(SignedFile)">
68 <Output TaskParameter="Include" ItemName="FileWrites" />
69 </CreateItem>
70
71 <WriteLinesToFile
72 File="$(IntermediateOutputPath)$(SignedFile)"
73 Lines="^$(MSBuildProjectFullPath);@(SignMsm);@(SignCabs);@(SignMsi);@(SignContainers);@(SignBundleEngine);@(SignBundle)"
74 Overwrite="true" />
75 </Target>
76
77 <!-- Internal targets so correct signing targets are called. -->
78 <Target
79 Name="GetMsmsToSign"
80 Inputs="@(SignTargetPath)"
81 Outputs="$(IntermediateOutputPath)$(SignedFile)">
82 <CreateItem Include="@(SignTargetPath)">
83 <Output TaskParameter="Include" ItemName="SignMsm" />
84 <Output TaskParameter="Include" ItemName="FileWrites" />
85 </CreateItem>
86 </Target>
87
88 <Target
89 Name="InternalSignMsm"
90 DependsOnTargets="SignMsm"
91 Condition=" '@(SignMsm)' != '' " />
92
93 <Target
94 Name="GetCabsToSign"
95 Inputs="@(SignTargetPath)"
96 Outputs="$(IntermediateOutputPath)$(SignedFile)">
97 <GetCabList Database="%(SignTargetPath.FullPath)">
98 <Output TaskParameter="CabList" ItemName="SignCabs" />
99 <Output TaskParameter="CabList" ItemName="FileWrites" />
100 </GetCabList>
101 </Target>
102
103 <Target
104 Name="InternalSignCabs"
105 DependsOnTargets="SignCabs"
106 Condition=" '@(SignCabs)' != '' " />
107
108 <Target
109 Name="GetMsiToSign"
110 Inputs="@(SignTargetPath)"
111 Outputs="$(IntermediateOutputPath)$(SignedFile)">
112 <CreateItemAvoidingInference InputProperties="@(SignTargetPath)">
113 <Output TaskParameter="OuputItems" ItemName="SignMsi" />
114 <Output TaskParameter="OuputItems" ItemName="FileWrites" />
115 </CreateItemAvoidingInference>
116 </Target>
117
118 <Target
119 Name="InternalSignMsi"
120 DependsOnTargets="SignMsi"
121 Inputs="@(SignTargetPath)"
122 Outputs="$(IntermediateOutputPath)$(SignedFile)"
123 Condition=" '@(SignMsi)' != '' " />
124
125 <Target
126 Name="GetContainersToSign"
127 Inputs="@(SignTargetPath)"
128 Outputs="$(IntermediateOutputPath)$(SignedFile)">
129 <!-- TODO: implement signing detached containers -->
130 </Target>
131
132 <Target
133 Name="InternalSignContainers"
134 DependsOnTargets="SignContainers"
135 Condition=" '@(SignContainers)' != '' " />
136
137 <Target
138 Name="InternalSignBundleEngine"
139 DependsOnTargets="SignBundleEngine"
140 Condition=" '@(SignBundleEngine)' != '' " />
141
142 <Target
143 Name="InternalSignBundle"
144 DependsOnTargets="SignBundle"
145 Condition=" '@(SignBundle)' != '' " />
146
147 <!--
148 ================================================================================================
149 InscribeMsi
150
151 To be called after signing an MSI's cabs - inscribes an MSI with the digital signature of its
152 external cabs.
153
154 [IN/OUT]
155 @(SignTargetPath) - The database file to inscribe - database file will be modified in-place.
156
157 [OUT]
158 @(SignMsi) - The database file to sign.
159 ================================================================================================
160 -->
161 <PropertyGroup>
162 <InscribeMsiDependsOn>
163 PrepareForBuild;
164 ResolveWixExtensionReferences;
165 CompileAndLink;
166 InternalSignCabs
167 </InscribeMsiDependsOn>
168 </PropertyGroup>
169 <Target
170 Name="InscribeMsi"
171 DependsOnTargets="$(InscribeMsiDependsOn)"
172 Inputs="@(SignTargetPath)"
173 Outputs="$(IntermediateOutputPath)$(SignedFile)"
174 Condition=" '@(SignCabs)' != '' ">
175
176 <Insignia
177 DatabaseFile="%(SignTargetPath.FullPath)"
178 OutputFile="%(SignTargetPath.FullPath)"
179 ToolPath="$(WixToolPath)"
180 NoLogo="$(InscribeNoLogo)"
181 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
182 SuppressAllWarnings="$(InscribeSuppressAllWarnings)"
183 SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)"
184 TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)"
185 TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)"
186 VerboseOutput="$(InscribeVerboseOutput)"
187 AdditionalOptions="$(InscribeAdditionalOptions)" />
188 </Target>
189
190 <!--
191 ================================================================================================
192 InscribeBundleEngine
193
194 To be called after signing a bundle's detached containers. Also removes attached container
195 so engine can be signed without attached container.
196
197 [IN]
198 @(SignTargetPath) - The bundle to inscribe.
199
200 [OUT]
201 @(SignBundleEngine) - The bundle engine file to be signed.
202 ================================================================================================
203 -->
204 <PropertyGroup>
205 <InscribeBundleEngineDependsOn>
206 PrepareForBuild;
207 ResolveWixExtensionReferences;
208 CompileAndLink;
209 InternalSignContainers
210 </InscribeBundleEngineDependsOn>
211 </PropertyGroup>
212 <Target
213 Name="InscribeBundleEngine"
214 DependsOnTargets="$(InscribeBundleEngineDependsOn)"
215 Inputs="@(SignTargetPath)"
216 Outputs="$(IntermediateOutputPath)$(SignedFile)">
217
218 <Insignia
219 BundleFile="@(SignTargetPath)"
220 OutputFile="$(IntermediateOutputPath)%(SignTargetPath.Filename)%(SignTargetPath.Extension)"
221 ToolPath="$(WixToolPath)"
222 NoLogo="$(InscribeNoLogo)"
223 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
224 SuppressAllWarnings="$(InscribeSuppressAllWarnings)"
225 SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)"
226 TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)"
227 TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)"
228 VerboseOutput="$(InscribeVerboseOutput)"
229 AdditionalOptions="$(InscribeAdditionalOptions)">
230 <Output TaskParameter="Output" ItemName="SignBundleEngine" />
231 </Insignia>
232
233 <!-- Explicitly add output to FileWrites to ensure even when the target is up to date. -->
234 <CreateItem Include="$(IntermediateOutputPath)%(SignTargetPath.Filename)%(SignTargetPath.Extension)">
235 <Output TaskParameter="Include" ItemName="FileWrites" />
236 </CreateItem>
237
238 </Target>
239
240 <!--
241 ================================================================================================
242 InscribeBundle
243
244 To be called after signing the bundle engine to reattach the attached container.
245
246 [IN]
247 @(Inscribe) - The bundle to inscribe.
248
249 [OUT]
250 @(SignBundle) - The bundle engine file to be signed.
251 ================================================================================================
252 -->
253 <PropertyGroup>
254 <InscribeBundleDependsOn>
255 PrepareForBuild;
256 ResolveWixExtensionReferences;
257 CompileAndLink;
258 InternalSignBundleEngine
259 </InscribeBundleDependsOn>
260 </PropertyGroup>
261 <Target
262 Name="InscribeBundle"
263 DependsOnTargets="$(InscribeBundleDependsOn)"
264 Inputs="@(SignTargetPath)"
265 Outputs="$(IntermediateOutputPath)$(SignedFile)">
266
267 <Insignia
268 BundleFile="@(SignBundleEngine)"
269 OriginalBundleFile="@(SignTargetPath)"
270 OutputFile="@(SignTargetPath)"
271 ToolPath="$(WixToolPath)"
272 NoLogo="$(InscribeNoLogo)"
273 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
274 SuppressAllWarnings="$(InscribeSuppressAllWarnings)"
275 SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)"
276 TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)"
277 TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)"
278 VerboseOutput="$(InscribeVerboseOutput)"
279 AdditionalOptions="$(InscribeAdditionalOptions)">
280 <Output TaskParameter="Output" ItemName="SignBundle" />
281 <Output TaskParameter="Output" ItemName="FileWrites" />
282 </Insignia>
283 </Target>
284
285 <!--
286 ==================================================================================================
287 BeforeSigning
288
289 Redefine this target in your project in order to run tasks just before all signing tasks.
290 ==================================================================================================
291 -->
292 <Target Name="BeforeSigning" />
293
294 <!--
295 ==================================================================================================
296 SignMsm
297
298 Redefine this target in your project in order to sign merge modules.
299
300 [IN]
301 @(SignMsm) - merge module files to sign.
302 ==================================================================================================
303 -->
304 <Target Name="SignMsm" />
305
306 <!--
307 ==================================================================================================
308 SignCabs
309
310 Redefine this target in your project in order to sign the cabs of your database.
311
312 [IN]
313 @(SignCabs) - cabinet files to sign.
314 ==================================================================================================
315 -->
316 <Target Name="SignCabs" />
317
318 <!--
319 ==================================================================================================
320 SignMsi
321
322 Redefine this target in your project in order to sign your database, after it has been inscribed
323 with the signatures of your signed cabs.
324
325 [IN]
326 @(SignMsi) - database files to sign.
327 ==================================================================================================
328 -->
329 <Target Name="SignMsi" />
330
331 <!--
332 ==================================================================================================
333 SignContainers
334
335 Redefine this target in your project in order to sign your bundle's detached containers.
336
337 [IN]
338 @(SignContainers) - detached container files to sign.
339 ==================================================================================================
340 -->
341 <Target Name="SignContainers" />
342
343 <!--
344 ==================================================================================================
345 SignBundleEngine
346
347 Redefine this target in your project in order to sign your bundle, after it has been inscribed
348 with the signatures of your signed containers.
349
350 [IN]
351 @(SignBundleEngine) - bundle engine file to sign.
352 ==================================================================================================
353 -->
354 <Target Name="SignBundleEngine" />
355
356 <!--
357 ==================================================================================================
358 SignBundle
359
360 Redefine this target in your project in order to sign your bundle, after the attached container
361 is reattached.
362
363 [IN]
364 @(SignBundle) - bundle file to sign.
365 ==================================================================================================
366 -->
367 <Target Name="SignBundle" />
368
369 <!--
370 ==================================================================================================
371 AfterSigning
372
373 Redefine this target in your project in order to run tasks just after all signing tasks.
374 ==================================================================================================
375 -->
376 <Target Name="AfterSigning" />
377
378</Project>
diff --git a/src/WixToolset.BuildTasks/wix.targets b/src/WixToolset.BuildTasks/wix.targets
new file mode 100644
index 00000000..c9704094
--- /dev/null
+++ b/src/WixToolset.BuildTasks/wix.targets
@@ -0,0 +1,1356 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="_CheckRequiredProperties" DefaultTargets="Build">
6 <PropertyGroup>
7 <WixTargetsImported>true</WixTargetsImported>
8 </PropertyGroup>
9
10 <!--
11 //////////////////////////////////////////////////////////////////////////////////////////////////
12 //////////////////////////////////////////////////////////////////////////////////////////////////
13 Extension Points
14 //////////////////////////////////////////////////////////////////////////////////////////////////
15 //////////////////////////////////////////////////////////////////////////////////////////////////
16 -->
17
18 <!-- Allow a user-customized targets files to be used as part of the build. -->
19 <Import Project="$(CustomBeforeWixTargets)" Condition=" '$(CustomBeforeWixTargets)' != '' and Exists('$(CustomBeforeWixTargets)')" />
20
21 <!-- These properties can be overridden to support non-default installations. -->
22 <PropertyGroup>
23 <WixBinDir Condition=" '$(WixBinDir)' == ''">$(MSBuildThisFileDirectory)</WixBinDir>
24 <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixBinDir)WixToolset.BuildTasks.dll</WixTasksPath>
25 <WixHarvestTargetsPath Condition=" '$(WixHarvestTargetsPath)' == '' ">$(WixBinDir)wix.harvest.targets</WixHarvestTargetsPath>
26 <WixSigningTargetsPath Condition=" '$(WixSigningTargetsPath)' == '' ">$(WixBinDir)wix.signing.targets</WixSigningTargetsPath>
27 <LuxTargetsPath Condition=" '$(LuxTargetsPath)' == '' ">$(WixBinDir)lux.targets</LuxTargetsPath>
28 <LuxTasksPath Condition=" '$(LuxTasksPath)' == '' ">$(WixBinDir)LuxTasks.dll</LuxTasksPath>
29 </PropertyGroup>
30
31 <!-- This makes the project files a dependency of all targets so that things rebuild if they change -->
32 <PropertyGroup>
33 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
34 <MSBuildAllProjects Condition="Exists('$(WixHarvestTargetsPath)')">$(MSBuildAllProjects);$(WixHarvestTargetsPath)</MSBuildAllProjects>
35 <MSBuildAllProjects Condition="Exists('$(WixSigningTargetsPath)')">$(MSBuildAllProjects);$(WixSigningTargetsPath)</MSBuildAllProjects>
36 <MSBuildAllProjects Condition="Exists('$(LuxTargetsPath)')">$(MSBuildAllProjects);$(LuxTargetsPath)</MSBuildAllProjects>
37 <MSBuildAllProjects Condition="Exists('$(CustomBeforeWixTargets)')">$(MSBuildAllProjects);$(CustomBeforeWixTargets)</MSBuildAllProjects>
38 <MSBuildAllProjects Condition="Exists('$(CustomAfterWixTargets)')">$(MSBuildAllProjects);$(CustomAfterWixTargets)</MSBuildAllProjects>
39 </PropertyGroup>
40
41 <!--
42 //////////////////////////////////////////////////////////////////////////////////////////////////
43 //////////////////////////////////////////////////////////////////////////////////////////////////
44 Declarations for Microsoft.Common.targets
45 //////////////////////////////////////////////////////////////////////////////////////////////////
46 //////////////////////////////////////////////////////////////////////////////////////////////////
47 -->
48
49 <PropertyGroup>
50 <DefaultLanguageSourceExtension>.wxs</DefaultLanguageSourceExtension>
51 <Language>wix</Language>
52 <TargetRuntime>Managed</TargetRuntime>
53
54 <!-- Use OutputName to set the AssemblyName for Microsoft.Common.targets -->
55 <OutputName Condition=" '$(OutputName)'=='' ">$(MSBuildProjectName)</OutputName>
56 <AssemblyName>$(OutputName)</AssemblyName>
57
58 <!-- Default the OutputType to a known WiX toolset TYPE. -->
59 <_OriginalOutputType>$(OutputType)</_OriginalOutputType>
60 <OutputType Condition=" '$(OutputType)' == '' ">Package</OutputType>
61 </PropertyGroup>
62
63 <!--
64 IDE Macros available from both integrated builds and from command line builds.
65 The following properties are 'macros' that are available via IDE for pre and post build steps.
66 All of them should be added to WixBuildMacroCollection to ensure that they are shown in the UI.
67 -->
68 <PropertyGroup>
69 <TargetExt Condition=" '$(OutputType)' == 'Package' ">.msi</TargetExt>
70 <TargetExt Condition=" '$(OutputType)' == 'Module' ">.msm</TargetExt>
71 <TargetExt Condition=" '$(OutputType)' == 'PatchCreation' ">.pcp</TargetExt>
72 <TargetExt Condition=" '$(OutputType)' == 'Library' ">.wixlib</TargetExt>
73 <TargetExt Condition=" '$(OutputType)' == 'Bundle' ">.exe</TargetExt>
74 </PropertyGroup>
75
76 <!-- Provide the correct output name for the .wixpdb -->
77 <ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true'">
78 <_DebugSymbolsIntermediatePath Include="$(PdbOutputDir)$(TargetPdbName)" Condition=" '@(_DebugSymbolsIntermediatePath)' == '' " />
79 </ItemGroup>
80
81 <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
82
83 <PropertyGroup>
84 <!-- Default pdb output path to the intermediate output directory -->
85 <PdbOutputDir Condition=" '$(PdbOutputDir)'=='' ">$(IntermediateOutputPath)</PdbOutputDir>
86 <PdbOutputDir Condition=" '$(PdbOutputDir)' != '' and !HasTrailingSlash('$(PdbOutputDir)') ">$(PdbOutputDir)\</PdbOutputDir>
87
88 <!-- Example, C:\MyProjects\MyProject\bin\debug\ -->
89 <TargetPdbDir Condition=" '$(PdbOutputDir)'!='' ">$([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `$(PdbOutputDir)`))`))</TargetPdbDir>
90
91 <!-- Example, MySetup.wixpdb" -->
92 <TargetPdbName Condition=" '$(TargetPdbName)' == '' ">$(TargetName).wixpdb</TargetPdbName>
93
94 <!-- Example, C:\MyProjects\MyProject\bin\debug\MyPackage.wixpdb -->
95 <TargetPdbPath Condition=" '$(TargetPdbPath)' == '' ">$(TargetPdbDir)$(TargetPdbName)</TargetPdbPath>
96 </PropertyGroup>
97
98 <!--
99 //////////////////////////////////////////////////////////////////////////////////////////////////
100 //////////////////////////////////////////////////////////////////////////////////////////////////
101 Property Declarations
102 //////////////////////////////////////////////////////////////////////////////////////////////////
103 //////////////////////////////////////////////////////////////////////////////////////////////////
104 -->
105
106 <!-- These tasks can be used as general-purpose build tasks. -->
107 <UsingTask TaskName="Candle" AssemblyFile="$(WixTasksPath)" />
108 <UsingTask TaskName="DoIt" AssemblyFile="$(WixTasksPath)" />
109 <UsingTask TaskName="Lit" AssemblyFile="$(WixTasksPath)" />
110 <UsingTask TaskName="Light" AssemblyFile="$(WixTasksPath)" />
111 <UsingTask TaskName="Torch" AssemblyFile="$(WixTasksPath)" />
112
113 <!-- These tasks are specific to the build process defined in this file, and are not considered general-purpose build tasks. -->
114 <UsingTask TaskName="CreateItemAvoidingInference" AssemblyFile="$(WixTasksPath)" />
115 <UsingTask TaskName="CreateProjectReferenceDefineConstants" AssemblyFile="$(WixTasksPath)" />
116 <UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" />
117 <UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)"/>
118 <UsingTask TaskName="ReplaceString" AssemblyFile="$(WixTasksPath)"/>
119 <UsingTask TaskName="GetCabList" AssemblyFile="$(WixTasksPath)" />
120 <UsingTask TaskName="GetLooseFileList" AssemblyFile="$(WixTasksPath)" />
121 <UsingTask TaskName="GenerateCompileWithObjectPath" AssemblyFile="$(WixTasksPath)"/>
122
123 <!-- WiX tools are 32bit EXEs, so run them out-of-proc when MSBuild is not 32bit. -->
124 <PropertyGroup>
125 <RunWixToolsOutOfProc Condition=" '$(PROCESSOR_ARCHITECTURE)'!='x86' ">true</RunWixToolsOutOfProc>
126 </PropertyGroup>
127
128 <PropertyGroup>
129 <BindContentsFile Condition=" '$(BindContentsFile)' == '' ">$(MSBuildProjectFile).BindContentsFileList.txt</BindContentsFile>
130 <BindOutputsFile Condition=" '$(BindOutputsFile)' == '' ">$(MSBuildProjectFile).BindOutputsFileList.txt</BindOutputsFile>
131 <BindBuiltOutputsFile Condition=" '$(BindBuiltOutputsFile)' == '' ">$(MSBuildProjectFile).BindBuiltOutputsFileList.txt</BindBuiltOutputsFile>
132 </PropertyGroup>
133
134 <PropertyGroup>
135 <CabinetCachePath Condition=" '$(CabinetCachePath)'=='' and '$(ReuseCabinetCache)'=='true' ">$(IntermediateOutputPath)cabcache\</CabinetCachePath>
136 </PropertyGroup>
137
138 <PropertyGroup>
139 <WixToolDir Condition=" '$(WixToolDir)' == ''">$(WixBinDir)</WixToolDir>
140 <WixExtDir Condition=" '$(WixExtDir)' == ''">$(WixToolDir)</WixExtDir>
141 </PropertyGroup>
142
143 <!--
144 Set the SignTargetPath item directly when output is a Bundle. The AssignCultures target
145 sets SignTargetPath item for other output types based on the cultures provided.
146 -->
147 <ItemGroup>
148 <SignTargetPath Include="$(TargetPath)" Condition=" '$(OutputType)' == 'Bundle' AND '$(SignOutput)' == 'true' AND '$(SuppressLayout)' != 'true' " />
149 </ItemGroup>
150
151 <!--
152 //////////////////////////////////////////////////////////////////////////////////////////////////
153 //////////////////////////////////////////////////////////////////////////////////////////////////
154 Default Compiler, Linker, and Librarian Property Declarations
155 //////////////////////////////////////////////////////////////////////////////////////////////////
156 //////////////////////////////////////////////////////////////////////////////////////////////////
157 -->
158
159 <!-- If WixExtension was passed in via the command line, then convert it to an ItemGroup -->
160 <ItemGroup>
161 <WixExtension Include="$(WixExtension)" Condition=" '$(WixExtension)' != '' " />
162 </ItemGroup>
163
164 <!-- Defaut Compiler properties. -->
165 <PropertyGroup>
166 <CompilerNoLogo Condition=" '$(CompilerNoLogo)' == '' ">$(NoLogo)</CompilerNoLogo>
167 <CompilerSuppressAllWarnings Condition=" '$(CompilerSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</CompilerSuppressAllWarnings>
168 <CompilerSuppressSpecificWarnings Condition=" '$(CompilerSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</CompilerSuppressSpecificWarnings>
169 <CompilerTreatWarningsAsErrors Condition=" '$(CompilerTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</CompilerTreatWarningsAsErrors>
170 <CompilerTreatSpecificWarningsAsErrors Condition=" '$(CompilerTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</CompilerTreatSpecificWarningsAsErrors>
171 <CompilerVerboseOutput Condition=" '$(CompilerVerboseOutput)' == '' ">$(VerboseOutput)</CompilerVerboseOutput>
172 <!-- TODO: This probably doesn't work any longer since Platform won't be defined until Microsoft.Common.targets is included -->
173 <InstallerPlatform Condition=" '$(InstallerPlatform)' == '' and '$(Platform)' != 'AnyCPU' and '$(Platform)' != 'Any CPU' ">$(Platform)</InstallerPlatform>
174 </PropertyGroup>
175
176 <!-- Default Lib properties. -->
177 <PropertyGroup>
178 <LibNoLogo Condition=" '$(LibNoLogo)' == '' ">$(NoLogo)</LibNoLogo>
179 <LibBindFiles Condition=" '$(LibBindFiles)' == '' ">$(BindFiles)</LibBindFiles>
180 <LibPedantic Condition=" '$(LibPedantic)' == '' ">$(Pedantic)</LibPedantic>
181 <LibSuppressAllWarnings Condition=" '$(LibSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</LibSuppressAllWarnings>
182 <LibSuppressSpecificWarnings Condition=" '$(LibSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</LibSuppressSpecificWarnings>
183 <LibSuppressSchemaValidation Condition=" '$(LibSuppressSchemaValidation)' == '' ">$(SuppressSchemaValidation)</LibSuppressSchemaValidation>
184 <LibSuppressIntermediateFileVersionMatching Condition=" '$(LibSuppressIntermediateFileVersionMatching)' == '' ">$(SuppressIntermediateFileVersionMatching)</LibSuppressIntermediateFileVersionMatching>
185 <LibTreatWarningsAsErrors Condition=" '$(LibTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</LibTreatWarningsAsErrors>
186 <LibTreatSpecificWarningsAsErrors Condition=" '$(LibTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</LibTreatSpecificWarningsAsErrors>
187 <LibVerboseOutput Condition=" '$(LibVerboseOutput)' == '' ">$(VerboseOutput)</LibVerboseOutput>
188 </PropertyGroup>
189
190 <!-- Default Linker properties. -->
191 <PropertyGroup>
192 <LinkerNoLogo Condition=" '$(LinkerNoLogo)' == '' ">$(NoLogo)</LinkerNoLogo>
193 <LinkerBindFiles Condition=" '$(LinkerBindFiles)' == '' ">$(BindFiles)</LinkerBindFiles>
194 <LinkerPedantic Condition=" '$(LinkerPedantic)' == '' ">$(Pedantic)</LinkerPedantic>
195 <LinkerSuppressAllWarnings Condition=" '$(LinkerSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</LinkerSuppressAllWarnings>
196 <LinkerSuppressSpecificWarnings Condition=" '$(LinkerSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</LinkerSuppressSpecificWarnings>
197 <LinkerSuppressSchemaValidation Condition=" '$(LinkerSuppressSchemaValidation)' == '' ">$(SuppressSchemaValidation)</LinkerSuppressSchemaValidation>
198 <LinkerSuppressIntermediateFileVersionMatching Condition=" '$(LinkerSuppressIntermediateFileVersionMatching)' == '' ">$(SuppressIntermediateFileVersionMatching)</LinkerSuppressIntermediateFileVersionMatching>
199 <LinkerTreatWarningsAsErrors Condition=" '$(LinkerTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</LinkerTreatWarningsAsErrors>
200 <LinkerTreatSpecificWarningsAsErrors Condition=" '$(LinkerTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</LinkerTreatSpecificWarningsAsErrors>
201 <LinkerVerboseOutput Condition=" '$(LinkerVerboseOutput)' == '' ">$(VerboseOutput)</LinkerVerboseOutput>
202 </PropertyGroup>
203
204 <!-- If BindInputPaths (or LinkerBindInputPaths) was passed in via the command line, then convert it to an ItemGroup -->
205 <ItemGroup>
206 <BindInputPaths Include="$(BindInputPaths)" Condition=" '$(BindInputPaths)' != '' " />
207 <LinkerBindInputPaths Include="$(LinkerBindInputPaths)" Condition=" '$(LinkerBindInputPaths)' != '' " />
208 </ItemGroup>
209
210 <!-- Default Lit and Light "properties" -->
211 <ItemGroup>
212 <LinkerBindInputPaths Condition=" '@(LinkerBindInputPaths)' == '' " Include="@(BindInputPaths)" />
213 </ItemGroup>
214
215 <!--
216 //////////////////////////////////////////////////////////////////////////////////////////////////
217 //////////////////////////////////////////////////////////////////////////////////////////////////
218 Initial Targets
219 //////////////////////////////////////////////////////////////////////////////////////////////////
220 //////////////////////////////////////////////////////////////////////////////////////////////////
221 -->
222
223 <!--
224 ==================================================================================================
225 _CheckRequiredProperties
226
227 Checks properties that must be set in the main project file or on the command line before
228 using this .TARGETS file.
229
230 [IN]
231 $(OutputName) - The name of the MSI/MSM/wixlib to build (without the extension)
232 $(OutputType) - Possible values are 'package', 'PatchCreation', 'module', 'library', 'bundle'
233 ==================================================================================================
234 -->
235 <PropertyGroup>
236 <_PleaseSetThisInProjectFile>Please set this in the project file before the &lt;Import&gt; of the wix.targets file.</_PleaseSetThisInProjectFile>
237 <_OutputTypeDescription>The OutputType defines whether a Windows Installer package (.msi), PatchCreation (.pcp), merge module (.msm), wix library (.wixlib), or self-extracting executable (.exe) is being built. $(_PleaseSetThisInProjectFile) Possible values are 'Package', 'Module', 'Library', and 'Bundle'.</_OutputTypeDescription>
238 </PropertyGroup>
239 <Target Name="_CheckRequiredProperties">
240
241 <Error
242 Code="WIXTARGETS100"
243 Condition=" '$(OutputName)' == '' "
244 Text="The OutputName property is not set in project &quot;$(MSBuildProjectFile)&quot;. The OutputName defines the name of the output without a file extension. $(_PleaseSetThisInProjectFile)" />
245
246 <Warning
247 Code="WIXTARGETS101"
248 Condition=" '$(_OriginalOutputType)' == '' "
249 Text="The OutputType property is not set in project &quot;$(MSBuildProjectFile)&quot;. Defaulting to '$(OutputType)'. $(_OutputTypeDescription)" />
250
251 <Error
252 Code="WIXTARGETS102"
253 Condition=" '$(OutputType)' != 'Package' and '$(OutputType)' != 'PatchCreation' and '$(OutputType)' != 'Module' and '$(OutputType)' != 'Library' and '$(OutputType)' != 'Bundle' "
254 Text="The OutputType property '$(OutputType)' is not valid in project &quot;$(MSBuildProjectFile)&quot;. $(_OutputTypeDescription)" />
255
256 <Error
257 Code="WIXTARGETS103"
258 Condition=" '$(MSBuildToolsVersion)' == '' OR '$(MSBuildToolsVersion)' &lt; '4.0' "
259 Text="MSBuild v$(MSBuildToolsVersion) is not supported by the project &quot;$(MSBuildProjectFile)&quot;. You must use MSBuild v4.0 or later." />
260
261 </Target>
262
263 <!--
264 //////////////////////////////////////////////////////////////////////////////////////////////////
265 //////////////////////////////////////////////////////////////////////////////////////////////////
266 Build Targets
267 //////////////////////////////////////////////////////////////////////////////////////////////////
268 //////////////////////////////////////////////////////////////////////////////////////////////////
269 -->
270
271 <!--
272 ==================================================================================================
273 CoreBuild - OVERRIDE DependsOn
274
275 The core build step calls each of the build targets.
276
277 This is where we insert our targets into the build process.
278 ==================================================================================================
279 -->
280 <PropertyGroup>
281 <CoreBuildDependsOn>
282 BuildOnlySettings;
283 PrepareForBuild;
284 PreBuildEvent;
285 ResolveReferences;
286
287 <!--CompileAndLink;-->
288 DoIt;
289 Signing;
290
291 GetTargetPath;
292 PrepareForRun;
293 IncrementalClean;
294 PostBuildEvent
295 </CoreBuildDependsOn>
296 </PropertyGroup>
297
298
299 <!--
300 //////////////////////////////////////////////////////////////////////////////////////////////////
301 //////////////////////////////////////////////////////////////////////////////////////////////////
302 Resolve References Targets
303 //////////////////////////////////////////////////////////////////////////////////////////////////
304 //////////////////////////////////////////////////////////////////////////////////////////////////
305 -->
306
307 <!--
308 ==================================================================================================
309 ResolveReferences - OVERRIDE DependsOn
310
311 ==================================================================================================
312 -->
313 <PropertyGroup>
314 <ResolveReferencesDependsOn>
315 BeforeResolveReferences;
316 AssignProjectConfiguration;
317 ResolveProjectReferences;
318 ResolveWixLibraryReferences;
319 ResolveWixExtensionReferences;
320 AfterResolveReferences
321 </ResolveReferencesDependsOn>
322 </PropertyGroup>
323
324 <!--
325 ================================================================================================
326 ResolveProjectReferences
327
328 Builds all of the referenced projects to get their outputs.
329
330 [IN]
331 @(NonVCProjectReference) - The list of non-VC project references.
332
333 [OUT]
334 @(ProjectReferenceWithConfiguration) - The list of non-VC project references.
335 @(WixLibProjects) - Paths to any .wixlibs that were built by referenced projects.
336 ================================================================================================
337 -->
338 <Target
339 Name="ResolveProjectReferences"
340 DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence"
341 Condition=" '@(ProjectReferenceWithConfiguration)' != '' ">
342
343 <!-- Issue a warning for each non-existent project. -->
344 <Warning
345 Text="The referenced project '%(_MSBuildProjectReferenceNonexistent.Identity)' does not exist."
346 Condition=" '@(_MSBuildProjectReferenceNonexistent)' != '' " />
347
348 <!--
349 When building this project from the IDE or when building a .sln from the command line or
350 when only building .wixlib project references, gather the referenced build outputs. The
351 code that builds the .sln will already have built the project, so there's no need to do
352 it again here and when building only .wixlib project references we'll use the results to
353 determine which projects to build.
354
355 The ContinueOnError setting is here so that, during project load, as much information as
356 possible will be passed to the compilers.
357 -->
358 <MSBuild
359 Projects="@(_MSBuildProjectReferenceExistent)"
360 Targets="%(_MSBuildProjectReferenceExistent.Targets);GetTargetPath"
361 Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform)"
362 Condition="('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '@(_MSBuildProjectReferenceExistent)' != '' "
363 ContinueOnError="!$(BuildingProject)">
364
365 <Output TaskParameter="TargetOutputs" ItemName="_GatheredProjectReferencePaths" />
366 </MSBuild>
367
368 <!--
369 Determine which project references should be built. Note: we will not build any project references
370 if building in the IDE because it builds project references directly.
371
372 If BuildProjectReferences is 'true' (the default) then take all MSBuild project references that exist
373 on disk and add them to the list of things to build. This is the easy case.
374 -->
375 <CreateItem
376 Include="@(_MSBuildProjectReferenceExistent)"
377 Condition=" '$(BuildProjectReferences)' == 'true' and '$(BuildingInsideVisualStudio)' != 'true' ">
378
379 <Output TaskParameter="Include" ItemName="_ProjectReferencesToBuild" />
380 </CreateItem>
381
382 <!--
383 If BuildProjectReferences is 'wixlib' then build only the MSBuild project references that exist and
384 create a .wixlib file. That requires us to first filter the gathered project references down to only
385 those that build .wixlibs.
386 -->
387 <CreateItem
388 Include="@(_GatheredProjectReferencePaths)"
389 Condition=" '$(BuildProjectReferences)' == 'wixlib' and '%(Extension)' == '.wixlib' and '$(BuildingInsideVisualStudio)' != 'true' ">
390
391 <Output TaskParameter="Include" ItemName="_ReferencedWixLibPaths" />
392 </CreateItem>
393
394 <!--
395 The second step when building only 'wixlib' project references is to create the list of existing MSBuild
396 project references that do *not* build a .wixlib. These are the projects that will be skipped.
397 -->
398 <CreateItem
399 Include="@(_MSBuildProjectReferenceExistent->'%(FullPath)')"
400 Exclude="@(_ReferencedWixLibPaths->'%(MSBuildSourceProjectFile)')"
401 Condition=" '$(BuildProjectReferences)' == 'wixlib' and '$(BuildingInsideVisualStudio)' != 'true' ">
402
403 <Output TaskParameter="Include" ItemName="_ProjectReferencesToSkip" />
404 </CreateItem>
405
406 <!--
407 Finally, when building only 'wixlib' project references, the list of projects to build are naturally the
408 list of projects *not* being skipped.
409 -->
410 <CreateItem
411 Include="@(_MSBuildProjectReferenceExistent->'%(FullPath)')"
412 Exclude="@(_ProjectReferencesToSkip)"
413 Condition=" '$(BuildProjectReferences)' == 'wixlib' and '$(BuildingInsideVisualStudio)' != 'true' ">
414
415 <Output TaskParameter="Include" ItemName="_ProjectReferencesToBuild" />
416 </CreateItem>
417
418 <!-- Display a warning for all projects being skipped. -->
419 <Warning
420 Text="BuildProjectReferences set to '$(BuildProjectReferences)'. Skipping the non-Library project: %(_ProjectReferencesToSkip.Identity)"
421 Condition=" '@(_ProjectReferencesToSkip)' != '' " />
422
423 <Message
424 Importance="low"
425 Text="Project reference to build: %(_ProjectReferencesToBuild.Identity), properties: %(_ProjectReferencesToBuild.Properties)"
426 Condition=" '@(_ProjectReferencesToBuild)' != '' " />
427
428 <!--
429 Build referenced projects when building from the command line.
430
431 The $(ProjectReferenceBuildTargets) will normally be blank so that the project's default target
432 is used during a P2P reference. However if a custom build process requires that the referenced
433 project has a different target to build it can be specified.
434 -->
435 <MSBuild
436 Projects="@(_ProjectReferencesToBuild)"
437 Targets="$(ProjectReferenceBuildTargets)"
438 Properties="%(_ProjectReferencesToBuild.SetConfiguration);%(_ProjectReferencesToBuild.SetPlatform)"
439 Condition=" '@(_ProjectReferencesToBuild)' != '' ">
440
441 <Output TaskParameter="TargetOutputs" ItemName="_BuiltProjectReferencePaths" />
442 </MSBuild>
443
444 <!--
445 VC project references must build GetNativeTargetPath because neither GetTargetPath nor the return of the default build
446 target return the output for a native .vcxproj.
447 -->
448 <MSBuild
449 Projects="@(_MSBuildProjectReferenceExistent)"
450 Targets="GetNativeTargetPath"
451 Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform)"
452 Condition=" '@(ProjectReferenceWithConfiguration)' != '' and '%(_MSBuildProjectReferenceExistent.Extension)' == '.vcxproj' ">
453
454 <Output TaskParameter="TargetOutputs" ItemName="_ResolvedProjectReferencePaths" />
455 <Output TaskParameter="TargetOutputs" ItemName="_MSBuildResolvedProjectReferencePaths" />
456 </MSBuild>
457
458 <!-- Assign the unique gathered and built project references to the resolved project
459 reference paths. -->
460 <RemoveDuplicates Inputs="@(_GatheredProjectReferencePaths);@(_BuiltProjectReferencePaths)">
461 <Output TaskParameter="Filtered" ItemName="_ResolvedProjectReferencePaths" />
462 <Output TaskParameter="Filtered" ItemName="_MSBuildResolvedProjectReferencePaths" />
463 </RemoveDuplicates>
464
465 <!-- Create list of all .wixlib project references. -->
466 <CreateItem
467 Include="@(_ResolvedProjectReferencePaths)"
468 Condition=" '%(Extension)' == '.wixlib' ">
469
470 <Output TaskParameter="Include" ItemName="WixLibProjects" />
471 </CreateItem>
472
473 <Message
474 Importance="low"
475 Text="Library from referenced projects: %(WixLibProjects.Identity)"
476 Condition=" '@(WixLibProjects)' != '' " />
477
478 </Target>
479
480 <!--
481 ================================================================================================
482 ResolveWixLibraryReferences
483
484 Resolve the library references to full paths.
485
486 [IN]
487 @(WixLibrary) - The list of .wixlib files.
488
489 [OUT]
490 @(_ResolvedWixLibraryPaths) - Item group with full paths to libraries
491 ================================================================================================
492 -->
493 <PropertyGroup>
494 <ResolveWixLibraryReferencesDependsOn></ResolveWixLibraryReferencesDependsOn>
495 </PropertyGroup>
496 <Target
497 Name="ResolveWixLibraryReferences"
498 DependsOnTargets="$(ResolveWixLibraryReferencesDependsOn)"
499 Condition=" '@(WixLibrary)' != ''">
500
501 <!--
502 The WixLibrarySearchPaths property is set to find assemblies in the following order:
503
504 (1) $(ReferencePaths) - the reference paths property, which comes from the .USER file.
505 (2) The hintpath from the referenced item itself, indicated by {HintPathFromItem}.
506 (3) Treat the reference's Include as if it were a real file name.
507 (4) Path specified by the WixExtDir property.
508 -->
509 <CreateProperty Condition=" '$(WixLibrarySearchPaths)' == '' " Value="
510 $(ReferencePaths);
511 {HintPathFromItem};
512 {RawFileName};
513 $(WixExtDir)
514 ">
515 <Output TaskParameter="Value" PropertyName="WixLibrarySearchPaths" />
516 </CreateProperty>
517
518 <ResolveWixReferences
519 WixReferences="@(WixLibrary)"
520 SearchPaths="$(WixLibrarySearchPaths)"
521 SearchFilenameExtensions=".wixlib">
522 <Output TaskParameter="ResolvedWixReferences" ItemName="_AllResolvedWixLibraryPaths" />
523 </ResolveWixReferences>
524
525 <!-- Remove duplicate library items that would cause build errors -->
526 <RemoveDuplicates Inputs="@(_AllResolvedWixLibraryPaths)">
527 <Output TaskParameter="Filtered" ItemName="_ResolvedWixLibraryPaths" />
528 </RemoveDuplicates>
529
530 </Target>
531
532 <!--
533 ==================================================================================================
534 ResolveWixExtensionReferences
535
536 Resolves WiX extension references to full paths. Any properties you use
537 to resolve paths to extensions must be defined before importing this
538 file or the extensions will be automatically resolved to $(WixExtDir).
539
540 [IN]
541 @(WixExtension) - WixExtension item group
542
543 [OUT]
544 @(_ResolvedWixExtensionPaths) - Item group with full paths to extensions
545 ==================================================================================================
546 -->
547 <PropertyGroup>
548 <ResolveWixExtensionReferencesDependsOn></ResolveWixExtensionReferencesDependsOn>
549 </PropertyGroup>
550 <Target
551 Name="ResolveWixExtensionReferences"
552 DependsOnTargets="$(ResolveWixExtensionReferencesDependsOn)"
553 Condition=" '@(WixExtension)' != ''">
554
555 <!--
556 The WixExtensionSearchPaths property is set to find assemblies in the following order:
557
558 (1) $(ReferencePaths) - the reference paths property, which comes from the .USER file.
559 (2) The hintpath from the referenced item itself, indicated by {HintPathFromItem}.
560 (3) Treat the reference's Include as if it were a real file name.
561 (4) Path specified by the WixExtDir property.
562 -->
563 <CreateProperty Condition=" '$(WixExtensionSearchPaths)' == '' " Value="
564 $(ReferencePaths);
565 {HintPathFromItem};
566 {RawFileName};
567 $(WixExtDir)
568 ">
569 <Output TaskParameter="Value" PropertyName="WixExtensionSearchPaths" />
570 </CreateProperty>
571
572 <ResolveWixReferences
573 WixReferences="@(WixExtension)"
574 SearchPaths="$(WixExtensionSearchPaths)"
575 SearchFilenameExtensions=".dll">
576 <Output TaskParameter="ResolvedWixReferences" ItemName="_AllResolvedWixExtensionPaths" />
577 </ResolveWixReferences>
578
579 <!-- Remove duplicate extension items that would cause build errors -->
580 <RemoveDuplicates Inputs="@(_AllResolvedWixExtensionPaths)">
581 <Output TaskParameter="Filtered" ItemName="_ResolvedWixExtensionPaths" />
582 </RemoveDuplicates>
583 </Target>
584
585 <!--
586 ================================================================================================
587 GetTargetPath - OVERRIDE DependsOn
588
589 This stand-alone target returns the name of the build product (i.e. MSI, MSM) that would be
590 produced if we built this project.
591 ================================================================================================
592 -->
593 <PropertyGroup>
594 <GetTargetPathDependsOn>AssignCultures</GetTargetPathDependsOn>
595 </PropertyGroup>
596
597
598 <!--
599 //////////////////////////////////////////////////////////////////////////////////////////////////
600 //////////////////////////////////////////////////////////////////////////////////////////////////
601 DoIt Targets
602 //////////////////////////////////////////////////////////////////////////////////////////////////
603 //////////////////////////////////////////////////////////////////////////////////////////////////
604 -->
605
606 <!--
607 ==================================================================================================
608 DoIt
609 ==================================================================================================
610 -->
611 <PropertyGroup>
612 <DoItDependsOn>
613 PrepareForBuild;
614 ResolveReferences;
615 BeforeCompile;
616 _TimeStampBeforeCompile;
617 Harvest;
618
619 CalculateDefineConstants;
620 GenerateCompileWithObjectPath;
621
622 AssignCultures;
623 ReadPreviousBindInputsAndBuiltOutputs;
624
625 ActuallyDoIt;
626
627 UpdateLinkFileWrites;
628 _TimeStampAfterCompile;
629 AfterCompile
630 </DoItDependsOn>
631 </PropertyGroup>
632 <Target
633 Name="DoIt"
634 DependsOnTargets="$(DoItDependsOn)" />
635
636 <Target
637 Name="ActuallyDoIt"
638
639 Inputs="@(Compile);
640 @(Content);
641 @(EmbeddedResource);
642 @(WixObject);
643 @(_ResolvedProjectReferencePaths);
644 @(_ResolvedWixLibraryPaths);
645 @(_ResolvedWixExtensionPaths);
646 @(_BindInputs);
647 $(MSBuildAllProjects)"
648 Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)"
649 Condition=" '@(Compile)' != '' ">
650
651 <PropertyGroup>
652 <OutputFile>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)))</OutputFile>
653 <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile>
654 </PropertyGroup>
655
656 <DoIt
657 SourceFiles="@(_CompileWithObjectPath)"
658 LibraryFiles="@(WixLibProjects);@(_ResolvedWixLibraryPaths)"
659 LocalizationFiles="@(EmbeddedResource)"
660
661 Cultures="%(CultureGroup.Identity)"
662
663 ExtensionDirectory="$(WixExtDir)"
664 Extensions="@(_ResolvedWixExtensionPaths)"
665
666 IntermediateDirectory="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)"
667
668 OutputFile="$(OutputFile)"
669 OutputType="$(OutputType)"
670 PdbOutputFile="$(PdbOutputFile)"
671
672 AdditionalOptions="$(CompilerAdditionalOptions) $(LinkerAdditionalOptions)"
673 DefineConstants="$(DefineConstants);$(SolutionDefineConstants);$(ProjectDefineConstants);$(ProjectReferenceDefineConstants)"
674 IncludeSearchPaths="$(IncludeSearchPaths)"
675 InstallerPlatform="$(InstallerPlatform)"
676 NoLogo="true"
677 Pedantic="$(Pedantic)"
678 ReferencePaths="$(ReferencePaths)"
679
680 SuppressSpecificWarnings="$(CompilerSuppressSpecificWarnings);$(LinkerSuppressSpecificWarnings)"
681 TreatSpecificWarningsAsErrors="$(CompilerTreatSpecificWarningsAsErrors)"
682
683 BindInputPaths="@(LinkerBindInputPaths)"
684 BindFiles="$(LinkerBindFiles)"
685 BindContentsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)"
686 BindOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)"
687 BindBuiltOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)"
688
689 CabinetCachePath="$(CabinetCachePath)"
690 CabinetCreationThreadCount="$(CabinetCreationThreadCount)"
691 DefaultCompressionLevel="$(DefaultCompressionLevel)"
692
693 UnreferencedSymbolsFile="$(UnreferencedSymbolsFile)"
694 WixProjectFile="$(ProjectPath)"
695 WixVariables="$(WixVariables)"
696
697 SuppressValidation="$(SuppressValidation)"
698 SuppressIces="$(SuppressIces)"
699 AdditionalCub="$(AdditionalCub)" />
700
701 <!--
702 SuppressAllWarnings="$(CompilerSuppressAllWarnings);$(LinkerSuppressAllWarnings)"
703 TreatWarningsAsErrors="$(CompilerTreatWarningsAsErrors);$(LinkerTreatWarningsAsErrors)"
704 VerboseOutput="$(CompilerVerboseOutput);$(LinkerVerboseOutput)"
705 -->
706
707</Target>
708
709
710 <!--
711 //////////////////////////////////////////////////////////////////////////////////////////////////
712 //////////////////////////////////////////////////////////////////////////////////////////////////
713 CompileAndLink Targets
714 //////////////////////////////////////////////////////////////////////////////////////////////////
715 //////////////////////////////////////////////////////////////////////////////////////////////////
716 -->
717
718 <!--
719 ==================================================================================================
720 CompileAndLink
721 ==================================================================================================
722 -->
723 <PropertyGroup>
724 <CompileAndLinkDependsOn>
725 ResolveReferences;
726 BeforeCompile;
727 _TimeStampBeforeCompile;
728 Harvest;
729 Compile;
730 Lib;
731 Link;
732 UpdateLinkFileWrites;
733 _TimeStampAfterCompile;
734 AfterCompile
735 </CompileAndLinkDependsOn>
736 </PropertyGroup>
737 <Target
738 Name="CompileAndLink"
739 DependsOnTargets="$(CompileAndLinkDependsOn)" />
740
741 <!--
742 ==================================================================================================
743 CalculateDefineConstants
744
745 Adds project references to the constants passed into the compiler.
746
747 [IN]
748 @(_ResolvedProjectReferencePaths) - paths to projects' outputs
749 $(VSProjectConfigurations) - map of project names to configurations, provided by VS when building in the IDE
750
751 [OUT]
752 $(ProjectReferenceDefineConstants) - the list of referenced project variables to be passed into the compiler
753 ==================================================================================================
754 -->
755 <PropertyGroup>
756 <CalculateDefineConstantsDependsOn>ResolveReferences</CalculateDefineConstantsDependsOn>
757 </PropertyGroup>
758 <Target
759 Name="CalculateDefineConstants"
760 DependsOnTargets="$(CalculateDefineConstantsDependsOn)"
761 Condition=" '@(_ResolvedProjectReferencePaths)' != '' ">
762
763 <PropertyGroup>
764 <ProjectDefineConstants>
765 Configuration=$(ConfigurationName);
766 OutDir=$(OutDir);
767 Platform=$(PlatformName);
768 ProjectDir=$(ProjectDir);
769 ProjectExt=$(ProjectExt);
770 ProjectFileName=$(ProjectFileName);
771 ProjectName=$(ProjectName);
772 ProjectPath=$(ProjectPath);
773 TargetDir=$(TargetDir);
774 TargetExt=$(TargetExt);
775 TargetFileName=$(TargetFileName);
776 TargetName=$(TargetName);
777 TargetPath=$(TargetPath);
778 </ProjectDefineConstants>
779 </PropertyGroup>
780
781 <PropertyGroup>
782 <SolutionDefineConstants Condition=" '$(DevEnvDir)'!='*Undefined*' ">$(SolutionDefineConstants);DevEnvDir=$(DevEnvDir)</SolutionDefineConstants>
783 <SolutionDefineConstants Condition=" '$(SolutionDir)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionDir=$(SolutionDir)</SolutionDefineConstants>
784 <SolutionDefineConstants Condition=" '$(SolutionExt)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionExt=$(SolutionExt)</SolutionDefineConstants>
785 <SolutionDefineConstants Condition=" '$(SolutionFileName)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionFileName=$(SolutionFileName)</SolutionDefineConstants>
786 <SolutionDefineConstants Condition=" '$(SolutionName)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionName=$(SolutionName)</SolutionDefineConstants>
787 <SolutionDefineConstants Condition=" '$(SolutionPath)'!='*Undefined*' ">$(SolutionDefineConstants);SolutionPath=$(SolutionPath)</SolutionDefineConstants>
788 </PropertyGroup>
789
790 <CreateProjectReferenceDefineConstants
791 ProjectReferencePaths="@(_ResolvedProjectReferencePaths)"
792 ProjectConfigurations="$(VSProjectConfigurations)">
793
794 <Output TaskParameter="DefineConstants" PropertyName="ProjectReferenceDefineConstants" />
795 </CreateProjectReferenceDefineConstants>
796
797 <ItemGroup>
798 <LinkerBindInputPaths Include="%(_ResolvedProjectReferencePaths.RootDir)%(_ResolvedProjectReferencePaths.Directory)" />
799 </ItemGroup>
800 </Target>
801
802 <!--
803 ================================================================================================
804 GenerateCompileWithObjectPath
805
806 Generates metadata on the for compile output objects.
807
808 ================================================================================================
809 -->
810 <PropertyGroup>
811 <GenerateCompileWithObjectPathDependsOn></GenerateCompileWithObjectPathDependsOn>
812 </PropertyGroup>
813 <Target
814 Name="GenerateCompileWithObjectPath"
815 Condition=" '@(Compile)' != '' ">
816
817 <GenerateCompileWithObjectPath
818 Compile="@(Compile)"
819 IntermediateOutputPath="$(IntermediateOutputPath)">
820 <Output TaskParameter="CompileWithObjectPath" ItemName="_CompileWithObjectPath" />
821 </GenerateCompileWithObjectPath>
822
823 </Target>
824
825 <!--
826 ================================================================================================
827 Compile
828
829 Compiles the wxs files into wixobj files using candle.exe.
830
831 [IN]
832 @(Compile) - The list of wxs files to compile.
833 @(Content) - Files that the project uses in the installer.
834 @(WixExtension) - The list of wixlib or wix dll extensions.
835
836 [OUT]
837 @(CompileObjOutput) - The compiled .wixobj files.
838 ================================================================================================
839 -->
840 <PropertyGroup>
841 <CompileDependsOn>
842 PrepareForBuild;
843 ResolveReferences;
844 CalculateDefineConstants;
845 GenerateCompileWithObjectPath
846 </CompileDependsOn>
847 </PropertyGroup>
848 <Target
849 Name="Compile"
850 Inputs="@(Compile);
851 @(Content);
852 @(_ResolvedWixExtensionPaths);
853 @(_ResolvedProjectReferencePaths);
854 $(MSBuildAllProjects)"
855 Outputs="@(_CompileWithObjectPath -> '%(ObjectPath)%(Filename).wixobj')"
856 DependsOnTargets="$(CompileDependsOn)"
857 Condition=" '@(Compile)' != '' ">
858
859 <Candle
860 SourceFiles="@(_CompileWithObjectPath)"
861 AdditionalOptions="$(CompilerAdditionalOptions)"
862 DefineConstants="$(DefineConstants);$(SolutionDefineConstants);$(ProjectDefineConstants);$(ProjectReferenceDefineConstants)"
863 ExtensionDirectory="$(WixExtDir)"
864 Extensions="@(_ResolvedWixExtensionPaths)"
865 PreprocessToStdOut="$(PreprocessToStdOut)"
866 PreprocessToFile="$(PreprocessToFile)"
867 IncludeSearchPaths="$(IncludeSearchPaths)"
868 InstallerPlatform="$(InstallerPlatform)"
869 IntermediateDirectory="$(IntermediateOutputPath)"
870 NoLogo="$(CompilerNoLogo)"
871 OutputFile="%(_CompileWithObjectPath.ObjectPath)"
872 Pedantic="$(Pedantic)"
873 ReferencePaths="$(ReferencePaths)"
874 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
875 SuppressAllWarnings="$(CompilerSuppressAllWarnings)"
876 SuppressSpecificWarnings="$(CompilerSuppressSpecificWarnings)"
877 ToolPath="$(WixToolDir)"
878 TreatWarningsAsErrors="$(CompilerTreatWarningsAsErrors)"
879 TreatSpecificWarningsAsErrors="$(CompilerTreatSpecificWarningsAsErrors)"
880 VerboseOutput="$(CompilerVerboseOutput)">
881 </Candle>
882
883 <!-- These will be still be set even if the Compile target is up to date. -->
884 <ItemGroup>
885 <CompileObjOutput Include="@(_CompileWithObjectPath -> '%(ObjectPath)%(Filename).wixobj')" />
886 <FileWrites Include="@(CompileObjOutput)" />
887 </ItemGroup>
888 </Target>
889
890 <!--
891 ================================================================================================
892 Lib
893
894 Links the .wixobj, .wxl, .wixlib, wix extensions into a .wixlib file using lit.exe.
895
896 [IN]
897 @(CompileObjOutput) - The compiled .wixobj file.
898 @(EmbeddedResource) - The list of wxl files to use for localization.
899 @(WixObject) - The list of .wixobj files.
900 @(WixLibrary) - The list of .wixlib files.
901 @(WixExtension) - The list of wix dll extension files.
902
903 [OUT]
904 $(TargetPath) - The compiled .wixlib file.
905 ================================================================================================
906 -->
907 <PropertyGroup>
908 <LibDependsOn>
909 PrepareForBuild;
910 ResolveReferences
911 </LibDependsOn>
912 </PropertyGroup>
913 <Target
914 Name="Lib"
915 Inputs="@(CompileObjOutput);
916 @(EmbeddedResource);
917 @(WixObject);
918 @(WixLibrary);
919 @(_ResolvedWixExtensionPaths);
920 $(MSBuildAllProjects)"
921 Outputs="$(TargetPath)"
922 DependsOnTargets="$(LibDependsOn)"
923 Condition=" '$(OutputType)' == 'Library' ">
924
925 <Lit
926 ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(WixLibrary)"
927 AdditionalOptions="$(LibAdditionalOptions)"
928 BindInputPaths="@(LinkerBindInputPaths)"
929 BindFiles="$(LibBindFiles)"
930 ExtensionDirectory="$(WixExtDir)"
931 Extensions="@(_ResolvedWixExtensionPaths)"
932 LocalizationFiles="@(EmbeddedResource)"
933 NoLogo="$(LibNoLogo)"
934 OutputFile="$(TargetPath)"
935 Pedantic="$(LibPedantic)"
936 ReferencePaths="$(ReferencePaths)"
937 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
938 SuppressAllWarnings="$(LibSuppressAllWarnings)"
939 SuppressIntermediateFileVersionMatching="$(LibSuppressIntermediateFileVersionMatching)"
940 SuppressSchemaValidation="$(LibSuppressSchemaValidation)"
941 SuppressSpecificWarnings="$(LibSuppressSpecificWarnings)"
942 ToolPath="$(WixToolDir)"
943 TreatWarningsAsErrors="$(LibTreatWarningsAsErrors)"
944 VerboseOutput="$(LibVerboseOutput)" />
945 </Target>
946
947 <!--
948 ================================================================================================
949 AssignCultures
950
951 Determines the final list of culture groups to build based on either the Cultures property or
952 those specified in .wxl files.
953
954 Culture groups specified in the Cultures property must be specified as a semi-colon
955 delimited list of groups, with comma-delimited cultures within a group.
956 For example:
957 <Cultures>en-US,en;en-GB,en</Cultures>
958 This will build 2 targets, outputing to en-US and en-GB sub-folders. Light will first look
959 for strings in the first culture (en-US or en-GB) then the second (en).
960
961 Cultures of .wxl files will be used when the Culture property is not set. The culture of a
962 .wxl file is determined by the Culture attribute in the WixLocalization element in the file
963
964 Sets the OutputFolder metadata on each culture group. In most cases this is the same as the
965 first culture in the culture group. When the Culture's property is unspecified and no .wxl
966 files are provided this is the same as the output directory. When the Culture's property
967 specifies a single culture group and no .wxl files are provided this is the same as the output
968 directory.
969
970 Updates the TargetPath and TargetPdbPath properties to be used in subsequent targets.
971
972 [IN]
973 @(EmbeddedResource) - The list of wxl files to use for localization.
974 $(Cultures) - The list of culture groups to build.
975
976 [OUT]
977 @(CultureGroup) - The list of culture group strings with OutputFolder metadata
978 $(TargetPath) - Property list of target link output MSIs/MSMs
979 $(TargetPdbPath) - Property list of target output pdbs
980 @(SignTargetPath) - The list of target to be signed
981
982 ================================================================================================
983 -->
984 <Target
985 Name="AssignCultures"
986 Condition=" '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' ">
987
988 <WixAssignCulture
989 Cultures="$(Cultures)"
990 Files="@(EmbeddedResource)">
991
992 <Output TaskParameter="CultureGroups" ItemName="CultureGroup" />
993 </WixAssignCulture>
994
995 <!-- Build an itemgroup of outputs -->
996 <ItemGroup>
997 <_TargetPathItems Include="$(TargetDir)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" />
998 <_TargetPdbPathItems Include="$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)" />
999 </ItemGroup>
1000
1001 <!-- Convert the itemgroup to a semicolon-delimited property -->
1002 <PropertyGroup>
1003 <TargetPath>@(_TargetPathItems)</TargetPath>
1004 <TargetPdbPath>@(_TargetPdbPathItems)</TargetPdbPath>
1005 </PropertyGroup>
1006
1007 <!-- Set the sign target items, if we're signing output. -->
1008 <ItemGroup Condition=" '$(SignOutput)' == 'true' AND '$(SuppressLayout)' != 'true' ">
1009 <SignTargetPath Include="@(_TargetPathItems)" />
1010 </ItemGroup>
1011 </Target>
1012
1013 <!--
1014 ================================================================================================
1015 ReadPreviousBindInputsAndBuiltOutputs
1016
1017 Reads a previous build's Bind contents and built outputs file into @(_BindInputs) and
1018 @(_BindBuiltOutputs) respectively.
1019
1020 Note: Only the *built* outputs are used because using files copied to output folder
1021 can cause perpetual incremental build.
1022
1023 Imagine the case where you have: Msi.wixproj -> Lib.wixproj -> Exe.csproj. The
1024 Exe.csproj cannot be both an input to Lib.wixproj and an output of Msi.wixproj
1025 (as an uncompressed file) because the Lib.wixproj will always newer than the
1026 Exe.csproj.
1027
1028 [IN]
1029
1030 [OUT]
1031 @(_BindInputs) - the content files required to bind (i.e. the Binary/@SourceFile and File/@Source files).
1032 @(_BindBuiltOutputs) - the previously built .msi, .msm, .pcp, .exe .wixpdb, .cabs, etc.
1033 Does not include content copied to output folder.
1034 ================================================================================================
1035 -->
1036 <Target
1037 Name="ReadPreviousBindInputsAndBuiltOutputs">
1038
1039 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)">
1040 <Output TaskParameter="Lines" ItemName="_BindInputs" />
1041 </ReadLinesFromFile>
1042
1043 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)">
1044 <Output TaskParameter="Lines" ItemName="_BindBuiltOutputs" />
1045 </ReadLinesFromFile>
1046
1047 <Message Importance="low" Text="Previous bind inputs: @(_BindInputs)" />
1048 <Message Importance="low" Text="Previous bind outputs: @(_BindBuiltOutputs)" />
1049 </Target>
1050
1051 <!--
1052 ================================================================================================
1053 Link
1054
1055 Links the .wixobj, .wxl, .wixlib, wix extensions into an .msi or .msm file using light.exe,
1056 once per culture group. All WXL files are passed into light and the culture switch determines
1057 which are used
1058
1059 [IN]
1060 @(CompileObjOutput) - The compiled .wixobj file.
1061 @(CultureGroup) - The cultures to build
1062 @(EmbeddedResource) - The list of wxl files to use for localization.
1063 @(WixObject) - The list of .wixobj files.
1064 @(WixLibrary) - The list of .wixlib files.
1065 @(WixExtension) - The list of wix dll extension files.
1066
1067 [OUT]
1068 $(TargetDir)\%(Culture)\$(TargetName)$(TargetExt) - The compiled .msi, .msm, or .exe files.
1069 ================================================================================================
1070 -->
1071 <PropertyGroup>
1072 <LinkDependsOn>
1073 PrepareForBuild;
1074 ResolveReferences;
1075 AssignCultures;
1076 ReadPreviousBindInputsAndBuiltOutputs;
1077 </LinkDependsOn>
1078 </PropertyGroup>
1079 <Target
1080 Name="Link"
1081 Inputs="@(CompileObjOutput);
1082 @(EmbeddedResource);
1083 @(WixObject);
1084 @(_ResolvedProjectReferencePaths);
1085 @(_ResolvedWixLibraryPaths);
1086 @(_ResolvedWixExtensionPaths);
1087 $(MSBuildAllProjects);
1088 @(_BindInputs)"
1089 Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)"
1090 DependsOnTargets="$(LinkDependsOn)"
1091 Condition=" '$(OutputType)' == 'Bundle' or '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' ">
1092
1093 <PropertyGroup>
1094 <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile>
1095 </PropertyGroup>
1096
1097 <!-- Call light using the culture subdirectory for output -->
1098 <Light
1099 ObjectFiles="@(CompileObjOutput);@(WixObject);@(WixLibProjects);@(_ResolvedWixLibraryPaths)"
1100 AdditionalOptions="$(LinkerAdditionalOptions)"
1101 AllowIdenticalRows="$(AllowIdenticalRows)"
1102 AllowUnresolvedReferences="$(AllowUnresolvedReferences)"
1103 AdditionalCub="$(AdditionalCub)"
1104 BackwardsCompatibleGuidGeneration="$(BackwardsCompatibleGuidGeneration)"
1105 BindInputPaths="@(LinkerBindInputPaths)"
1106 BindFiles="$(LinkerBindFiles)"
1107 BindContentsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)"
1108 BindOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)"
1109 BindBuiltOutputsFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)"
1110 CabinetCachePath="$(CabinetCachePath)"
1111 CabinetCreationThreadCount="$(CabinetCreationThreadCount)"
1112 Cultures="%(CultureGroup.Identity)"
1113 CustomBinder="$(CustomBinder)"
1114 DefaultCompressionLevel="$(DefaultCompressionLevel)"
1115 DropUnrealTables="$(DropUnrealTables)"
1116 ExactAssemblyVersions="$(ExactAssemblyVersions)"
1117 ExtensionDirectory="$(WixExtDir)"
1118 Extensions="@(_ResolvedWixExtensionPaths)"
1119 Ices="$(Ices)"
1120 LeaveTemporaryFiles="$(LeaveTemporaryFiles)"
1121 LocalizationFiles="@(EmbeddedResource)"
1122 NoLogo="$(LinkerNoLogo)"
1123 OutputAsXml="$(OutputAsXml)"
1124 OutputFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)"
1125 PdbOutputFile="$(PdbOutputFile)"
1126 Pedantic="$(LinkerPedantic)"
1127 ReferencePaths="$(ReferencePaths)"
1128 ReuseCabinetCache="$(ReuseCabinetCache)"
1129 RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
1130 SuppressAclReset="$(SuppressAclReset)"
1131 SuppressAllWarnings="$(LinkerSuppressAllWarnings)"
1132 SuppressAssemblies="$(SuppressAssemblies)"
1133 SuppressDefaultAdminSequenceActions="$(SuppressDefaultAdminSequenceActions)"
1134 SuppressDefaultAdvSequenceActions="$(SuppressDefaultAdvSequenceActions)"
1135 SuppressDefaultUISequenceActions="$(SuppressDefaultUISequenceActions)"
1136 SuppressFileHashAndInfo="$(SuppressFileHashAndInfo)"
1137 SuppressFiles="$(SuppressFiles)"
1138 SuppressIntermediateFileVersionMatching="$(LinkerSuppressIntermediateFileVersionMatching)"
1139 SuppressIces="$(SuppressIces)"
1140 SuppressLayout="$(SuppressLayout)"
1141 SuppressLocalization="$(SuppressLocalization)"
1142 SuppressMsiAssemblyTableProcessing="$(SuppressMsiAssemblyTableProcessing)"
1143 SuppressPdbOutput="$(SuppressPdbOutput)"
1144 SuppressSchemaValidation="$(LinkerSuppressSchemaValidation)"
1145 SuppressValidation="$(SuppressValidation)"
1146 SuppressSpecificWarnings="$(LinkerSuppressSpecificWarnings)"
1147 SuppressTagSectionIdAttributeOnTuples="$(SuppressTagSectionIdAttributeOnTuples)"
1148 ToolPath="$(WixToolDir)"
1149 TreatWarningsAsErrors="$(LinkerTreatWarningsAsErrors)"
1150 UnreferencedSymbolsFile="$(UnreferencedSymbolsFile)"
1151 VerboseOutput="$(LinkerVerboseOutput)"
1152 WixProjectFile="$(ProjectPath)"
1153 WixVariables="$(WixVariables)" />
1154 </Target>
1155
1156 <!--
1157 ================================================================================================
1158 UpdateLinkFileWrites
1159
1160 Reads the bind outputs file(s) output generated during Link to correctly set the @(FileWrites)
1161 item. Most targets have it easy because they can do a static mapping from inputs to the outputs.
1162 However, the Link target outputs are determined after a rather complex calculation we call
1163 linking and binding!
1164
1165 This target runs independently after Link to ensure that @(FileWrites) is updated even if the
1166 "Light" task fails.
1167
1168 [IN]
1169 Path to bind outputs file(s).
1170
1171 [OUT]
1172 @(FileWrites) updated with outputs from bind.
1173 ================================================================================================
1174 -->
1175 <Target
1176 Name="UpdateLinkFileWrites">
1177
1178 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)">
1179 <Output TaskParameter="Lines" ItemName="FileWrites"/>
1180 </ReadLinesFromFile>
1181
1182 <ItemGroup>
1183 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)" Condition=" Exists('$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindContentsFile)') " />
1184 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)" Condition=" Exists('$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)') " />
1185 <FileWrites Include="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)" Condition=" Exists('$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)') " />
1186 </ItemGroup>
1187
1188 <Message Importance="low" Text="Build files after link: @(FileWrites)" />
1189 </Target>
1190
1191 <!--
1192 //////////////////////////////////////////////////////////////////////////////////////////////////
1193 //////////////////////////////////////////////////////////////////////////////////////////////////
1194 AllProjectOutputGroups Section
1195 //////////////////////////////////////////////////////////////////////////////////////////////////
1196 //////////////////////////////////////////////////////////////////////////////////////////////////
1197 -->
1198
1199 <!--
1200 ==================================================================================================
1201 AllProjectOutputGroups - OVERRIDE Target
1202
1203 ==================================================================================================
1204 -->
1205 <Target
1206 Name="AllProjectOutputGroups"
1207 DependsOnTargets="
1208 BuiltProjectOutputGroup;
1209 DebugSymbolsProjectOutputGroup;
1210 SourceFilesProjectOutputGroup;
1211 ContentFilesProjectOutputGroup" />
1212
1213 <!--
1214 This is the key output for the BuiltProjectOutputGroup and is meant to be read directly from the IDE.
1215 Reading an item is faster than invoking a target.
1216 -->
1217 <ItemGroup>
1218 <BuiltProjectOutputGroupKeyOutput Include="$(TargetPath)">
1219 <IsKeyOutput>true</IsKeyOutput>
1220 <FinalOutputPath>$(TargetPath)</FinalOutputPath>
1221 <TargetPath>$(TargetFileName)</TargetPath>
1222 </BuiltProjectOutputGroupKeyOutput>
1223 </ItemGroup>
1224
1225 <!--
1226 ==================================================================================================
1227 BuiltProjectOutputGroup - OVERRIDE Target
1228 ==================================================================================================
1229 -->
1230 <PropertyGroup>
1231 <BuiltProjectOutputGroupDependsOn>PrepareForBuild;AssignCultures</BuiltProjectOutputGroupDependsOn>
1232 </PropertyGroup>
1233 <Target
1234 Name="BuiltProjectOutputGroup"
1235 Outputs="@(BuiltProjectOutputGroupOutput)"
1236 DependsOnTargets="$(BuiltProjectOutputGroupDependsOn)">
1237
1238 <!-- Don't add BuiltProjectOutputGroupKeyOutput - to avoid duplicates, we only want to get the updated list of TargetPaths from the TargetPath property below -->
1239
1240 <!-- Try to read the outputs from the bind outputs text file since that's the output list straight from linker. -->
1241 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)">
1242 <Output TaskParameter="Lines" ItemName="_BuiltProjectOutputGroupOutputIntermediate"/>
1243 </ReadLinesFromFile>
1244
1245 <!-- If we didn't get anything from the bind outputs text file, default to the target path. -->
1246 <ItemGroup Condition=" '@(_BuiltProjectOutputGroupOutputIntermediate)'=='' ">
1247 <_BuiltProjectOutputGroupOutputIntermediate Include="$(TargetPath)" />
1248 </ItemGroup>
1249
1250 <!-- Convert intermediate items into final items; this way we can get the full path for each item -->
1251 <ItemGroup>
1252 <BuiltProjectOutputGroupOutput Include="@(_BuiltProjectOutputGroupOutputIntermediate->'%(FullPath)')">
1253 <!-- For compatibility with 2.0 -->
1254 <OriginalItemSpec Condition="'%(_BuiltProjectOutputGroupOutputIntermediate.OriginalItemSpec)' == ''">%(_BuiltProjectOutputGroupOutputIntermediate.FullPath)</OriginalItemSpec>
1255 </BuiltProjectOutputGroupOutput>
1256 </ItemGroup>
1257 </Target>
1258
1259 <!--
1260 ==================================================================================================
1261 DebugSymbolsProjectOutputGroup
1262
1263 Populates the Debug Symbols project output group.
1264 ==================================================================================================
1265 -->
1266 <PropertyGroup>
1267 <DebugSymbolsProjectOutputGroupDependsOn>AssignCultures</DebugSymbolsProjectOutputGroupDependsOn>
1268 </PropertyGroup>
1269 <Target
1270 Name="DebugSymbolsProjectOutputGroup"
1271 Outputs="@(DebugSymbolsProjectOutputGroupOutput)"
1272 DependsOnTargets="$(DebugSymbolsProjectOutputGroupDependsOn)">
1273
1274 <!-- Include build output pdb(s). Different than predefined itemgroup since AssignCultures target may change -->
1275 <ItemGroup>
1276 <DebugSymbolsProjectOutputGroupOutput Include="$(TargetPdbPath)" Condition=" '$(SuppressPdbOutput)' != 'true' "/>
1277 </ItemGroup>
1278 </Target>
1279
1280
1281 <!--
1282 ==================================================================================================
1283 CopyFilesToOutputDirectory - OVERRIDE Target
1284
1285 Copy all build outputs, satellites and other necessary files to the final directory.
1286 ============================================================
1287 -->
1288 <Target
1289 Name="CopyFilesToOutputDirectory">
1290
1291 <PropertyGroup>
1292 <!-- By default we're using hard links to copy to the output directory, disabling this could slow the build significantly -->
1293 <CreateHardLinksForCopyFilesToOutputDirectoryIfPossible Condition=" '$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)' == '' ">true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>
1294 </PropertyGroup>
1295
1296 <PropertyGroup>
1297 <CopyBuildOutputToOutputDirectory Condition="'$(CopyBuildOutputToOutputDirectory)'==''">true</CopyBuildOutputToOutputDirectory>
1298 <CopyOutputSymbolsToOutputDirectory Condition="'$(CopyOutputSymbolsToOutputDirectory)'==''">true</CopyOutputSymbolsToOutputDirectory>
1299 <FullIntermediateOutputPath>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)))</FullIntermediateOutputPath>
1300 </PropertyGroup>
1301
1302 <!-- Copy the bound files. -->
1303 <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)">
1304 <Output TaskParameter="Lines" ItemName="_FullPathToCopy"/>
1305 </ReadLinesFromFile>
1306
1307 <ItemGroup>
1308 <_FullPathToCopy Include="$(OutputFile)" Condition=" '@(_FullPathToCopy)'=='' " />
1309 <_RelativePath Include="$([MSBuild]::MakeRelative($(FullIntermediateOutputPath), %(_FullPathToCopy.Identity)))" />
1310 </ItemGroup>
1311
1312 <Copy
1313 SourceFiles="@(_RelativePath->'$(IntermediateOutputPath)%(Identity)')"
1314 DestinationFiles="@(_RelativePath->'$(OutDir)%(Identity)')"
1315 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
1316 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
1317 Retries="$(CopyRetryCount)"
1318 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
1319 UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
1320 Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'"
1321 >
1322
1323 <Output TaskParameter="DestinationFiles" ItemName="MainAssembly"/>
1324 <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
1325
1326 </Copy>
1327
1328 <Message Importance="High" Text="$(MSBuildProjectName) -&gt; $(TargetPath)" Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />
1329 <!--<Message Importance="High" Text="$(MSBuildProjectName) -&gt; @(MainAssembly->'%(FullPath)')" Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" />-->
1330
1331 <!-- Copy the debug information file (.pdb), if any
1332 <Copy
1333 SourceFiles="@(_DebugSymbolsIntermediatePath)"
1334 DestinationFiles="@(_DebugSymbolsOutputPath)"
1335 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
1336 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
1337 Retries="$(CopyRetryCount)"
1338 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
1339 UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
1340 Condition="'$(_DebugSymbolsProduced)'=='true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true'">
1341
1342 <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
1343
1344 </Copy>
1345 -->
1346 </Target>
1347
1348
1349 <Import Project="$(WixHarvestTargetsPath)" Condition=" '$(WixHarvestTargetsPath)' != '' and Exists('$(WixHarvestTargetsPath)')" />
1350 <Import Project="$(WixSigningTargetsPath)" Condition=" '$(WixSigningTargetsPath)' != '' and Exists('$(WixSigningTargetsPath)')" />
1351 <Import Project="$(LuxTargetsPath)" Condition=" '$(LuxTargetsPath)' != '' and Exists('$(LuxTargetsPath)')" />
1352
1353 <!-- Extension point: Define CustomAfterWixTargets to a .targets file that you want to include after this file. -->
1354 <Import Project="$(CustomAfterWixTargets)" Condition=" '$(CustomAfterWixTargets)' != '' and Exists('$(CustomAfterWixTargets)')" />
1355
1356</Project>
diff --git a/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.csproj b/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.csproj
new file mode 100644
index 00000000..73f331ff
--- /dev/null
+++ b/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.csproj
@@ -0,0 +1,28 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netstandard2.0</TargetFramework>
7 <IncludeBuildOutput>false</IncludeBuildOutput>
8 <Description>Internal WiX Toolset Tools</Description>
9 <NuspecFile>$(MSBuildThisFileName).nuspec</NuspecFile>
10 <NuspecBasePath>$(OutputPath)publish</NuspecBasePath>
11 <NuspecProperties>Id=$(MSBuildThisFileName);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description)</NuspecProperties>
12 </PropertyGroup>
13
14 <ItemGroup>
15 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" />
16 </ItemGroup>
17
18 <PropertyGroup>
19 <GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);SetNuspecVersion</GenerateNuspecDependsOn>
20 </PropertyGroup>
21 <Target Name="SetNuspecVersion">
22 <Error Text="Cannot pack $(MSBuildThisFileName) until all projects are published to: '$(NuspecBasePath)'. Run appveyor.cmd to publish projects properly." Condition=" !Exists('$(NuspecBasePath)') " />
23
24 <PropertyGroup>
25 <NuspecProperties>$(NuspecProperties);Version=$(Version);ProjectFolder=$(MSBuildThisFileDirectory)</NuspecProperties>
26 </PropertyGroup>
27 </Target>
28</Project>
diff --git a/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.nuspec b/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.nuspec
new file mode 100644
index 00000000..a461557a
--- /dev/null
+++ b/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.nuspec
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3 <metadata>
4 <id>$id$</id>
5 <version>$version$</version>
6 <authors>$authors$</authors>
7 <owners>$authors$</owners>
8 <requireLicenseAcceptance>false</requireLicenseAcceptance>
9 <description>$description$</description>
10 <copyright>$copyright$</copyright>
11 </metadata>
12
13 <files>
14 <file src="$projectFolder$$id$.props" target="build" />
15
16 <file src="netcoreapp2.1\*" target="tools\netcoreapp2.1" />
17 <file src="net461\*" target="tools\net461" />
18 <file src="net461\redirects\*" target="msbuild" />
19 </files>
20</package>
diff --git a/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.props b/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.props
new file mode 100644
index 00000000..8d71aa66
--- /dev/null
+++ b/src/WixToolset.Core.InternalPackage/WixToolset.Core.InternalPackage.props
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
5 <PropertyGroup>
6 <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileDirectory)..\tools\net461\wix.targets</WixTargetsPath>
7 </PropertyGroup>
8</Project>
diff --git a/src/WixToolset.MSBuild/WixToolset.MSBuild.csproj b/src/WixToolset.MSBuild/WixToolset.MSBuild.csproj
new file mode 100644
index 00000000..76e42911
--- /dev/null
+++ b/src/WixToolset.MSBuild/WixToolset.MSBuild.csproj
@@ -0,0 +1,28 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netstandard2.0</TargetFramework>
7 <IncludeBuildOutput>false</IncludeBuildOutput>
8 <Description>WiX Toolset MSBuild integration</Description>
9 <NuspecFile>$(MSBuildThisFileName).nuspec</NuspecFile>
10 <NuspecBasePath>$(OutputPath)publish\WixToolset.MSBuild\</NuspecBasePath>
11 <NuspecProperties>Id=$(MSBuildThisFileName);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description)</NuspecProperties>
12 </PropertyGroup>
13
14 <ItemGroup>
15 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
16 </ItemGroup>
17
18 <PropertyGroup>
19 <GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);SetNuspecVersion</GenerateNuspecDependsOn>
20 </PropertyGroup>
21 <Target Name="SetNuspecVersion">
22 <Error Text="Cannot pack $(MSBuildThisFileName) until all projects are published to: '$(NuspecBasePath)'. Run appveyor.cmd to publish projects properly." Condition=" !Exists('$(NuspecBasePath)') " />
23
24 <PropertyGroup>
25 <NuspecProperties>$(NuspecProperties);Version=$(Version);ProjectFolder=$(MSBuildThisFileDirectory)</NuspecProperties>
26 </PropertyGroup>
27 </Target>
28</Project>
diff --git a/src/WixToolset.MSBuild/WixToolset.MSBuild.nuspec b/src/WixToolset.MSBuild/WixToolset.MSBuild.nuspec
new file mode 100644
index 00000000..1a21315a
--- /dev/null
+++ b/src/WixToolset.MSBuild/WixToolset.MSBuild.nuspec
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>
2<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3 <metadata>
4 <id>$id$</id>
5 <version>$version$</version>
6 <authors>$authors$</authors>
7 <owners>$authors$</owners>
8 <requireLicenseAcceptance>false</requireLicenseAcceptance>
9 <description>$description$</description>
10 <copyright>$copyright$</copyright>
11 </metadata>
12
13 <files>
14 <file src="$projectFolder$$id$.props" target="build" />
15 <file src="net461\*" target="tools\net461" />
16 <file src="net461\runtimes\win-x86\native\*.exe" target="tools\net461" />
17 <file src="netcoreapp2.1\*" target="tools\netcoreapp2.1" />
18 <file src="netcoreapp2.1\runtimes\**" target="tools\netcoreapp2.1\runtimes" />
19 <file src="netcoreapp2.1\runtimes\win-x86\native\*.exe" target="tools\netcoreapp2.1" />
20 </files>
21</package>
diff --git a/src/WixToolset.MSBuild/WixToolset.MSBuild.props b/src/WixToolset.MSBuild/WixToolset.MSBuild.props
new file mode 100644
index 00000000..b1d207f4
--- /dev/null
+++ b/src/WixToolset.MSBuild/WixToolset.MSBuild.props
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
5 <PropertyGroup>
6 <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\tools\netcoreapp2.1\wix.targets'))</WixTargetsPath>
7 <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\tools\net461\wix.targets'))</WixTargetsPath>
8 </PropertyGroup>
9</Project>
diff --git a/src/dotnet-wix/DotnetToolSettings.xml b/src/dotnet-wix/DotnetToolSettings.xml
new file mode 100644
index 00000000..a7a87fb2
--- /dev/null
+++ b/src/dotnet-wix/DotnetToolSettings.xml
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="utf-8"?>
2<DotNetCliTool Version="1">
3 <Commands>
4 <Command Name="wix" EntryPoint="wix.dll" Runner="dotnet" />
5 </Commands>
6</DotNetCliTool> \ No newline at end of file
diff --git a/src/dotnet-wix/dotnet-wix.csproj b/src/dotnet-wix/dotnet-wix.csproj
new file mode 100644
index 00000000..08fa9530
--- /dev/null
+++ b/src/dotnet-wix/dotnet-wix.csproj
@@ -0,0 +1,28 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netstandard2.0</TargetFramework>
7 <IncludeBuildOutput>false</IncludeBuildOutput>
8 <Description>WiX Toolset Command-line interface</Description>
9 <NuspecFile>$(MSBuildThisFileName).nuspec</NuspecFile>
10 <NuspecBasePath>$(OutputPath)publish\dotnet-wix\</NuspecBasePath>
11 <NuspecProperties>Id=$(MSBuildThisFileName);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description)</NuspecProperties>
12 </PropertyGroup>
13
14 <ItemGroup>
15 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
16 </ItemGroup>
17
18 <PropertyGroup>
19 <GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);SetNuspecVersion</GenerateNuspecDependsOn>
20 </PropertyGroup>
21 <Target Name="SetNuspecVersion">
22 <Error Text="Cannot pack $(MSBuildThisFileName) until all projects are published to: '$(NuspecBasePath)'. Run appveyor.cmd to publish projects properly." Condition=" !Exists('$(NuspecBasePath)') " />
23
24 <PropertyGroup>
25 <NuspecProperties>$(NuspecProperties);Version=$(Version);ProjectFolder=$(MSBuildThisFileDirectory)</NuspecProperties>
26 </PropertyGroup>
27 </Target>
28</Project>
diff --git a/src/dotnet-wix/dotnet-wix.nuspec b/src/dotnet-wix/dotnet-wix.nuspec
new file mode 100644
index 00000000..53a8dc9e
--- /dev/null
+++ b/src/dotnet-wix/dotnet-wix.nuspec
@@ -0,0 +1,24 @@
1<?xml version="1.0" encoding="utf-8"?>
2<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3 <metadata>
4 <id>$id$</id>
5 <version>$version$</version>
6 <authors>$authors$</authors>
7 <owners>$authors$</owners>
8 <requireLicenseAcceptance>false</requireLicenseAcceptance>
9 <description>$description$</description>
10 <copyright>$copyright$</copyright>
11 <packageTypes>
12 <packageType name="DotnetTool" />
13 </packageTypes>
14 <dependencies>
15 <group targetFramework=".NETCoreApp2.1" />
16 </dependencies>
17 </metadata>
18
19 <files>
20 <file src="$projectFolder$DotnetToolSettings.xml" target="tools\netcoreapp2.1\any" />
21 <file src="**" target="tools\netcoreapp2.1\any" />
22 <file src="runtimes\win-x86\native\*.exe" target="tools\netcoreapp2.1\any" />
23 </files>
24</package>
diff --git a/src/test/WixToolsetTest.BuildTasks/FakeBuildEngine.cs b/src/test/WixToolsetTest.BuildTasks/FakeBuildEngine.cs
new file mode 100644
index 00000000..8fd69414
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/FakeBuildEngine.cs
@@ -0,0 +1,33 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolsetTest.BuildTasks
4{
5 using System.Collections;
6 using System.Text;
7 using Microsoft.Build.Framework;
8
9 internal class FakeBuildEngine : IBuildEngine
10 {
11 private StringBuilder output = new StringBuilder();
12
13 public int ColumnNumberOfTaskNode => 0;
14
15 public bool ContinueOnError => false;
16
17 public int LineNumberOfTaskNode => 0;
18
19 public string ProjectFileOfTaskNode => "fake_wix.targets";
20
21 public string Output => this.output.ToString();
22
23 public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) => throw new System.NotImplementedException();
24
25 public void LogCustomEvent(CustomBuildEventArgs e) => this.output.AppendLine(e.Message);
26
27 public void LogErrorEvent(BuildErrorEventArgs e) => this.output.AppendLine(e.Message);
28
29 public void LogMessageEvent(BuildMessageEventArgs e) => this.output.AppendLine(e.Message);
30
31 public void LogWarningEvent(BuildWarningEventArgs e) => this.output.AppendLine(e.Message);
32 }
33}
diff --git a/src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs b/src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs
new file mode 100644
index 00000000..a27928d5
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs
@@ -0,0 +1,64 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolsetTest.BuildTasks
4{
5 using System.IO;
6 using System.Linq;
7 using Microsoft.Build.Utilities;
8 using WixBuildTools.TestSupport;
9 using WixToolset.BuildTasks;
10 using WixToolset.Data;
11 using WixToolset.Data.Tuples;
12 using Xunit;
13
14 public partial class MsbuildFixture
15 {
16 [Fact]
17 public void CanBuildSimpleMsiPackage()
18 {
19 var folder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
20
21 using (var fs = new DisposableFileSystem())
22 {
23 var baseFolder = fs.GetFolder();
24 var intermediateFolder = Path.Combine(baseFolder, "obj");
25
26 var engine = new FakeBuildEngine();
27
28 var task = new DoIt
29 {
30 BuildEngine = engine,
31 SourceFiles = new[]
32 {
33 new TaskItem(Path.Combine(folder, "Package.wxs")),
34 new TaskItem(Path.Combine(folder, "PackageComponents.wxs")),
35 },
36 LocalizationFiles = new[]
37 {
38 new TaskItem(Path.Combine(folder, "Package.en-us.wxl")),
39 },
40 BindInputPaths = new[]
41 {
42 new TaskItem(Path.Combine(folder, "data")),
43 },
44 IntermediateDirectory = new TaskItem(intermediateFolder),
45 OutputFile = new TaskItem(Path.Combine(baseFolder, @"bin\test.msi")),
46 };
47
48 var result = task.Execute();
49 Assert.True(result, $"MSBuild task failed unexpectedly. Output:\r\n{engine.Output}");
50
51 Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi")));
52 Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));
53 Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\cab1.cab")));
54
55 var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wir"));
56 var section = intermediate.Sections.Single();
57
58 var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
59 Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
60 Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
61 }
62 }
63 }
64}
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/MsiPackage.wixproj b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/MsiPackage.wixproj
new file mode 100644
index 00000000..e04ea43d
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/MsiPackage.wixproj
@@ -0,0 +1,57 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6 <ProductVersion>0.9</ProductVersion>
7 <ProjectGuid>7fb77005-c6e0-454f-8c2d-0a4a79c918ba</ProjectGuid>
8 <OutputName>MsiPackage</OutputName>
9 <OutputType>Package</OutputType>
10 <Name>MsiPackage</Name>
11 <RootNamespace>MsiPackage</RootNamespace>
12 <Cultures>en-US,en;de-DE</Cultures>
13 </PropertyGroup>
14
15 <PropertyGroup>
16 <WixTargetsPath>..\..\..\..\..\..\build\Release\publish\net461\wix.targets</WixTargetsPath>
17 </PropertyGroup>
18
19 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
20 <PlatformName>$(Platform)</PlatformName>
21 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
22 <DefineConstants>Debug</DefineConstants>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
25 <PlatformName>$(Platform)</PlatformName>
26 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
27 </PropertyGroup>
28 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
29 <PlatformName>$(Platform)</PlatformName>
30 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
31 <DefineConstants>Debug</DefineConstants>
32 </PropertyGroup>
33 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
34 <PlatformName>$(Platform)</PlatformName>
35 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
36 </PropertyGroup>
37
38 <ItemGroup>
39 <Compile Include="Package.wxs" />
40 <Compile Include="PackageComponents.wxs" />
41 </ItemGroup>
42
43 <ItemGroup>
44 <EmbeddedResource Include="Package.en-us.wxl" />
45 <EmbeddedResource Include="Package.de-de.wxl" />
46 </ItemGroup>
47
48 <ItemGroup>
49 <BindInputPaths Include="data" />
50 </ItemGroup>
51
52 <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
53 <Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets') " />
54 <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
55 <Error Text="WiX Toolset build tools (v3.11 or later) must be installed to build this project. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
56 </Target>
57</Project>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.de-de.wxl b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.de-de.wxl
new file mode 100644
index 00000000..23493ace
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.de-de.wxl
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This file contains the declaration of all the localizable strings.
5-->
6<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="de-DE">
7
8 <String Id="DowngradeError">German DowngradeError</String>
9 <String Id="FeatureTitle">German FeatureTitle</String>
10
11</WixLocalization>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.en-us.wxl b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.en-us.wxl
new file mode 100644
index 00000000..38c12ac1
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.en-us.wxl
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This file contains the declaration of all the localizable strings.
5-->
6<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7
8 <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 <String Id="FeatureTitle">MsiPackage</String>
10
11</WixLocalization>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.wxs b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.wxs
new file mode 100644
index 00000000..d5a5a40d
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/Package.wxs
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
4 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
5
6 <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
7 <MediaTemplate />
8
9 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
10 <ComponentGroupRef Id="ProductComponents" />
11 </Feature>
12 </Product>
13
14 <Fragment>
15 <Directory Id="TARGETDIR" Name="SourceDir">
16 <Directory Id="ProgramFilesFolder">
17 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
18 </Directory>
19 </Directory>
20 </Fragment>
21</Wix>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/PackageComponents.wxs b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/PackageComponents.wxs
new file mode 100644
index 00000000..e26c4509
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/PackageComponents.wxs
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Fragment>
4 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
5 <Component>
6 <File Source="test.txt" />
7 </Component>
8 </ComponentGroup>
9 </Fragment>
10</Wix>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/data/test.txt b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/data/test.txt
new file mode 100644
index 00000000..cd0db0e1
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MsiPackage/data/test.txt
@@ -0,0 +1 @@
This is test.txt. \ No newline at end of file
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MultiCulturalMsiPackage.sln b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MultiCulturalMsiPackage.sln
new file mode 100644
index 00000000..2c88704e
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/MultiCulturalMsiPackage/MultiCulturalMsiPackage.sln
@@ -0,0 +1,31 @@
1
2Microsoft Visual Studio Solution File, Format Version 12.00
3# Visual Studio 15
4VisualStudioVersion = 15.0.26730.8
5MinimumVisualStudioVersion = 10.0.40219.1
6Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MsiPackage", "MsiPackage\MsiPackage.wixproj", "{7FB77005-C6E0-454F-8C2D-0A4A79C918BA}"
7EndProject
8Global
9 GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 Debug|x64 = Debug|x64
11 Debug|x86 = Debug|x86
12 Release|x64 = Release|x64
13 Release|x86 = Release|x86
14 EndGlobalSection
15 GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x64.ActiveCfg = Debug|x64
17 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x64.Build.0 = Debug|x64
18 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x86.ActiveCfg = Debug|x86
19 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x86.Build.0 = Debug|x86
20 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x64.ActiveCfg = Release|x64
21 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x64.Build.0 = Release|x64
22 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x86.ActiveCfg = Release|x86
23 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x86.Build.0 = Release|x86
24 EndGlobalSection
25 GlobalSection(SolutionProperties) = preSolution
26 HideSolutionNode = FALSE
27 EndGlobalSection
28 GlobalSection(ExtensibilityGlobals) = postSolution
29 SolutionGuid = {585B0599-4EB5-4AB6-BC66-819CC78B63D5}
30 EndGlobalSection
31EndGlobal
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj
new file mode 100644
index 00000000..31c3ec9c
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj
@@ -0,0 +1,55 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6 <ProductVersion>0.9</ProductVersion>
7 <ProjectGuid>7fb77005-c6e0-454f-8c2d-0a4a79c918ba</ProjectGuid>
8 <OutputName>MsiPackage</OutputName>
9 <OutputType>Package</OutputType>
10 <Name>MsiPackage</Name>
11 <RootNamespace>MsiPackage</RootNamespace>
12 </PropertyGroup>
13
14 <PropertyGroup>
15 <WixTargetsPath>..\..\..\..\..\..\build\Release\publish\wix.targets</WixTargetsPath>
16 </PropertyGroup>
17
18 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
19 <PlatformName>$(Platform)</PlatformName>
20 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
21 <DefineConstants>Debug</DefineConstants>
22 </PropertyGroup>
23 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
24 <PlatformName>$(Platform)</PlatformName>
25 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
26 </PropertyGroup>
27 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
28 <PlatformName>$(Platform)</PlatformName>
29 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
30 <DefineConstants>Debug</DefineConstants>
31 </PropertyGroup>
32 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
33 <PlatformName>$(Platform)</PlatformName>
34 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
35 </PropertyGroup>
36
37 <ItemGroup>
38 <Compile Include="Package.wxs" />
39 <Compile Include="PackageComponents.wxs" />
40 </ItemGroup>
41
42 <ItemGroup>
43 <EmbeddedResource Include="Package.en-us.wxl" />
44 </ItemGroup>
45
46 <ItemGroup>
47 <BindInputPaths Include="data" />
48 </ItemGroup>
49
50 <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
51 <Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets') " />
52 <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
53 <Error Text="WiX Toolset build tools (v3.11 or later) must be installed to build this project. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
54 </Target>
55</Project> \ No newline at end of file
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.en-us.wxl b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.en-us.wxl
new file mode 100644
index 00000000..38c12ac1
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.en-us.wxl
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This file contains the declaration of all the localizable strings.
5-->
6<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7
8 <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 <String Id="FeatureTitle">MsiPackage</String>
10
11</WixLocalization>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.wxs b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.wxs
new file mode 100644
index 00000000..d5a5a40d
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/Package.wxs
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
4 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
5
6 <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
7 <MediaTemplate />
8
9 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
10 <ComponentGroupRef Id="ProductComponents" />
11 </Feature>
12 </Product>
13
14 <Fragment>
15 <Directory Id="TARGETDIR" Name="SourceDir">
16 <Directory Id="ProgramFilesFolder">
17 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
18 </Directory>
19 </Directory>
20 </Fragment>
21</Wix>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/PackageComponents.wxs b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/PackageComponents.wxs
new file mode 100644
index 00000000..e26c4509
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/PackageComponents.wxs
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Fragment>
4 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
5 <Component>
6 <File Source="test.txt" />
7 </Component>
8 </ComponentGroup>
9 </Fragment>
10</Wix>
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/data/test.txt b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/data/test.txt
new file mode 100644
index 00000000..cd0db0e1
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/data/test.txt
@@ -0,0 +1 @@
This is test.txt. \ No newline at end of file
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/SimpleMsiPackage.sln b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/SimpleMsiPackage.sln
new file mode 100644
index 00000000..2c88704e
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/SimpleMsiPackage.sln
@@ -0,0 +1,31 @@
1
2Microsoft Visual Studio Solution File, Format Version 12.00
3# Visual Studio 15
4VisualStudioVersion = 15.0.26730.8
5MinimumVisualStudioVersion = 10.0.40219.1
6Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MsiPackage", "MsiPackage\MsiPackage.wixproj", "{7FB77005-C6E0-454F-8C2D-0A4A79C918BA}"
7EndProject
8Global
9 GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 Debug|x64 = Debug|x64
11 Debug|x86 = Debug|x86
12 Release|x64 = Release|x64
13 Release|x86 = Release|x86
14 EndGlobalSection
15 GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x64.ActiveCfg = Debug|x64
17 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x64.Build.0 = Debug|x64
18 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x86.ActiveCfg = Debug|x86
19 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Debug|x86.Build.0 = Debug|x86
20 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x64.ActiveCfg = Release|x64
21 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x64.Build.0 = Release|x64
22 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x86.ActiveCfg = Release|x86
23 {7FB77005-C6E0-454F-8C2D-0A4A79C918BA}.Release|x86.Build.0 = Release|x86
24 EndGlobalSection
25 GlobalSection(SolutionProperties) = preSolution
26 HideSolutionNode = FALSE
27 EndGlobalSection
28 GlobalSection(ExtensibilityGlobals) = postSolution
29 SolutionGuid = {585B0599-4EB5-4AB6-BC66-819CC78B63D5}
30 EndGlobalSection
31EndGlobal
diff --git a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
new file mode 100644
index 00000000..5ec5b7fd
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
@@ -0,0 +1,32 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>net461</TargetFramework>
7 <IsPackable>false</IsPackable>
8 <DebugType>embedded</DebugType>
9 </PropertyGroup>
10
11 <ItemGroup>
12 <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
13 <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
14 <Content Include="TestData\SimpleMsiPackage\MsiPackage\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
15 <Content Include="TestData\SimpleMsiPackage\MsiPackage\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
16 </ItemGroup>
17
18 <ItemGroup>
19 <ProjectReference Include="..\..\WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" />
20 </ItemGroup>
21
22 <ItemGroup>
23 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" PrivateAssets="All" />
24 <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" />
25 </ItemGroup>
26
27 <ItemGroup>
28 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
29 <PackageReference Include="xunit" Version="2.3.1" />
30 <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
31 </ItemGroup>
32</Project>
diff --git a/src/wix/Program.cs b/src/wix/Program.cs
new file mode 100644
index 00000000..134900e9
--- /dev/null
+++ b/src/wix/Program.cs
@@ -0,0 +1,123 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Tools
4{
5 using System;
6 using System.Globalization;
7 using System.Text;
8 using System.Threading;
9 using WixToolset.Core;
10 using WixToolset.Data;
11 using WixToolset.Extensibility;
12 using WixToolset.Extensibility.Services;
13
14 /// <summary>
15 /// Wix Toolset Command-Line Interface.
16 /// </summary>
17 public sealed class Program
18 {
19 /// <summary>
20 /// The main entry point for wix command-line interface.
21 /// </summary>
22 /// <param name="args">Commandline arguments for the application.</param>
23 /// <returns>Returns the application error code.</returns>
24 [MTAThread]
25 public static int Main(string[] args)
26 {
27 var serviceProvider = new WixToolsetServiceProvider();
28
29 var listener = new ConsoleMessageListener("WIX", "wix.exe");
30
31 var program = new Program();
32 return program.Run(serviceProvider, listener, args);
33 }
34
35 /// <summary>
36 /// Executes the wix command-line interface.
37 /// </summary>
38 /// <param name="serviceProvider">Service provider to use throughout this execution.</param>
39 /// <param name="args">Command-line arguments to execute.</param>
40 /// <returns>Returns the application error code.</returns>
41 public int Run(IServiceProvider serviceProvider, IMessageListener listener, string[] args)
42 {
43 var messaging = serviceProvider.GetService<IMessaging>();
44 messaging.SetListener(listener);
45
46 var arguments = serviceProvider.GetService<ICommandLineArguments>();
47 arguments.Populate(args);
48
49 var context = serviceProvider.GetService<ICommandLineContext>();
50 context.Messaging = messaging;
51 context.ExtensionManager = CreateExtensionManagerWithStandardBackends(serviceProvider, arguments.Extensions);
52 context.Arguments = arguments;
53
54 var commandLine = serviceProvider.GetService<ICommandLine>();
55 var command = commandLine.ParseStandardCommandLine(context);
56 return command?.Execute() ?? 1;
57 }
58
59 private static IExtensionManager CreateExtensionManagerWithStandardBackends(IServiceProvider serviceProvider, string[] extensions)
60 {
61 var extensionManager = serviceProvider.GetService<IExtensionManager>();
62
63 foreach (var type in new[] { typeof(WixToolset.Core.Burn.WixToolsetStandardBackend), typeof(WixToolset.Core.WindowsInstaller.WixToolsetStandardBackend) })
64 {
65 extensionManager.Add(type.Assembly);
66 }
67
68 foreach (var extension in extensions)
69 {
70 extensionManager.Load(extension);
71 }
72
73 return extensionManager;
74 }
75
76 private class ConsoleMessageListener : IMessageListener
77 {
78 public ConsoleMessageListener(string shortName, string longName)
79 {
80 this.ShortAppName = shortName;
81 this.LongAppName = longName;
82
83 PrepareConsoleForLocalization();
84 }
85
86 public string LongAppName { get; }
87
88 public string ShortAppName { get; }
89
90 public void Write(Message message)
91 {
92 var filename = message.SourceLineNumbers?.FileName ?? this.LongAppName;
93 var line = message.SourceLineNumbers?.LineNumber ?? -1;
94 var type = message.Level.ToString().ToLowerInvariant();
95 var output = message.Level >= MessageLevel.Warning ? Console.Out : Console.Error;
96
97 if (line > 0)
98 {
99 filename = String.Concat(filename, "(", line, ")");
100 }
101
102 output.WriteLine("{0} : {1} {2}{3:0000}: {4}", filename, type, this.ShortAppName, message.Id, message.ToString());
103 }
104
105 public void Write(string message)
106 {
107 Console.Out.WriteLine(message);
108 }
109
110 private static void PrepareConsoleForLocalization()
111 {
112 Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture();
113
114 if (Console.OutputEncoding.CodePage != Encoding.UTF8.CodePage &&
115 Console.OutputEncoding.CodePage != Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage &&
116 Console.OutputEncoding.CodePage != Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage)
117 {
118 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
119 }
120 }
121 }
122 }
123}
diff --git a/src/wix/wix.csproj b/src/wix/wix.csproj
new file mode 100644
index 00000000..fbb8a0f5
--- /dev/null
+++ b/src/wix/wix.csproj
@@ -0,0 +1,34 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netcoreapp2.1</TargetFramework>
7 <OutputType>Exe</OutputType>
8 <Description>Compiler</Description>
9 <Title>WiX Toolset Compiler</Title>
10 <DebugType>embedded</DebugType>
11 <PublishRepositoryUrl>true</PublishRepositoryUrl>
12 <!-- <PackAsTool>true</PackAsTool> -->
13 </PropertyGroup>
14
15 <PropertyGroup>
16 <NoWarn>NU1701</NoWarn>
17 </PropertyGroup>
18
19 <ItemGroup>
20 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core\WixToolset.Core.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
21 <PackageReference Include="WixToolset.Core" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
22
23 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core.Burn\WixToolset.Core.Burn.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
24 <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
25
26 <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core.WindowsInstaller\WixToolset.Core.WindowsInstaller.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " />
27 <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " />
28 </ItemGroup>
29
30 <ItemGroup>
31 <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All"/>
32 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
33 </ItemGroup>
34</Project>
diff --git a/version.json b/version.json
new file mode 100644
index 00000000..eaeb2c79
--- /dev/null
+++ b/version.json
@@ -0,0 +1,11 @@
1{
2 "version": "4.0.0-build.{height}",
3 "publicReleaseRefSpec": [
4 "^refs/heads/master$"
5 ],
6 "cloudBuild": {
7 "buildNumber": {
8 "enabled": true
9 }
10 }
11}