main
targets 300 lines 11.9 KB
Raw
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">
5 <PropertyGroup>
6 <WixSigningTargetsImported>true</WixSigningTargetsImported>
7 <SignedFileName Condition=" '$(SignedFileName)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFileName>
8 <SignedFilePath>$(IntermediateOutputPath)$(SignedFileName)</SignedFilePath>
9 </PropertyGroup>
10
11 <Import Project="WixToolset.Signing.props" Condition=" '$(WixSigningPropsImported)' != 'true' " />
12
13 <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
14 <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
15 <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
16
17 <UsingTask TaskName="GetLooseFileList" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
18 <UsingTask TaskName="GetLooseFileList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
19 <UsingTask TaskName="GetLooseFileList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
20
21 <UsingTask TaskName="InscribeMsiWithCabinetSignatures" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
22 <UsingTask TaskName="InscribeMsiWithCabinetSignatures" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
23 <UsingTask TaskName="InscribeMsiWithCabinetSignatures" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
24
25 <UsingTask TaskName="DetachBundleEngineForSigning" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
26 <UsingTask TaskName="DetachBundleEngineForSigning" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
27 <UsingTask TaskName="DetachBundleEngineForSigning" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
28
29 <UsingTask TaskName="ReattachSignedBundleEngine" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
30 <UsingTask TaskName="ReattachSignedBundleEngine" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
31 <UsingTask TaskName="ReattachSignedBundleEngine" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
32
33 <!-- Default Inscribe properties. -->
34 <PropertyGroup>
35 <InscribeNoLogo Condition=" '$(InscribeNoLogo)' == '' ">$(NoLogo)</InscribeNoLogo>
36 <InscribeSuppressAllWarnings Condition=" '$(InscribeSuppressAllWarnings)' == '' ">$(SuppressAllWarnings)</InscribeSuppressAllWarnings>
37 <InscribeSuppressSpecificWarnings Condition=" '$(InscribeSuppressSpecificWarnings)' == '' ">$(SuppressSpecificWarnings)</InscribeSuppressSpecificWarnings>
38 <InscribeTreatWarningsAsErrors Condition=" '$(InscribeTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</InscribeTreatWarningsAsErrors>
39 <InscribeTreatSpecificWarningsAsErrors Condition=" '$(InscribeTreatSpecificWarningsAsErrors)' == '' ">$(TreatSpecificWarningsAsErrors)</InscribeTreatSpecificWarningsAsErrors>
40 <InscribeVerboseOutput Condition=" '$(InscribeVerboseOutput)' == '' ">$(VerboseOutput)</InscribeVerboseOutput>
41 </PropertyGroup>
42
43 <PropertyGroup>
44 <SignOutputCabs Condition=" '$(SignOutputCabs)'=='' ">$(SignOutput)</SignOutputCabs>
45 </PropertyGroup>
46
47 <!--
48 ==================================================================================================
49 Signing
50 ==================================================================================================
51 -->
52 <PropertyGroup>
53 <_InternalSignDependsOn Condition=" '$(OutputType)' == 'Module' ">
54 GetMsmsToSign;
55 InternalSignMsm;
56 </_InternalSignDependsOn>
57 <_InternalSignDependsOn Condition=" '$(OutputType)' == 'Package' ">
58 GetCabsToSign;
59 GetMsiToSign;
60 InternalSignCabs;
61 InscribeMsi;
62 InternalSignMsi;
63 </_InternalSignDependsOn>
64 <_InternalSignDependsOn Condition=" '$(OutputType)' == 'Bundle' ">
65 InscribeBundleEngine;
66 InternalSignBundleEngine;
67 InscribeBundle;
68 InternalSignBundle;
69 </_InternalSignDependsOn>
70
71 <SigningDependsOn>
72 CoreCompile;
73 CalculateSignTargetFiles;
74 BeforeSigning;
75 $(_InternalSignDependsOn);
76 AfterSigning
77 </SigningDependsOn>
78
79 <CompileDependsOn>
80 $(CompileDependsOn);
81 Signing
82 </CompileDependsOn>
83 </PropertyGroup>
84 <Target
85 Name="Signing"
86 DependsOnTargets="$(SigningDependsOn)"
87 Inputs="@(_WixBuildOutputFile)"
88 Outputs="$(SignedFilePath)"
89 Condition=" '$(SignOutput)' == 'true' ">
90
91 <ItemGroup>
92 <FileWrites Include="$(SignedFilePath)" />
93 </ItemGroup>
94
95 <WriteLinesToFile
96 File="$(SignedFilePath)"
97 Lines="^$(MSBuildProjectFullPath);@(SignMsm);@(SignCabs);@(SignMsi);@(SignBundleEngine);@(SignBundle)"
98 Overwrite="true" />
99 </Target>
100
101 <!-- Internal targets so correct signing targets are called. -->
102 <Target
103 Name="CalculateSignTargetFiles">
104 <ItemGroup>
105 <SignTargetPath Include="@(_WixBuildOutputFile)" />
106 </ItemGroup>
107 </Target>
108
109 <Target
110 Name="GetMsmsToSign"
111 Inputs="@(SignTargetPath)"
112 Outputs="$(SignedFilePath)">
113
114 <ItemGroup>
115 <SignMsm Include="@(SignTargetPath)" />
116 </ItemGroup>
117 </Target>
118
119 <Target
120 Name="InternalSignMsm"
121 DependsOnTargets="SignMsm"
122 Condition=" '@(SignMsm)' != '' " />
123
124 <Target
125 Name="GetCabsToSign"
126 Inputs="@(SignTargetPath)"
127 Outputs="$(SignedFilePath)"
128 Condition=" '$(SignOutputCabs)' == 'true' ">
129 <GetCabList Database="%(SignTargetPath.FullPath)">
130 <Output TaskParameter="CabList" ItemName="SignCabs" />
131 <Output TaskParameter="CabList" ItemName="FileWrites" />
132 </GetCabList>
133 </Target>
134
135 <Target
136 Name="InternalSignCabs"
137 DependsOnTargets="SignCabs"
138 Condition=" '@(SignCabs)' != '' " />
139
140 <Target
141 Name="GetMsiToSign"
142 Inputs="@(SignTargetPath)"
143 Outputs="$(SignedFilePath)">
144 <CreateItemAvoidingInference InputProperties="@(SignTargetPath)">
145 <Output TaskParameter="OutputItems" ItemName="SignMsi" />
146 <Output TaskParameter="OutputItems" ItemName="FileWrites" />
147 </CreateItemAvoidingInference>
148 </Target>
149
150 <Target
151 Name="InternalSignMsi"
152 DependsOnTargets="SignMsi"
153 Inputs="@(SignTargetPath)"
154 Outputs="$(SignedFilePath)"
155 Condition=" '@(SignMsi)' != '' " />
156
157 <Target
158 Name="InternalSignBundleEngine"
159 DependsOnTargets="SignBundleEngine"
160 Condition=" '@(SignBundleEngine)' != '' " />
161
162 <Target
163 Name="InternalSignBundle"
164 DependsOnTargets="SignBundle"
165 Condition=" '@(SignBundle)' != '' " />
166
167 <!--
168 ================================================================================================
169 InscribeMsi
170
171 To be called after signing an MSI's cabs - inscribes an MSI with the digital signature of its
172 external cabs.
173
174 [IN/OUT]
175 @(SignTargetPath) - The database file to inscribe - database file will be modified in-place.
176
177 [OUT]
178 @(SignMsi) - The database file to sign.
179 ================================================================================================
180 -->
181 <PropertyGroup>
182 <InscribeMsiDependsOn>
183 </InscribeMsiDependsOn>
184 </PropertyGroup>
185 <Target
186 Name="InscribeMsi"
187 DependsOnTargets="$(InscribeMsiDependsOn)"
188 Inputs="@(SignTargetPath)"
189 Outputs="$(SignedFilePath)"
190 Condition=" '@(SignCabs)' != '' ">
191
192 <InscribeMsiWithCabinetSignatures
193 DatabaseFile="%(SignTargetPath.FullPath)"
194 OutputFile="%(SignTargetPath.FullPath)"
195 IntermediateDirectory="%(SignTargetPath.RootDir)%(SignTargetPath.Directory)"
196
197 NoLogo="$(InscribeNoLogo)"
198 SuppressAllWarnings="$(InscribeSuppressAllWarnings)"
199 SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)"
200 TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)"
201 TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)"
202 VerboseOutput="$(InscribeVerboseOutput)"
203 AdditionalOptions="$(InscribeAdditionalOptions)"
204
205 ToolExe="$(WixToolExe)"
206 ToolPath="$(WixToolDir)" />
207 </Target>
208
209 <!--
210 ================================================================================================
211 InscribeBundleEngine
212
213 Removes attached container so engine can be signed without attached container.
214
215 [IN]
216 @(SignTargetPath) - The bundle to inscribe.
217
218 [OUT]
219 @(SignBundleEngine) - The bundle engine file to be signed.
220 ================================================================================================
221 -->
222 <PropertyGroup>
223 <InscribeBundleEngineDependsOn>
224 </InscribeBundleEngineDependsOn>
225 </PropertyGroup>
226 <Target
227 Name="InscribeBundleEngine"
228 DependsOnTargets="$(InscribeBundleEngineDependsOn)"
229 Inputs="@(SignTargetPath)"
230 Outputs="$(SignedFilePath)">
231
232 <DetachBundleEngineForSigning
233 BundleFile="@(SignTargetPath)"
234 OutputFile="$(IntermediateOutputPath)%(SignTargetPath.Filename)-engine%(SignTargetPath.Extension)"
235 IntermediateDirectory="%(SignTargetPath.RootDir)%(SignTargetPath.Directory)"
236
237 NoLogo="$(InscribeNoLogo)"
238 SuppressAllWarnings="$(InscribeSuppressAllWarnings)"
239 SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)"
240 TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)"
241 TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)"
242 VerboseOutput="$(InscribeVerboseOutput)"
243 AdditionalOptions="$(InscribeAdditionalOptions)"
244
245 ToolExe="$(WixToolExe)"
246 ToolPath="$(WixToolDir)">
247 <Output TaskParameter="Output" ItemName="SignBundleEngine" />
248 </DetachBundleEngineForSigning>
249
250 <!-- Explicitly add output to FileWrites to ensure it is included even when the target is up to date. -->
251 <ItemGroup>
252 <FileWrites Include="$(IntermediateOutputPath)%(SignTargetPath.Filename)-engine%(SignTargetPath.Extension)" />
253 </ItemGroup>
254 </Target>
255
256 <!--
257 ================================================================================================
258 InscribeBundle
259
260 To be called after signing the bundle engine to reattach the attached container.
261
262 [IN]
263 @(SignBundleEngine) - The bundle to inscribe.
264
265 [OUT]
266 @(SignBundle) - The bundle engine file to be signed.
267 ================================================================================================
268 -->
269 <PropertyGroup>
270 <InscribeBundleDependsOn>
271 </InscribeBundleDependsOn>
272 </PropertyGroup>
273 <Target
274 Name="InscribeBundle"
275 DependsOnTargets="$(InscribeBundleDependsOn)"
276 Inputs="@(SignTargetPath);@(SignBundleEngine)"
277 Outputs="$(SignedFilePath)">
278
279 <ReattachSignedBundleEngine
280 BundleFile="@(SignTargetPath)"
281 BundleEngineFile="@(SignBundleEngine)"
282 OutputFile="@(SignTargetPath)"
283 IntermediateDirectory="%(SignTargetPath.RootDir)%(SignTargetPath.Directory)"
284
285 NoLogo="$(InscribeNoLogo)"
286 SuppressAllWarnings="$(InscribeSuppressAllWarnings)"
287 SuppressSpecificWarnings="$(InscribeSuppressSpecificWarnings)"
288 TreatWarningsAsErrors="$(InscribeTreatWarningsAsErrors)"
289 TreatSpecificWarningsAsErrors="$(InscribeTreatSpecificWarningsAsErrors)"
290 VerboseOutput="$(InscribeVerboseOutput)"
291 AdditionalOptions="$(InscribeAdditionalOptions)"
292
293 ToolExe="$(WixToolExe)"
294 ToolPath="$(WixToolDir)">
295 <Output TaskParameter="Output" ItemName="SignBundle" />
296 <Output TaskParameter="Output" ItemName="FileWrites" />
297 </ReattachSignedBundleEngine>
298 </Target>
299
300 </Project>