@joebigelow / wix-1 / commits / f3494182

Fix Build and Clean targets

Rob Mensching committed Aug 11, 2018 at 01:12 UTC f34941825894d44059a560d9f95016ac97803504
9 files changed +289 -227
.editorconfig new
+28
@@ -0,0 +1,28 @@
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 +root = true
4 +
5 +[*]
6 +charset = utf-8
7 +indent_style = space
8 +indent_size = 4
9 +trim_trailing_whitespace = true
10 +
11 +[*.{cs,vb}]
12 +dotnet_sort_system_directives_first = true
13 +
14 +[*.cs]
15 +csharp_indent_case_contents = true : error
16 +csharp_indent_switch_labels = true : error
17 +csharp_new_line_before_open_brace = all
18 +csharp_prefer_braces = true : error
19 +csharp_style_var_elsewhere = true : suggestion
20 +csharp_style_var_for_built_in_types = true : suggestion
21 +csharp_style_var_when_type_is_apparent = true : suggestion
22 +dotnet_style_qualification_for_event = true : error
23 +dotnet_style_qualification_for_field = true : error
24 +dotnet_style_qualification_for_method = true : error
25 +dotnet_style_qualification_for_property = true : error
26 +
27 +[*.targets]
28 +indent_size = 2
Tools.sln
+5
@@ -13,6 +13,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-wix", "src\dotnet-wi
13 EndProject
14 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.MSBuild", "src\WixToolset.MSBuild\WixToolset.MSBuild.csproj", "{0DF5D4CF-8457-469D-8288-13775E984F70}"
15 EndProject
16 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{449BE9B0-422F-4039-A030-BDD3E7D97878}"
17 + ProjectSection(SolutionItems) = preProject
18 + .editorconfig = .editorconfig
19 + EndProjectSection
20 +EndProject
21 Global
22 GlobalSection(SolutionConfigurationPlatforms) = preSolution
23 Debug|Any CPU = Debug|Any CPU
src/WixToolset.BuildTasks/wix.signing.targets
+59 -67
@@ -1,18 +1,15 @@
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 -
4 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6 -
7 - <!-- These properties can be overridden to support non-default installations. -->
5 <PropertyGroup>
9 - <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileFullPath)</WixTargetsPath>
10 - <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixTasks.dll</WixTasksPath>
11 -
12 - <SignedFile Condition=" '$(SignedFile)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFile>
6 + <SignedFileName Condition=" '$(SignedFileName)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFileName>
7 + <SignedFilePath>$(IntermediateOutputPath)$(SignedFileName)</SignedFilePath>
8 </PropertyGroup>
9
10 <UsingTask TaskName="Insignia" AssemblyFile="$(WixTasksPath)" />
11 + <UsingTask TaskName="GetCabList" AssemblyFile="$(WixTasksPath)" />
12 + <UsingTask TaskName="GetLooseFileList" AssemblyFile="$(WixTasksPath)" />
13
14 <!-- Default Inscribe properties. -->
15 <PropertyGroup>
@@ -51,49 +48,57 @@
48 </InternalSignDependsOn>
49
50 <SigningDependsOn>
54 - CompileAndLink;
51 + WixBuild;
52 + CalculateSignTargetFiles;
53 BeforeSigning;
54 $(InternalSignDependsOn);
55 AfterSigning
56 </SigningDependsOn>
57 </PropertyGroup>
58 <Target
61 - Name="Signing"
62 - DependsOnTargets="$(SigningDependsOn)"
63 - Inputs="@(SignTargetPath)"
64 - Outputs="$(IntermediateOutputPath)$(SignedFile)"
65 - Condition=" '@(SignTargetPath)' != '' ">
59 + Name="Signing"
60 + DependsOnTargets="$(SigningDependsOn)"
61 + Inputs="$(TargetPath)"
62 + Outputs="$(SignedFilePath)"
63 + Condition=" '$(SignOutput)' == 'true' ">
64
67 - <CreateItem Include="$(IntermediateOutputPath)$(SignedFile)">
68 - <Output TaskParameter="Include" ItemName="FileWrites" />
69 - </CreateItem>
65 + <ItemGroup>
66 + <FileWrites Include="$(SignedFilePath)" />
67 + </ItemGroup>
68
69 <WriteLinesToFile
72 - File="$(IntermediateOutputPath)$(SignedFile)"
73 - Lines="^$(MSBuildProjectFullPath);@(SignMsm);@(SignCabs);@(SignMsi);@(SignContainers);@(SignBundleEngine);@(SignBundle)"
74 - Overwrite="true" />
70 + File="$(SignedFilePath)"
71 + Lines="^$(MSBuildProjectFullPath);@(SignMsm);@(SignCabs);@(SignMsi);@(SignContainers);@(SignBundleEngine);@(SignBundle)"
72 + Overwrite="true" />
73 </Target>
74
75 <!-- Internal targets so correct signing targets are called. -->
76 + <Target
77 + Name="CalculateSignTargetFiles">
78 + <ItemGroup>
79 + <SignTargetPath Include="$(TargetPath)" />
80 + </ItemGroup>
81 + </Target>
82 +
83 <Target
84 Name="GetMsmsToSign"
85 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 + Outputs="$(SignedFilePath)">
87 +
88 + <ItemGroup>
89 + <SignMsm Include="@(SignTargetPath)" />
90 + </ItemGroup>
91 </Target>
92
93 <Target
89 - Name="InternalSignMsm"
90 - DependsOnTargets="SignMsm"
91 - Condition=" '@(SignMsm)' != '' " />
94 + Name="InternalSignMsm"
95 + DependsOnTargets="SignMsm"
96 + Condition=" '@(SignMsm)' != '' " />
97
98 <Target
99 Name="GetCabsToSign"
100 Inputs="@(SignTargetPath)"
96 - Outputs="$(IntermediateOutputPath)$(SignedFile)">
101 + Outputs="$(SignedFilePath)">
102 <GetCabList Database="%(SignTargetPath.FullPath)">
103 <Output TaskParameter="CabList" ItemName="SignCabs" />
104 <Output TaskParameter="CabList" ItemName="FileWrites" />
@@ -101,14 +106,14 @@
106 </Target>
107
108 <Target
104 - Name="InternalSignCabs"
105 - DependsOnTargets="SignCabs"
106 - Condition=" '@(SignCabs)' != '' " />
109 + Name="InternalSignCabs"
110 + DependsOnTargets="SignCabs"
111 + Condition=" '@(SignCabs)' != '' " />
112
113 <Target
114 Name="GetMsiToSign"
115 Inputs="@(SignTargetPath)"
111 - Outputs="$(IntermediateOutputPath)$(SignedFile)">
116 + Outputs="$(SignedFilePath)">
117 <CreateItemAvoidingInference InputProperties="@(SignTargetPath)">
118 <Output TaskParameter="OuputItems" ItemName="SignMsi" />
119 <Output TaskParameter="OuputItems" ItemName="FileWrites" />
@@ -116,33 +121,33 @@
121 </Target>
122
123 <Target
119 - Name="InternalSignMsi"
120 - DependsOnTargets="SignMsi"
121 - Inputs="@(SignTargetPath)"
122 - Outputs="$(IntermediateOutputPath)$(SignedFile)"
123 - Condition=" '@(SignMsi)' != '' " />
124 + Name="InternalSignMsi"
125 + DependsOnTargets="SignMsi"
126 + Inputs="@(SignTargetPath)"
127 + Outputs="$(SignedFilePath)"
128 + Condition=" '@(SignMsi)' != '' " />
129
130 <Target
131 Name="GetContainersToSign"
132 Inputs="@(SignTargetPath)"
128 - Outputs="$(IntermediateOutputPath)$(SignedFile)">
133 + Outputs="$(SignedFilePath)">
134 <!-- TODO: implement signing detached containers -->
135 </Target>
136
137 <Target
133 - Name="InternalSignContainers"
134 - DependsOnTargets="SignContainers"
135 - Condition=" '@(SignContainers)' != '' " />
138 + Name="InternalSignContainers"
139 + DependsOnTargets="SignContainers"
140 + Condition=" '@(SignContainers)' != '' " />
141
142 <Target
138 - Name="InternalSignBundleEngine"
139 - DependsOnTargets="SignBundleEngine"
140 - Condition=" '@(SignBundleEngine)' != '' " />
143 + Name="InternalSignBundleEngine"
144 + DependsOnTargets="SignBundleEngine"
145 + Condition=" '@(SignBundleEngine)' != '' " />
146
147 <Target
143 - Name="InternalSignBundle"
144 - DependsOnTargets="SignBundle"
145 - Condition=" '@(SignBundle)' != '' " />
148 + Name="InternalSignBundle"
149 + DependsOnTargets="SignBundle"
150 + Condition=" '@(SignBundle)' != '' " />
151
152 <!--
153 ================================================================================================
@@ -160,17 +165,13 @@
165 -->
166 <PropertyGroup>
167 <InscribeMsiDependsOn>
163 - PrepareForBuild;
164 - ResolveWixExtensionReferences;
165 - CompileAndLink;
166 - InternalSignCabs
168 </InscribeMsiDependsOn>
169 </PropertyGroup>
170 <Target
171 Name="InscribeMsi"
172 DependsOnTargets="$(InscribeMsiDependsOn)"
173 Inputs="@(SignTargetPath)"
173 - Outputs="$(IntermediateOutputPath)$(SignedFile)"
174 + Outputs="$(SignedFilePath)"
175 Condition=" '@(SignCabs)' != '' ">
176
177 <Insignia
@@ -203,17 +204,13 @@
204 -->
205 <PropertyGroup>
206 <InscribeBundleEngineDependsOn>
206 - PrepareForBuild;
207 - ResolveWixExtensionReferences;
208 - CompileAndLink;
209 - InternalSignContainers
207 </InscribeBundleEngineDependsOn>
208 </PropertyGroup>
209 <Target
210 Name="InscribeBundleEngine"
211 DependsOnTargets="$(InscribeBundleEngineDependsOn)"
212 Inputs="@(SignTargetPath)"
216 - Outputs="$(IntermediateOutputPath)$(SignedFile)">
213 + Outputs="$(SignedFilePath)">
214
215 <Insignia
216 BundleFile="@(SignTargetPath)"
@@ -230,11 +227,10 @@
227 <Output TaskParameter="Output" ItemName="SignBundleEngine" />
228 </Insignia>
229
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 -
230 + <!-- Explicitly add output to FileWrites to ensure they are included even when the target is up to date. -->
231 + <ItemGroup>
232 + <FileWrites Include="$(IntermediateOutputPath)%(SignTargetPath.Filename)%(SignTargetPath.Extension)" />
233 + </ItemGroup>
234 </Target>
235
236 <!--
@@ -252,17 +248,13 @@
248 -->
249 <PropertyGroup>
250 <InscribeBundleDependsOn>
255 - PrepareForBuild;
256 - ResolveWixExtensionReferences;
257 - CompileAndLink;
258 - InternalSignBundleEngine
251 </InscribeBundleDependsOn>
252 </PropertyGroup>
253 <Target
254 Name="InscribeBundle"
255 DependsOnTargets="$(InscribeBundleDependsOn)"
256 Inputs="@(SignTargetPath)"
265 - Outputs="$(IntermediateOutputPath)$(SignedFile)">
257 + Outputs="$(SignedFilePath)">
258
259 <Insignia
260 BundleFile="@(SignBundleEngine)"
src/WixToolset.BuildTasks/wix.targets
+48 -78
@@ -48,14 +48,13 @@
48 <PropertyGroup>
49 <DefaultLanguageSourceExtension>.wxs</DefaultLanguageSourceExtension>
50 <Language>wix</Language>
51 - <TargetRuntime>Managed</TargetRuntime>
51 + <TargetRuntime>wix</TargetRuntime>
52
53 <!-- Use OutputName to set the AssemblyName for Microsoft.Common.targets -->
54 <OutputName Condition=" '$(OutputName)'=='' ">$(MSBuildProjectName)</OutputName>
55 <AssemblyName>$(OutputName)</AssemblyName>
56
57 - <!-- Default the OutputType to a known WiX toolset TYPE. -->
58 - <_OriginalOutputType>$(OutputType)</_OriginalOutputType>
57 + <!-- Default the OutputType to a known WiX Toolset type. -->
58 <OutputType Condition=" '$(OutputType)' == '' ">Package</OutputType>
59 </PropertyGroup>
60
@@ -70,28 +69,24 @@
69 <TargetExt Condition=" '$(OutputType)' == 'PatchCreation' ">.pcp</TargetExt>
70 <TargetExt Condition=" '$(OutputType)' == 'Library' ">.wixlib</TargetExt>
71 <TargetExt Condition=" '$(OutputType)' == 'Bundle' ">.exe</TargetExt>
72 + <TargetExt Condition=" '$(OutputType)' == 'IntermediatePostLink' ">.wixipl</TargetExt>
73 </PropertyGroup>
74
75 - <!-- Provide the correct output name for the .wixpdb -->
76 - <ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true'">
77 - <_DebugSymbolsIntermediatePath Include="$(PdbOutputDir)$(TargetPdbName)" Condition=" '@(_DebugSymbolsIntermediatePath)' == '' " />
78 - </ItemGroup>
79 -
75 <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
76
77 <PropertyGroup>
78 <!-- Default pdb output path to the intermediate output directory -->
84 - <PdbOutputDir Condition=" '$(PdbOutputDir)'=='' ">$(IntermediateOutputPath)</PdbOutputDir>
85 - <PdbOutputDir Condition=" '$(PdbOutputDir)' != '' and !HasTrailingSlash('$(PdbOutputDir)') ">$(PdbOutputDir)\</PdbOutputDir>
79 + <PdbOutputDir Condition=" '$(PdbOutputDir)'=='' ">$(TargetDir)</PdbOutputDir>
80 + <PdbOutputDir Condition=" !HasTrailingSlash('$(PdbOutputDir)') ">$(PdbOutputDir)\</PdbOutputDir>
81
82 <!-- Example, C:\MyProjects\MyProject\bin\debug\ -->
83 <TargetPdbDir Condition=" '$(PdbOutputDir)'!='' ">$([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `$(PdbOutputDir)`))`))</TargetPdbDir>
84
85 <!-- Example, MySetup.wixpdb" -->
91 - <TargetPdbName Condition=" '$(TargetPdbName)' == '' ">$(TargetName).wixpdb</TargetPdbName>
86 + <TargetPdbFileName Condition=" '$(TargetPdbFileName)' == '' ">$(TargetName).wixpdb</TargetPdbFileName>
87
88 <!-- Example, C:\MyProjects\MyProject\bin\debug\MyPackage.wixpdb -->
94 - <TargetPdbPath Condition=" '$(TargetPdbPath)' == '' ">$(TargetPdbDir)$(TargetPdbName)</TargetPdbPath>
89 + <TargetPdbPath Condition=" '$(TargetPdbPath)' == '' ">$(TargetPdbDir)$(TargetPdbFileName)</TargetPdbPath>
90 </PropertyGroup>
91
92 <!--
@@ -111,8 +106,6 @@
106 <UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" />
107 <UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)"/>
108 <UsingTask TaskName="ReplaceString" AssemblyFile="$(WixTasksPath)"/>
114 - <UsingTask TaskName="GetCabList" AssemblyFile="$(WixTasksPath)" />
115 - <UsingTask TaskName="GetLooseFileList" AssemblyFile="$(WixTasksPath)" />
109 <UsingTask TaskName="GenerateCompileWithObjectPath" AssemblyFile="$(WixTasksPath)"/>
110
111 <PropertyGroup>
@@ -130,14 +123,6 @@
123 <WixExtDir Condition=" '$(WixExtDir)' == ''">$(WixToolDir)</WixExtDir>
124 </PropertyGroup>
125
133 - <!--
134 - Set the SignTargetPath item directly when output is a Bundle. The AssignCultures target
135 - sets SignTargetPath item for other output types based on the cultures provided.
136 - -->
137 - <ItemGroup>
138 - <SignTargetPath Include="$(TargetPath)" Condition=" '$(OutputType)' == 'Bundle' AND '$(SignOutput)' == 'true' AND '$(SuppressLayout)' != 'true' " />
139 - </ItemGroup>
140 -
126 <!--
127 //////////////////////////////////////////////////////////////////////////////////////////////////
128 //////////////////////////////////////////////////////////////////////////////////////////////////
@@ -219,32 +204,27 @@
204
205 [IN]
206 $(OutputName) - The name of the MSI/MSM/wixlib to build (without the extension)
222 - $(OutputType) - Possible values are 'package', 'PatchCreation', 'module', 'library', 'bundle'
207 + $(OutputType) - Possible values are 'Package', 'PatchCreation', 'Module', 'Library', 'Bundle', 'IntermediatePostLink'
208 ==================================================================================================
209 -->
210 <PropertyGroup>
211 <_PleaseSetThisInProjectFile>Please set this in the project file before the &lt;Import&gt; of the wix.targets file.</_PleaseSetThisInProjectFile>
227 - <_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>
212 + <_OutputTypeDescription>Possible values are: 'Package', 'Module', 'Library', 'Bundle', 'IntermediatePostLink'. $(_PleaseSetThisInProjectFile)</_OutputTypeDescription>
213 </PropertyGroup>
214 <Target Name="_CheckRequiredProperties">
215
216 <Error
232 - Code="WIXTARGETS100"
217 + Code="WIX100"
218 Condition=" '$(OutputName)' == '' "
219 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)" />
220
236 - <Warning
237 - Code="WIXTARGETS101"
238 - Condition=" '$(_OriginalOutputType)' == '' "
239 - Text="The OutputType property is not set in project &quot;$(MSBuildProjectFile)&quot;. Defaulting to '$(OutputType)'. $(_OutputTypeDescription)" />
240 -
221 <Error
242 - Code="WIXTARGETS102"
243 - Condition=" '$(OutputType)' != 'Package' and '$(OutputType)' != 'PatchCreation' and '$(OutputType)' != 'Module' and '$(OutputType)' != 'Library' and '$(OutputType)' != 'Bundle' "
222 + Code="WIX101"
223 + Condition=" '$(OutputType)' != 'Package' and '$(OutputType)' != 'PatchCreation' and '$(OutputType)' != 'Module' and '$(OutputType)' != 'Library' and '$(OutputType)' != 'Bundle' and '$(OutputType)' != 'IntermediatePostLink' "
224 Text="The OutputType property '$(OutputType)' is not valid in project &quot;$(MSBuildProjectFile)&quot;. $(_OutputTypeDescription)" />
225
226 <Error
247 - Code="WIXTARGETS103"
227 + Code="WIX102"
228 Condition=" '$(MSBuildToolsVersion)' == '' OR '$(MSBuildToolsVersion)' &lt; '4.0' "
229 Text="MSBuild v$(MSBuildToolsVersion) is not supported by the project &quot;$(MSBuildProjectFile)&quot;. You must use MSBuild v4.0 or later." />
230
@@ -272,7 +252,6 @@
252 BuildOnlySettings;
253 PrepareForBuild;
254 PreBuildEvent;
275 - ResolveReferences;
255
256 WixBuild;
257 Signing;
@@ -580,7 +559,7 @@
559 ================================================================================================
560 -->
561 <PropertyGroup>
583 - <GetTargetPathDependsOn>AssignCultures</GetTargetPathDependsOn>
562 + <GetTargetPathDependsOn>AssignTargetPaths</GetTargetPathDependsOn>
563 </PropertyGroup>
564
565
@@ -600,22 +579,22 @@
579 <PropertyGroup>
580 <WixBuildDependsOn>
581 ResolveReferences;
603 - BeforeWixBuild;
604 - _TimeStampBeforeWixBuild;
582 + BeforeCompile;
583 + _TimeStampBeforeCompile;
584
585 CalculateDefineConstants;
586 Harvest;
587
588 GenerateCompileWithObjectPath;
589
611 - AssignCultures;
590 + AssignTargetPaths;
591 ReadPreviousBindInputsAndBuiltOutputs;
592
593 CoreWixBuild;
594
595 UpdateLinkFileWrites;
617 - _TimeStampAfterWixBuild;
618 - AfterWixBuild
596 + _TimeStampAfterCompile;
597 + AfterCompile
598 </WixBuildDependsOn>
599 </PropertyGroup>
600 <Target
@@ -623,23 +602,24 @@
602 DependsOnTargets="$(WixBuildDependsOn)" />
603
604 <Target
626 - Name="CoreWixBuild"
627 -
628 - Inputs="@(Compile);
629 - @(Content);
630 - @(EmbeddedResource);
631 - @(WixObject);
632 - @(_ResolvedProjectReferencePaths);
633 - @(_ResolvedWixLibraryPaths);
634 - @(_ResolvedWixExtensionPaths);
635 - @(_BindInputs);
636 - $(MSBuildAllProjects)"
637 - Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)"
638 - Condition=" '@(Compile)' != '' ">
605 + Name="CoreWixBuild"
606 + Inputs="@(Compile);
607 + @(Content);
608 + @(EmbeddedResource);
609 + @(WixObject);
610 + @(_ResolvedProjectReferencePaths);
611 + @(_ResolvedWixLibraryPaths);
612 + @(_ResolvedWixExtensionPaths);
613 + @(_BindInputs);
614 + $(MSBuildAllProjects)"
615 + Outputs="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile);@(_BindBuiltOutputs)"
616 + Condition=" '@(Compile)' != '' ">
617
618 <PropertyGroup>
641 - <OutputFile>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)))</OutputFile>
642 - <PdbOutputFile>$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)</PdbOutputFile>
619 + <!--<OutputFile>$([System.IO.Path]::GetFullPath($(TargetDir)%(CultureGroup.OutputFolder)$(TargetFileName)))</OutputFile>-->
620 + <OutputFile>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetFileName)))</OutputFile>
621 + <!--<OutputFile>$([System.IO.Path]::GetFullPath($(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)))</OutputFile>-->
622 + <PdbOutputFile>$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetPdbFileName)</PdbOutputFile>
623 </PropertyGroup>
624
625 <DoIt
@@ -780,7 +760,7 @@
760
761 <!--
762 ================================================================================================
783 - AssignCultures
763 + AssignTargetPaths - OVERRIDE Target
764
765 Determines the final list of culture groups to build based on either the Cultures property or
766 those specified in .wxl files.
@@ -811,37 +791,27 @@
791 @(CultureGroup) - The list of culture group strings with OutputFolder metadata
792 $(TargetPath) - Property list of target link output MSIs/MSMs
793 $(TargetPdbPath) - Property list of target output pdbs
814 - @(SignTargetPath) - The list of target to be signed
794
795 ================================================================================================
796 -->
797 <Target
819 - Name="AssignCultures"
798 + Name="AssignTargetPaths"
799 Condition=" '$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' ">
800
822 - <WixAssignCulture
823 - Cultures="$(Cultures)"
824 - Files="@(EmbeddedResource)">
825 -
801 + <WixAssignCulture Cultures="$(Cultures)" Files="@(EmbeddedResource)">
802 <Output TaskParameter="CultureGroups" ItemName="CultureGroup" />
803 </WixAssignCulture>
804
829 - <!-- Build an itemgroup of outputs -->
805 + <!-- Expand the culture groups then put them back into the appropriate property -->
806 <ItemGroup>
831 - <_TargetPathItems Include="$(TargetDir)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" />
832 - <_TargetPdbPathItems Include="$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbName)" />
807 + <_CulturedTargetPath Include="$(TargetDir)%(CultureGroup.OutputFolder)$(TargetFileName)" />
808 + <_CulturedTargetPdbPath Include="$(TargetPdbDir)%(CultureGroup.OutputFolder)$(TargetPdbFileName)" />
809 </ItemGroup>
810
835 - <!-- Convert the itemgroup to a semicolon-delimited property -->
811 <PropertyGroup>
837 - <TargetPath>@(_TargetPathItems)</TargetPath>
838 - <TargetPdbPath>@(_TargetPdbPathItems)</TargetPdbPath>
812 + <TargetPath>@(_CulturedTargetPath)</TargetPath>
813 + <TargetPdbPath>@(_CulturedTargetPdbPath)</TargetPdbPath>
814 </PropertyGroup>
840 -
841 - <!-- Set the sign target items, if we're signing output. -->
842 - <ItemGroup Condition=" '$(SignOutput)' == 'true' AND '$(SuppressLayout)' != 'true' ">
843 - <SignTargetPath Include="@(_TargetPathItems)" />
844 - </ItemGroup>
815 </Target>
816
817 <!--
@@ -957,7 +927,7 @@
927 ==================================================================================================
928 -->
929 <PropertyGroup>
960 - <BuiltProjectOutputGroupDependsOn>PrepareForBuild;AssignCultures</BuiltProjectOutputGroupDependsOn>
930 + <BuiltProjectOutputGroupDependsOn>PrepareForBuild;AssignTargetPaths</BuiltProjectOutputGroupDependsOn>
931 </PropertyGroup>
932 <Target
933 Name="BuiltProjectOutputGroup"
@@ -967,7 +937,7 @@
937 <!-- Don't add BuiltProjectOutputGroupKeyOutput - to avoid duplicates, we only want to get the updated list of TargetPaths from the TargetPath property below -->
938
939 <!-- Try to read the outputs from the bind outputs text file since that's the output list straight from linker. -->
970 - <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)">
940 + <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)">
941 <Output TaskParameter="Lines" ItemName="_BuiltProjectOutputGroupOutputIntermediate"/>
942 </ReadLinesFromFile>
943
@@ -993,14 +963,14 @@
963 ==================================================================================================
964 -->
965 <PropertyGroup>
996 - <DebugSymbolsProjectOutputGroupDependsOn>AssignCultures</DebugSymbolsProjectOutputGroupDependsOn>
966 + <DebugSymbolsProjectOutputGroupDependsOn>AssignTargetPaths</DebugSymbolsProjectOutputGroupDependsOn>
967 </PropertyGroup>
968 <Target
969 Name="DebugSymbolsProjectOutputGroup"
970 Outputs="@(DebugSymbolsProjectOutputGroupOutput)"
971 DependsOnTargets="$(DebugSymbolsProjectOutputGroupDependsOn)">
972
1003 - <!-- Include build output pdb(s). Different than predefined itemgroup since AssignCultures target may change -->
973 + <!-- Include build output pdb(s). Different than predefined itemgroup since AssignTargetPaths target may change -->
974 <ItemGroup>
975 <DebugSymbolsProjectOutputGroupOutput Include="$(TargetPdbPath)" Condition=" '$(SuppressPdbOutput)' != 'true' "/>
976 </ItemGroup>
@@ -1029,7 +999,7 @@
999 </PropertyGroup>
1000
1001 <!-- Copy the bound files. -->
1032 - <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindOutputsFile)">
1002 + <ReadLinesFromFile File="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(BindBuiltOutputsFile)">
1003 <Output TaskParameter="Lines" ItemName="_FullPathToCopy"/>
1004 </ReadLinesFromFile>
1005
src/test/WixToolsetTest.BuildTasks/FakeBuildEngine.cs deleted
-33
@@ -1,33 +0,0 @@
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 -namespace 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 -}
src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs
+80 -39
@@ -2,62 +2,103 @@
2
3 namespace WixToolsetTest.BuildTasks
4 {
5 + using System;
6 using System.IO;
7 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;
10 using Xunit;
11
14 - public partial class MsbuildFixture
12 + public class MsbuildFixture
13 {
14 + private static readonly string WixTargetsPath = Path.Combine(Path.GetDirectoryName(new Uri(typeof(DoIt).Assembly.CodeBase).AbsolutePath), "wix.targets");
15 +
16 + public MsbuildFixture()
17 + {
18 + this.MsbuildRunner = new MsbuildRunner();
19 + }
20 +
21 + private MsbuildRunner MsbuildRunner { get; }
22 +
23 [Fact]
24 public void CanBuildSimpleMsiPackage()
25 {
19 - var folder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
26 + var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj");
27
28 using (var fs = new DisposableFileSystem())
29 {
30 var baseFolder = fs.GetFolder();
24 - var intermediateFolder = Path.Combine(baseFolder, "obj");
31 + var binFolder = Path.Combine(baseFolder, @"bin\");
32 + var intermediateFolder = Path.Combine(baseFolder, @"obj\");
33
26 - var engine = new FakeBuildEngine();
34 + var result = this.MsbuildRunner.Execute(projectPath, new[]
35 + {
36 + $"-p:WixTargetsPath={WixTargetsPath}",
37 + $"-p:IntermediateOutputPath={intermediateFolder}",
38 + $"-p:OutputPath={binFolder}"
39 + });
40 + result.AssertSuccess();
41
28 - var task = new DoIt
42 + var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
43 + .Select(s => s.Substring(baseFolder.Length + 1))
44 + .OrderBy(s => s)
45 + .ToArray();
46 + Assert.Equal(new[]
47 {
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);
48 + @"bin\en-US\cab1.cab",
49 + @"bin\en-US\MsiPackage.msi",
50 + @"bin\en-US\MsiPackage.wixpdb",
51 + }, paths);
52 + }
53 + }
54 +
55 + [Fact]
56 + public void CanBuildAndCleanSimpleMsiPackage()
57 + {
58 + var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj");
59 +
60 + using (var fs = new DisposableFileSystem())
61 + {
62 + var baseFolder = fs.GetFolder();
63 + var binFolder = Path.Combine(baseFolder, @"bin\");
64 + var intermediateFolder = Path.Combine(baseFolder, @"obj\");
65 +
66 + // Build
67 + var result = this.MsbuildRunner.Execute(projectPath, new[]
68 + {
69 + $"-p:WixTargetsPath={WixTargetsPath}",
70 + $"-p:IntermediateOutputPath={intermediateFolder}",
71 + $"-p:OutputPath={binFolder}",
72 + "-v:diag"
73 + });
74 + result.AssertSuccess();
75 +
76 + var buildOutput = String.Join("\r\n", result.Output);
77 +
78 + var createdPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories)
79 + .Select(s => s.Substring(baseFolder.Length + 1))
80 + .OrderBy(s => s)
81 + .ToArray();
82 + Assert.NotEmpty(createdPaths);
83 +
84 + // Clean
85 + result = this.MsbuildRunner.Execute(projectPath, new[]
86 + {
87 + $"-p:WixTargetsPath={WixTargetsPath}",
88 + $"-p:IntermediateOutputPath={intermediateFolder}",
89 + $"-p:OutputPath={binFolder}",
90 + "-t:Clean",
91 + "-v:diag"
92 + });
93 + result.AssertSuccess();
94 +
95 + var cleanOutput = String.Join("\r\n", result.Output);
96 +
97 + var remainingPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories)
98 + .Select(s => s.Substring(baseFolder.Length + 1))
99 + .OrderBy(s => s)
100 + .ToArray();
101 + Assert.Empty(remainingPaths);
102 }
103 }
104 }
src/test/WixToolsetTest.BuildTasks/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj
+4 -10
@@ -1,18 +1,12 @@
1 -<?xml version="1.0" encoding="utf-8"?>
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>
6 </PropertyGroup>
7
8 <PropertyGroup>
15 - <WixTargetsPath>..\..\..\..\..\..\build\Release\publish\wix.targets</WixTargetsPath>
9 + <ProjectGuid>7fb77005-c6e0-454f-8c2d-0a4a79c918ba</ProjectGuid>
10 </PropertyGroup>
11
12 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@@ -48,8 +42,8 @@
42 </ItemGroup>
43
44 <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') " />
45 + <Import Project="$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets') " />
46 <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/." />
47 + <Error Text="WiX Toolset build tools (v4.0 or later) must be installed to build this project. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
48 </Target>
49 </Project>
\ No newline at end of file
src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs new
+64
@@ -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 +
3 +namespace 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 class WixBuildTaskFixture
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(intermediateFolder, @"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 +}
src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
+1
@@ -9,6 +9,7 @@
9 </PropertyGroup>
10
11 <ItemGroup>
12 + <Content Include="TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" />
13 <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
14 <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
15 <Content Include="TestData\SimpleMsiPackage\MsiPackage\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />