diff options
author | Rob Mensching <rob@firegiant.com> | 2022-11-20 11:12:45 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-11-21 09:12:41 -0800 |
commit | 6ed066072db5bf15453da1f8da28f727ba46fc5b (patch) | |
tree | 91e6053c2cc3ad41f42573b0e0dca0dc5e89f2ce | |
parent | 83a63bdc1943187e93749420a3408cd6248eedb9 (diff) | |
download | wix-6ed066072db5bf15453da1f8da28f727ba46fc5b.tar.gz wix-6ed066072db5bf15453da1f8da28f727ba46fc5b.tar.bz2 wix-6ed066072db5bf15453da1f8da28f727ba46fc5b.zip |
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
7 files changed, 122 insertions, 98 deletions
diff --git a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj index 63caf5c0..27affb11 100644 --- a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj +++ b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj | |||
@@ -3,6 +3,7 @@ | |||
3 | <Project Sdk='WixToolset.Sdk'> | 3 | <Project Sdk='WixToolset.Sdk'> |
4 | <PropertyGroup> | 4 | <PropertyGroup> |
5 | <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | 5 | <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> |
6 | <SignOutput>true</SignOutput> | ||
6 | </PropertyGroup> | 7 | </PropertyGroup> |
7 | 8 | ||
8 | <ItemGroup> | 9 | <ItemGroup> |
@@ -12,4 +13,8 @@ | |||
12 | 13 | ||
13 | <PackageReference Include="Wixtoolset.UI.wixext" /> | 14 | <PackageReference Include="Wixtoolset.UI.wixext" /> |
14 | </ItemGroup> | 15 | </ItemGroup> |
16 | |||
17 | <Target Name="SignMsi"> | ||
18 | <Warning Text="SignMsi = @(SignMsi)" /> | ||
19 | </Target> | ||
15 | </Project> | 20 | </Project> |
diff --git a/src/test/wix/WixE2E/WixE2EFixture.cs b/src/test/wix/WixE2E/WixE2EFixture.cs index f9094fb2..4a0b78d8 100644 --- a/src/test/wix/WixE2E/WixE2EFixture.cs +++ b/src/test/wix/WixE2E/WixE2EFixture.cs | |||
@@ -55,6 +55,14 @@ namespace WixE2E | |||
55 | 55 | ||
56 | var result = RestoreAndBuild(projectPath); | 56 | var result = RestoreAndBuild(projectPath); |
57 | result.AssertSuccess(); | 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); | ||
58 | } | 66 | } |
59 | 67 | ||
60 | [Fact] | 68 | [Fact] |
diff --git a/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj b/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj index 4a5e6229..eca65bda 100644 --- a/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj +++ b/src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj | |||
@@ -13,6 +13,7 @@ | |||
13 | <ItemGroup> | 13 | <ItemGroup> |
14 | <Content Include="build\$(MSBuildThisFileName).props" CopyToOutputDirectory="PreserveNewest" /> | 14 | <Content Include="build\$(MSBuildThisFileName).props" CopyToOutputDirectory="PreserveNewest" /> |
15 | <Content Include="build\$(MSBuildThisFileName).targets" CopyToOutputDirectory="PreserveNewest" /> | 15 | <Content Include="build\$(MSBuildThisFileName).targets" CopyToOutputDirectory="PreserveNewest" /> |
16 | <Content Include="tools\WixToolset.Signing.props" CopyToOutputDirectory="PreserveNewest" /> | ||
16 | <Content Include="tools\WixToolset.Signing.targets" CopyToOutputDirectory="PreserveNewest" /> | 17 | <Content Include="tools\WixToolset.Signing.targets" CopyToOutputDirectory="PreserveNewest" /> |
17 | <Content Include="tools\wix.props" CopyToOutputDirectory="PreserveNewest" /> | 18 | <Content Include="tools\wix.props" CopyToOutputDirectory="PreserveNewest" /> |
18 | <Content Include="tools\wix.targets" CopyToOutputDirectory="PreserveNewest" /> | 19 | <Content Include="tools\wix.targets" CopyToOutputDirectory="PreserveNewest" /> |
diff --git a/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.props b/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.props new file mode 100644 index 00000000..0b2522c8 --- /dev/null +++ b/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.props | |||
@@ -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> | ||
diff --git a/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.targets b/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.targets index 8b850fd7..c414bcf1 100644 --- a/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.targets +++ b/src/wix/WixToolset.Sdk/tools/WixToolset.Signing.targets | |||
@@ -3,10 +3,13 @@ | |||
3 | 3 | ||
4 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | 4 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
5 | <PropertyGroup> | 5 | <PropertyGroup> |
6 | <WixSigningTargetsImported>true</WixSigningTargetsImported> | ||
6 | <SignedFileName Condition=" '$(SignedFileName)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFileName> | 7 | <SignedFileName Condition=" '$(SignedFileName)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFileName> |
7 | <SignedFilePath>$(IntermediateOutputPath)$(SignedFileName)</SignedFilePath> | 8 | <SignedFilePath>$(IntermediateOutputPath)$(SignedFileName)</SignedFilePath> |
8 | </PropertyGroup> | 9 | </PropertyGroup> |
9 | 10 | ||
11 | <Import Project="WixToolset.Signing.props" Condition=" '$(WixSigningPropsImported)' != 'true' " /> | ||
12 | |||
10 | <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" /> | 13 | <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" /> |
11 | <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" /> | 14 | <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" /> |
12 | <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" /> | 15 | <UsingTask TaskName="GetCabList" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" /> |
@@ -309,97 +312,4 @@ | |||
309 | </ReattachSignedBundleEngine> | 312 | </ReattachSignedBundleEngine> |
310 | </Target> | 313 | </Target> |
311 | 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 | |||
405 | </Project> | 315 | </Project> |
diff --git a/src/wix/WixToolset.Sdk/tools/wix.props b/src/wix/WixToolset.Sdk/tools/wix.props index d3c202bf..c526d865 100644 --- a/src/wix/WixToolset.Sdk/tools/wix.props +++ b/src/wix/WixToolset.Sdk/tools/wix.props | |||
@@ -19,6 +19,8 @@ | |||
19 | 19 | ||
20 | <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | 20 | <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
21 | 21 | ||
22 | <Import Project="WixToolset.Signing.props" Condition=" '$(WixSigningPropsImported)' != 'true' " /> | ||
23 | |||
22 | <PropertyGroup> | 24 | <PropertyGroup> |
23 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | 25 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
24 | </PropertyGroup> | 26 | </PropertyGroup> |
diff --git a/src/wix/WixToolset.Sdk/tools/wix.targets b/src/wix/WixToolset.Sdk/tools/wix.targets index e18eaf62..a4603c47 100644 --- a/src/wix/WixToolset.Sdk/tools/wix.targets +++ b/src/wix/WixToolset.Sdk/tools/wix.targets | |||
@@ -31,10 +31,6 @@ | |||
31 | <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixBinDir)WixToolset.BuildTasks.dll</WixTasksPath> | 31 | <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixBinDir)WixToolset.BuildTasks.dll</WixTasksPath> |
32 | </PropertyGroup> | 32 | </PropertyGroup> |
33 | 33 | ||
34 | <PropertyGroup> | ||
35 | <WixSigningTargetsPath Condition=" '$(WixSigningTargetsPath)' == '' ">$(MSBuildThisFileDirectory)WixToolset.Signing.targets</WixSigningTargetsPath> | ||
36 | </PropertyGroup> | ||
37 | |||
38 | <ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' "> | 34 | <ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' "> |
39 | <Compile Include="**/*.wxs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultCompileItems)' == 'true' " /> | 35 | <Compile Include="**/*.wxs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultCompileItems)' == 'true' " /> |
40 | <EmbeddedResource Include="**/*.wxl" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " /> | 36 | <EmbeddedResource Include="**/*.wxl" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition=" '$(EnableDefaultEmbeddedResourceItems)' == 'true' " /> |
@@ -937,7 +933,7 @@ | |||
937 | </Copy> | 933 | </Copy> |
938 | </Target> | 934 | </Target> |
939 | 935 | ||
940 | <Import Project="$(WixSigningTargetsPath)" /> | 936 | <Import Project="WixToolset.Signing.targets" Condition=" '$(WixSigningTargetsImported)' != 'true' " /> |
941 | 937 | ||
942 | <!-- Extension point: Define CustomAfterWixTargets to a .targets file that you want to include after this file. --> | 938 | <!-- Extension point: Define CustomAfterWixTargets to a .targets file that you want to include after this file. --> |
943 | <Import Project="$(CustomAfterWixTargets)" Condition=" '$(CustomAfterWixTargets)' != '' and Exists('$(CustomAfterWixTargets)')" /> | 939 | <Import Project="$(CustomAfterWixTargets)" Condition=" '$(CustomAfterWixTargets)' != '' and Exists('$(CustomAfterWixTargets)')" /> |