diff options
| author | Rob Mensching <rob@firegiant.com> | 2025-12-14 19:55:28 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-12-15 13:36:08 -0800 |
| commit | 2a58247b62bdea7c829ca643812faa7665f39a73 (patch) | |
| tree | 9836abd29cda2539c9b71aeecbd80a529409a261 /src | |
| parent | aad18fbd75dcf49ba9574f42667928b6a4a58dc8 (diff) | |
| download | wix-2a58247b62bdea7c829ca643812faa7665f39a73.tar.gz wix-2a58247b62bdea7c829ca643812faa7665f39a73.tar.bz2 wix-2a58247b62bdea7c829ca643812faa7665f39a73.zip | |
Resolves 8967
Diffstat (limited to 'src')
4 files changed, 78 insertions, 2 deletions
diff --git a/src/wix/WixToolset.BuildTasks/UpdateProjectReferenceMetadata.cs b/src/wix/WixToolset.BuildTasks/UpdateProjectReferenceMetadata.cs index d391bdb9..238ab02d 100644 --- a/src/wix/WixToolset.BuildTasks/UpdateProjectReferenceMetadata.cs +++ b/src/wix/WixToolset.BuildTasks/UpdateProjectReferenceMetadata.cs | |||
| @@ -364,7 +364,26 @@ namespace WixToolset.BuildTasks | |||
| 364 | } | 364 | } |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | return new ProjectReferenceFacade(projectReference, configurations, null, platforms, null, targetFrameworks, null, runtimeIdentifiersValue.Values, null, publishBaseDir); | 367 | // If the Properties metadata is specified MSBuild will not use TargetFramework inference and require explicit declaration of |
| 368 | // our expansions (Configurations, Platforms, TargetFrameworks, RuntimeIdentifiers). Rather that try to interoperate, we'll | ||
| 369 | // warn the user that we're disabling our expansion behavior. | ||
| 370 | var propertiesValue = projectReference.GetMetadata("Properties"); | ||
| 371 | |||
| 372 | if (!String.IsNullOrWhiteSpace(propertiesValue) && (configurationsValue.HadValue || platformsValue.HadValue || targetFrameworksValue.HadValue || runtimeIdentifiersValue.HadValue)) | ||
| 373 | { | ||
| 374 | logger.LogWarning( | ||
| 375 | "ProjectReference '{0}' specifies 'Properties' metadata. " + | ||
| 376 | "That overrides ProjectReference expansion so the 'Configurations', 'Platforms', 'TargetFrameworks', and 'RuntimeIdentifiers' metadata was ignored. " + | ||
| 377 | "Instead, use the 'AdditionalProperties' metadata to pass properties to the referenced project without disabling ProjectReference expansion.", | ||
| 378 | projectReference.ItemSpec); | ||
| 379 | |||
| 380 | // Return a facade that does not participate in expansion. | ||
| 381 | return new ProjectReferenceFacade(projectReference, Array.Empty<string>(), null, Array.Empty<string>(), null, Array.Empty<string>(), null, Array.Empty<string>(), null, publishBaseDir); | ||
| 382 | } | ||
| 383 | else | ||
| 384 | { | ||
| 385 | return new ProjectReferenceFacade(projectReference, configurations, null, platforms, null, targetFrameworks, null, runtimeIdentifiersValue.Values, null, publishBaseDir); | ||
| 386 | } | ||
| 368 | } | 387 | } |
| 369 | 388 | ||
| 370 | public string CalculatePublishDir() | 389 | public string CalculatePublishDir() |
diff --git a/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs b/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs index 78166e00..408bab2f 100644 --- a/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs +++ b/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs | |||
| @@ -14,7 +14,6 @@ namespace WixToolsetTest.Sdk | |||
| 14 | using WixInternal.MSTestSupport; | 14 | using WixInternal.MSTestSupport; |
| 15 | using WixToolset.Data; | 15 | using WixToolset.Data; |
| 16 | using WixToolset.Data.Symbols; | 16 | using WixToolset.Data.Symbols; |
| 17 | using WixToolset.Data.WindowsInstaller.Rows; | ||
| 18 | 17 | ||
| 19 | [TestClass] | 18 | [TestClass] |
| 20 | public class MsbuildFixture | 19 | public class MsbuildFixture |
| @@ -818,6 +817,36 @@ namespace WixToolsetTest.Sdk | |||
| 818 | [DataRow(BuildSystem.DotNetCoreSdk)] | 817 | [DataRow(BuildSystem.DotNetCoreSdk)] |
| 819 | [DataRow(BuildSystem.MSBuild)] | 818 | [DataRow(BuildSystem.MSBuild)] |
| 820 | [DataRow(BuildSystem.MSBuild64)] | 819 | [DataRow(BuildSystem.MSBuild64)] |
| 820 | public void CanBuildUsingExplicitProperties(BuildSystem buildSystem) | ||
| 821 | { | ||
| 822 | var sourceFolder = TestData.Get(@"TestData", "MultiTargetingWixlib"); | ||
| 823 | |||
| 824 | using (var fs = new TestDataFolderFileSystem()) | ||
| 825 | { | ||
| 826 | fs.Initialize(sourceFolder); | ||
| 827 | var baseFolder = Path.Combine(fs.BaseFolder, "PackageUsingExplicitProperties"); | ||
| 828 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 829 | var filesFolder = Path.Combine(binFolder, "Release", @"PFiles\"); | ||
| 830 | var projectPath = Path.Combine(baseFolder, "PackageUsingExplicitProperties.wixproj"); | ||
| 831 | |||
| 832 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, [ | ||
| 833 | "-Restore", | ||
| 834 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath) | ||
| 835 | ]); | ||
| 836 | result.AssertSuccess(); | ||
| 837 | |||
| 838 | var warnings = result.Output.Where(line => line.Contains(": warning")).Select(line => ExtractWarningFromMessage(line, baseFolder)).Distinct().ToArray(); | ||
| 839 | WixAssert.CompareLineByLine( | ||
| 840 | [ | ||
| 841 | @": ProjectReference '..\TestExe\TestExe.csproj' specifies 'Properties' metadata. That overrides ProjectReference expansion so the 'Configurations', 'Platforms', 'TargetFrameworks', and 'RuntimeIdentifiers' metadata was ignored. Instead, use the 'AdditionalProperties' metadata to pass properties to the referenced project without disabling ProjectReference expansion.", | ||
| 842 | ], warnings); | ||
| 843 | } | ||
| 844 | } | ||
| 845 | |||
| 846 | [TestMethod] | ||
| 847 | [DataRow(BuildSystem.DotNetCoreSdk)] | ||
| 848 | [DataRow(BuildSystem.MSBuild)] | ||
| 849 | [DataRow(BuildSystem.MSBuild64)] | ||
| 821 | public void CanBuildMultiTargetingWixlibUsingRidsWithReleaseAndDebug(BuildSystem buildSystem) | 850 | public void CanBuildMultiTargetingWixlibUsingRidsWithReleaseAndDebug(BuildSystem buildSystem) |
| 822 | { | 851 | { |
| 823 | var sourceFolder = TestData.Get(@"TestData", "MultiTargetingWixlib"); | 852 | var sourceFolder = TestData.Get(@"TestData", "MultiTargetingWixlib"); |
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/MultiTargetingWixlib/PackageUsingExplicitProperties/Package.wxs b/src/wix/test/WixToolsetTest.Sdk/TestData/MultiTargetingWixlib/PackageUsingExplicitProperties/Package.wxs new file mode 100644 index 00000000..a53c59a5 --- /dev/null +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/MultiTargetingWixlib/PackageUsingExplicitProperties/Package.wxs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Name="Test Package" Manufacturer="~Test" Version="0" Compressed="false" UpgradeCode="11111111-1111-1111-1111-111111111111"> | ||
| 3 | <Feature Id="Main"> | ||
| 4 | <ComponentGroupRef Id="Stuff"/> | ||
| 5 | </Feature> | ||
| 6 | </Package> | ||
| 7 | |||
| 8 | <Fragment> | ||
| 9 | <ComponentGroup Id="Stuff" Directory="ProgramFilesFolder"> | ||
| 10 | <Component Subdirectory="net8_x64"> | ||
| 11 | <File Id="net8_x64" Source="!(bindpath.TestExe)\e_sqlite3.dll" /> | ||
| 12 | </Component> | ||
| 13 | </ComponentGroup> | ||
| 14 | </Fragment> | ||
| 15 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/MultiTargetingWixlib/PackageUsingExplicitProperties/PackageUsingExplicitProperties.wixproj b/src/wix/test/WixToolsetTest.Sdk/TestData/MultiTargetingWixlib/PackageUsingExplicitProperties/PackageUsingExplicitProperties.wixproj new file mode 100644 index 00000000..8d3d9112 --- /dev/null +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/MultiTargetingWixlib/PackageUsingExplicitProperties/PackageUsingExplicitProperties.wixproj | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Project> | ||
| 3 | <Import Project="$(WixMSBuildProps)" /> | ||
| 4 | |||
| 5 | <ItemGroup> | ||
| 6 | <ProjectReference Include="..\TestExe\TestExe.csproj" Publish="true" TargetFrameworks="net472" RuntimeIdentifiers="win-x86"> | ||
| 7 | <!-- Not recommended, these disable the values on the ProjectReference --> | ||
| 8 | <Properties>TargetFramework=net8.0;RuntimeIdentifier=win-x64</Properties> | ||
| 9 | </ProjectReference> | ||
| 10 | </ItemGroup> | ||
| 11 | |||
| 12 | <Import Project="$(WixTargetsPath)" /> | ||
| 13 | </Project> | ||
