@joebigelow / wix-1 / commits / 6ed06607

Allow signing targets to be overridden in simple Sdk-style .wixproj

Moved the overridable signing targets (like SignMsi) to a new WixToolset.Signing.props that is included "at the very top of" a .wixproj using Sdk-style project. That way these signing targets can be overridden in the .wixproj. When the overridable signing targets were defined in WixToolset.Signing.targets, then it was necessary to use the more complex Sdk-style Import syntax to place the signing targets low enough in the .wixproj. Closes 7038

Rob Mensching committed Nov 20, 2022 at 11:12 UTC 6ed066072db5bf15453da1f8da28f727ba46fc5b
7 files changed +122 -98
src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj
+5
@@ -3,6 +3,7 @@
3 <Project Sdk='WixToolset.Sdk'>
4 <PropertyGroup>
5 <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
6 + <SignOutput>true</SignOutput>
7 </PropertyGroup>
8
9 <ItemGroup>
@@ -12,4 +13,8 @@
13
14 <PackageReference Include="Wixtoolset.UI.wixext" />
15 </ItemGroup>
16 +
17 + <Target Name="SignMsi">
18 + <Warning Text="SignMsi = @(SignMsi)" />
19 + </Target>
20 </Project>
src/test/wix/WixE2E/WixE2EFixture.cs
+8
@@ -55,6 +55,14 @@ namespace WixE2E
55
56 var result = RestoreAndBuild(projectPath);
57 result.AssertSuccess();
58 +
59 + var signingStatement = result.Output.Where(s => s.Contains("warning :"))
60 + .Select(s => s.Replace(Path.GetDirectoryName(projectPath), "<projectFolder>").Replace(@"\Debug\", @"\<configuration>\").Replace(@"\Release\", @"\<configuration>\"))
61 + .ToArray();
62 + WixAssert.CompareLineByLine(new[]
63 + {
64 + @"<projectFolder>\WixprojPackageVcxprojWindowsApp.wixproj(18,5): warning : SignMsi = obj\<configuration>\en-US\WixprojPackageVcxprojWindowsApp.msi;obj\<configuration>\ja-JP\WixprojPackageVcxprojWindowsApp.msi"
65 + }, signingStatement);
66 }
67
68 [Fact]
src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj
+1
@@ -13,6 +13,7 @@
13 <ItemGroup>
14 <Content Include="build\$(MSBuildThisFileName).props" CopyToOutputDirectory="PreserveNewest" />
15 <Content Include="build\$(MSBuildThisFileName).targets" CopyToOutputDirectory="PreserveNewest" />
16 + <Content Include="tools\WixToolset.Signing.props" CopyToOutputDirectory="PreserveNewest" />
17 <Content Include="tools\WixToolset.Signing.targets" CopyToOutputDirectory="PreserveNewest" />
18 <Content Include="tools\wix.props" CopyToOutputDirectory="PreserveNewest" />
19 <Content Include="tools\wix.targets" CopyToOutputDirectory="PreserveNewest" />
src/wix/WixToolset.Sdk/tools/WixToolset.Signing.props new
+102
@@ -0,0 +1,102 @@
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 + <WixSigningPropsImported>true</WixSigningPropsImported>
7 + </PropertyGroup>
8 +
9 + <!--
10 + ==================================================================================================
11 + BeforeSigning
12 +
13 + Redefine this target in your project in order to run tasks just before all signing tasks.
14 + ==================================================================================================
15 + -->
16 + <Target Name="BeforeSigning" />
17 +
18 + <!--
19 + ==================================================================================================
20 + SignMsm
21 +
22 + Redefine this target in your project in order to sign merge modules.
23 +
24 + [IN]
25 + @(SignMsm) - merge module files to sign.
26 + ==================================================================================================
27 + -->
28 + <Target Name="SignMsm" />
29 +
30 + <!--
31 + ==================================================================================================
32 + SignCabs
33 +
34 + Redefine this target in your project in order to sign the cabs of your database.
35 +
36 + [IN]
37 + @(SignCabs) - cabinet files to sign.
38 + ==================================================================================================
39 + -->
40 + <Target Name="SignCabs" />
41 +
42 + <!--
43 + ==================================================================================================
44 + SignMsi
45 +
46 + Redefine this target in your project in order to sign your database, after it has been inscribed
47 + with the signatures of your signed cabs.
48 +
49 + [IN]
50 + @(SignMsi) - database files to sign.
51 + ==================================================================================================
52 + -->
53 + <Target Name="SignMsi" />
54 +
55 + <!--
56 + ==================================================================================================
57 + SignContainers
58 +
59 + Redefine this target in your project in order to sign your bundle's detached containers.
60 +
61 + [IN]
62 + @(SignContainers) - detached container files to sign.
63 + ==================================================================================================
64 + -->
65 + <Target Name="SignContainers" />
66 +
67 + <!--
68 + ==================================================================================================
69 + SignBundleEngine
70 +
71 + Redefine this target in your project in order to sign your bundle, after it has been inscribed
72 + with the signatures of your signed containers.
73 +
74 + [IN]
75 + @(SignBundleEngine) - bundle engine file to sign.
76 + ==================================================================================================
77 + -->
78 + <Target Name="SignBundleEngine" />
79 +
80 + <!--
81 + ==================================================================================================
82 + SignBundle
83 +
84 + Redefine this target in your project in order to sign your bundle, after the attached container
85 + is reattached.
86 +
87 + [IN]
88 + @(SignBundle) - bundle file to sign.
89 + ==================================================================================================
90 + -->
91 + <Target Name="SignBundle" />
92 +
93 + <!--
94 + ==================================================================================================
95 + AfterSigning
96 +
97 + Redefine this target in your project in order to run tasks just after all signing tasks.
98 + ==================================================================================================
99 + -->
100 + <Target Name="AfterSigning" />
101 +
102 +</Project>
src/wix/WixToolset.Sdk/tools/WixToolset.Signing.targets
+3 -93
@@ -3,10 +3,13 @@
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" />
@@ -309,97 +312,4 @@
312 </ReattachSignedBundleEngine>
313 </Target>
314
312 - <!--
313 - ==================================================================================================
314 - BeforeSigning
315 -
316 - Redefine this target in your project in order to run tasks just before all signing tasks.
317 - ==================================================================================================
318 - -->
319 - <Target Name="BeforeSigning" />
320 -
321 - <!--
322 - ==================================================================================================
323 - SignMsm
324 -
325 - Redefine this target in your project in order to sign merge modules.
326 -
327 - [IN]
328 - @(SignMsm) - merge module files to sign.
329 - ==================================================================================================
330 - -->
331 - <Target Name="SignMsm" />
332 -
333 - <!--
334 - ==================================================================================================
335 - SignCabs
336 -
337 - Redefine this target in your project in order to sign the cabs of your database.
338 -
339 - [IN]
340 - @(SignCabs) - cabinet files to sign.
341 - ==================================================================================================
342 - -->
343 - <Target Name="SignCabs" />
344 -
345 - <!--
346 - ==================================================================================================
347 - SignMsi
348 -
349 - Redefine this target in your project in order to sign your database, after it has been inscribed
350 - with the signatures of your signed cabs.
351 -
352 - [IN]
353 - @(SignMsi) - database files to sign.
354 - ==================================================================================================
355 - -->
356 - <Target Name="SignMsi" />
357 -
358 - <!--
359 - ==================================================================================================
360 - SignContainers
361 -
362 - Redefine this target in your project in order to sign your bundle's detached containers.
363 -
364 - [IN]
365 - @(SignContainers) - detached container files to sign.
366 - ==================================================================================================
367 - -->
368 - <Target Name="SignContainers" />
369 -
370 - <!--
371 - ==================================================================================================
372 - SignBundleEngine
373 -
374 - Redefine this target in your project in order to sign your bundle, after it has been inscribed
375 - with the signatures of your signed containers.
376 -
377 - [IN]
378 - @(SignBundleEngine) - bundle engine file to sign.
379 - ==================================================================================================
380 - -->
381 - <Target Name="SignBundleEngine" />
382 -
383 - <!--
384 - ==================================================================================================
385 - SignBundle
386 -
387 - Redefine this target in your project in order to sign your bundle, after the attached container
388 - is reattached.
389 -
390 - [IN]
391 - @(SignBundle) - bundle file to sign.
392 - ==================================================================================================
393 - -->
394 - <Target Name="SignBundle" />
395 -
396 - <!--
397 - ==================================================================================================
398 - AfterSigning
399 -
400 - Redefine this target in your project in order to run tasks just after all signing tasks.
401 - ==================================================================================================
402 - -->
403 - <Target Name="AfterSigning" />
404 -
315 </Project>
src/wix/WixToolset.Sdk/tools/wix.props
+2
@@ -19,6 +19,8 @@
19
20 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
21
22 + <Import Project="WixToolset.Signing.props" Condition=" '$(WixSigningPropsImported)' != 'true' " />
23 +
24 <PropertyGroup>
25 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
26 </PropertyGroup>
src/wix/WixToolset.Sdk/tools/wix.targets
+1 -5
@@ -31,10 +31,6 @@
31 <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixBinDir)WixToolset.BuildTasks.dll</WixTasksPath>
32 </PropertyGroup>
33
34 - <PropertyGroup>
35 - <WixSigningTargetsPath Condition=" '$(WixSigningTargetsPath)' == '' ">$(MSBuildThisFileDirectory)WixToolset.Signing.targets</WixSigningTargetsPath>
36 - </PropertyGroup>
37 -
34 <ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' ">
35 <Compile Include="**/*.wxs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
36 <EmbeddedResource Include="**/*.wxl" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " />
@@ -937,7 +933,7 @@
933 </Copy>
934 </Target>
935
940 - <Import Project="$(WixSigningTargetsPath)" />
936 + <Import Project="WixToolset.Signing.targets" Condition=" '$(WixSigningTargetsImported)' != 'true' " />
937
938 <!-- Extension point: Define CustomAfterWixTargets to a .targets file that you want to include after this file. -->
939 <Import Project="$(CustomAfterWixTargets)" Condition=" '$(CustomAfterWixTargets)' != '' and Exists('$(CustomAfterWixTargets)')" />