diff options
Diffstat (limited to 'src')
21 files changed, 689 insertions, 18 deletions
diff --git a/src/build_all.cmd b/src/build_all.cmd index 14e77bee..7e9e7790 100644 --- a/src/build_all.cmd +++ b/src/build_all.cmd | |||
| @@ -84,7 +84,7 @@ if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" | |||
| 84 | exit /b 2 | 84 | exit /b 2 |
| 85 | ) | 85 | ) |
| 86 | 86 | ||
| 87 | for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [18^,19^) -property installationPath`) do ( | 87 | for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [17^,19^) -property installationPath`) do ( |
| 88 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( | 88 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( |
| 89 | call "%%i\Common7\Tools\vsdevcmd.bat" -no_logo | 89 | call "%%i\Common7\Tools\vsdevcmd.bat" -no_logo |
| 90 | exit /b | 90 | exit /b |
diff --git a/src/internal/WixInternal.MSTestSupport/MsbuildUtilities.cs b/src/internal/WixInternal.MSTestSupport/MsbuildUtilities.cs index 8f3fecd9..516143dd 100644 --- a/src/internal/WixInternal.MSTestSupport/MsbuildUtilities.cs +++ b/src/internal/WixInternal.MSTestSupport/MsbuildUtilities.cs | |||
| @@ -30,7 +30,8 @@ namespace WixInternal.MSTestSupport | |||
| 30 | 30 | ||
| 31 | if (binlog) | 31 | if (binlog) |
| 32 | { | 32 | { |
| 33 | MsbuildUtilities.GetQuotedSwitch(buildSystem, "bl", Path.ChangeExtension(projectPath, ".binlog")); | 33 | var binlogSwitch = MsbuildUtilities.GetQuotedSwitch(buildSystem, "bl", Path.ChangeExtension(projectPath, ".binlog")); |
| 34 | allArgs.Add(binlogSwitch); | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | if (arguments != null) | 37 | if (arguments != null) |
diff --git a/src/test/wix/TestData/CsprojWpfNetCore/CsprojWpfNetCore.csproj b/src/test/wix/TestData/CsprojWpfNetCore/CsprojWpfNetCore.csproj index e7061e74..b1bf8781 100644 --- a/src/test/wix/TestData/CsprojWpfNetCore/CsprojWpfNetCore.csproj +++ b/src/test/wix/TestData/CsprojWpfNetCore/CsprojWpfNetCore.csproj | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | <PropertyGroup> | 3 | <PropertyGroup> |
| 4 | <OutputType>WinExe</OutputType> | 4 | <OutputType>WinExe</OutputType> |
| 5 | <TargetFramework>net5.0-windows7.0</TargetFramework> | 5 | <TargetFramework>net8.0-windows7.0</TargetFramework> |
| 6 | <Nullable>enable</Nullable> | 6 | <Nullable>enable</Nullable> |
| 7 | <UseWPF>true</UseWPF> | 7 | <UseWPF>true</UseWPF> |
| 8 | </PropertyGroup> | 8 | </PropertyGroup> |
diff --git a/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/Package.wxs b/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/Package.wxs index 8bd191d8..3671c0ca 100644 --- a/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/Package.wxs +++ b/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/Package.wxs | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | </StandardDirectory> | 7 | </StandardDirectory> |
| 8 | 8 | ||
| 9 | <Feature Id='Main' Title='WpfApp'> | 9 | <Feature Id='Main' Title='WpfApp'> |
| 10 | <Component Directory='ApplicationFolder'> | 10 | <Files Directory='ApplicationFolder' Include='!(bindpath.CsprojWpfNetCore)\**'> |
| 11 | <File Source='CsprojWpfNetCore.exe' /> | 11 | <Exclude Files="**\*.pdb" /> |
| 12 | </Component> | 12 | </Files> |
| 13 | </Feature> | 13 | </Feature> |
| 14 | </Package> | 14 | </Package> |
| 15 | </Wix> | 15 | </Wix> |
diff --git a/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/WixprojPackageCsprojWebApplicationNetCore.wixproj b/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/WixprojPackageCsprojWpfNetCore.wixproj index 686092b6..df333242 100644 --- a/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/WixprojPackageCsprojWebApplicationNetCore.wixproj +++ b/src/test/wix/TestData/WixprojPackageCsprojWpfNetCore/WixprojPackageCsprojWpfNetCore.wixproj | |||
| @@ -1,17 +1,13 @@ | |||
| 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. --> | 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 | <Project Sdk='WixToolset.Sdk'> | 2 | <Project Sdk='WixToolset.Sdk'> |
| 3 | <!-- <Project> --> | ||
| 4 | <!-- <Import Sdk="WixToolset.Sdk" Project='D:\src\wix4\build\wix\Debug\net8.0\Sdk\Sdk.props' /> --> | ||
| 5 | 3 | ||
| 6 | <PropertyGroup> | 4 | <ItemGroup> |
| 7 | <!-- <WixBinDir>D:\src\wix4\build\wix\Debug\net472\</WixBinDir> --> | 5 | <Compile Remove="abc\Bad.wxs" /> |
| 8 | <!-- <WixBinDir64>D:\src\wix4\build\wix\Debug\publish\WixToolset.Sdk\tools\net472\x64\</WixBinDir64> --> | 6 | </ItemGroup> |
| 9 | </PropertyGroup> | ||
| 10 | 7 | ||
| 11 | <ItemGroup> | 8 | <ItemGroup> |
| 12 | <!-- SkipPublish="true" BindPath="$(MSBuildProjectDirectory)\does\not\exist" BindName="Xxx" Publish="true" --> | 9 | <!-- SkipPublish="true" BindPath="$(MSBuildProjectDirectory)\does\not\exist" BindName="Xxx" Publish="true" --> |
| 13 | <ProjectReference Include="..\CsprojWpfNetCore\CsprojWpfNetCore.csproj" Publish="true" /> | 10 | <ProjectReference Include="..\CsprojWpfNetCore\CsprojWpfNetCore.csproj" Publish="true" /> |
| 14 | </ItemGroup> | 11 | </ItemGroup> |
| 15 | 12 | ||
| 16 | <!-- <Import Sdk="WixToolset.Sdk" Project='D:\src\wix4\build\wix\Debug\net8.0\Sdk\Sdk.targets' /> --> | ||
| 17 | </Project> | 13 | </Project> |
diff --git a/src/wix/WixToolset.BuildTasks/ILogger.cs b/src/wix/WixToolset.BuildTasks/ILogger.cs new file mode 100644 index 00000000..16db691e --- /dev/null +++ b/src/wix/WixToolset.BuildTasks/ILogger.cs | |||
| @@ -0,0 +1,13 @@ | |||
| 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 WixToolset.BuildTasks | ||
| 4 | { | ||
| 5 | public interface ILogger | ||
| 6 | { | ||
| 7 | bool HasLoggedErrors { get; } | ||
| 8 | |||
| 9 | void LogError(string message); | ||
| 10 | |||
| 11 | void LogWarning(string message); | ||
| 12 | } | ||
| 13 | } | ||
diff --git a/src/wix/WixToolset.BuildTasks/MSBuildLoggerAdapter.cs b/src/wix/WixToolset.BuildTasks/MSBuildLoggerAdapter.cs new file mode 100644 index 00000000..5382254c --- /dev/null +++ b/src/wix/WixToolset.BuildTasks/MSBuildLoggerAdapter.cs | |||
| @@ -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 | namespace WixToolset.BuildTasks | ||
| 4 | { | ||
| 5 | using Microsoft.Build.Utilities; | ||
| 6 | |||
| 7 | internal class MSBuildLoggerAdapter : ILogger | ||
| 8 | { | ||
| 9 | private readonly TaskLoggingHelper log; | ||
| 10 | |||
| 11 | public MSBuildLoggerAdapter(TaskLoggingHelper log) | ||
| 12 | { | ||
| 13 | this.log = log; | ||
| 14 | } | ||
| 15 | |||
| 16 | public bool HasLoggedErrors => this.log.HasLoggedErrors; | ||
| 17 | |||
| 18 | public void LogError(string message) | ||
| 19 | { | ||
| 20 | this.log.LogError(message); | ||
| 21 | } | ||
| 22 | |||
| 23 | public void LogWarning(string message) | ||
| 24 | { | ||
| 25 | this.log.LogWarning(message); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
diff --git a/src/wix/WixToolset.BuildTasks/ResolveInstallerPlatform.cs b/src/wix/WixToolset.BuildTasks/ResolveInstallerPlatform.cs new file mode 100644 index 00000000..5e551d7b --- /dev/null +++ b/src/wix/WixToolset.BuildTasks/ResolveInstallerPlatform.cs | |||
| @@ -0,0 +1,174 @@ | |||
| 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 WixToolset.BuildTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Linq; | ||
| 7 | using Microsoft.Build.Framework; | ||
| 8 | using Microsoft.Build.Utilities; | ||
| 9 | |||
| 10 | /// <summary> | ||
| 11 | /// This task calculates the InstallerPlatform from the RuntimeIdentifier, | ||
| 12 | /// InitialInstallerPlatform and Platform properties. | ||
| 13 | /// </summary> | ||
| 14 | public class ResolveInstallerPlatform : Task | ||
| 15 | { | ||
| 16 | private readonly ILogger logger; | ||
| 17 | |||
| 18 | /// <summary> | ||
| 19 | /// Default constructor. | ||
| 20 | /// </summary> | ||
| 21 | public ResolveInstallerPlatform() | ||
| 22 | { | ||
| 23 | this.logger = new MSBuildLoggerAdapter(this.Log); | ||
| 24 | } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Constructor for dependency injection of logger used by unit tests. | ||
| 28 | /// </summary> | ||
| 29 | public ResolveInstallerPlatform(ILogger logger) | ||
| 30 | { | ||
| 31 | this.logger = logger; | ||
| 32 | } | ||
| 33 | |||
| 34 | /// <summary> | ||
| 35 | /// The optional RuntimeIdentifier property. | ||
| 36 | /// </summary> | ||
| 37 | public string RuntimeIdentifier { private get; set; } | ||
| 38 | |||
| 39 | /// <summary> | ||
| 40 | /// The optional InitialInstallerPlatform property. | ||
| 41 | /// </summary> | ||
| 42 | public string InitialInstallerPlatform { private get; set; } | ||
| 43 | |||
| 44 | /// <summary> | ||
| 45 | /// The InstallerPlatform property. | ||
| 46 | /// </summary> | ||
| 47 | public string InstallerPlatform { private get; set; } | ||
| 48 | |||
| 49 | /// <summary> | ||
| 50 | /// The optional Platform property. | ||
| 51 | /// </summary> | ||
| 52 | public string Platform { private get; set; } | ||
| 53 | |||
| 54 | /// <summary> | ||
| 55 | /// The resolved InstallerPlatform. | ||
| 56 | /// </summary> | ||
| 57 | [Output] | ||
| 58 | public string ResolvedInstallerPlatform { get; private set; } | ||
| 59 | |||
| 60 | /// <summary> | ||
| 61 | /// The optionally resolved Platform. | ||
| 62 | /// </summary> | ||
| 63 | [Output] | ||
| 64 | public string ResolvedPlatform { get; private set; } | ||
| 65 | |||
| 66 | /// <summary> | ||
| 67 | /// Convert the input properties into output items. | ||
| 68 | /// </summary> | ||
| 69 | /// <returns>True upon completion of the task execution.</returns> | ||
| 70 | public override bool Execute() | ||
| 71 | { | ||
| 72 | if (String.IsNullOrEmpty(this.RuntimeIdentifier)) | ||
| 73 | { | ||
| 74 | this.ResolvedInstallerPlatform = this.InstallerPlatform; | ||
| 75 | } | ||
| 76 | else if (this.ValidateWindowsRuntimeIdentifier(this.RuntimeIdentifier, out var platform)) | ||
| 77 | { | ||
| 78 | if (!String.IsNullOrEmpty(this.InitialInstallerPlatform) && !String.Equals(this.InitialInstallerPlatform, platform, StringComparison.OrdinalIgnoreCase)) | ||
| 79 | { | ||
| 80 | this.logger.LogError($"The RuntimeIdentifier '{this.RuntimeIdentifier}' resolves to platform '{platform}', which conflicts with the provided InstallerPlatform '{this.InitialInstallerPlatform}'."); | ||
| 81 | } | ||
| 82 | else | ||
| 83 | { | ||
| 84 | this.ResolvedInstallerPlatform = platform; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | // If Platform was a generic value, resolve it to the resolved installer platform. | ||
| 89 | if (String.IsNullOrEmpty(this.Platform) | ||
| 90 | || this.Platform.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase) | ||
| 91 | || this.Platform.Equals("Any CPU", StringComparison.OrdinalIgnoreCase) | ||
| 92 | || this.Platform.Equals("Win32", StringComparison.OrdinalIgnoreCase)) | ||
| 93 | { | ||
| 94 | this.ResolvedPlatform = this.ResolvedInstallerPlatform; | ||
| 95 | } | ||
| 96 | else if (!this.Platform.Equals(this.ResolvedInstallerPlatform, StringComparison.OrdinalIgnoreCase)) | ||
| 97 | { | ||
| 98 | this.logger.LogWarning($"The provided Platform '{this.Platform}' does not match the resolved InstallerPlatform '{this.ResolvedInstallerPlatform}'. The output will be built using '{this.ResolvedInstallerPlatform}'."); | ||
| 99 | } | ||
| 100 | |||
| 101 | return !this.logger.HasLoggedErrors; | ||
| 102 | } | ||
| 103 | |||
| 104 | private bool ValidateWindowsRuntimeIdentifier(string runtimeIdentifier, out string platform) | ||
| 105 | { | ||
| 106 | platform = null; | ||
| 107 | |||
| 108 | var ridParts = runtimeIdentifier.Split('-'); | ||
| 109 | if (ridParts.Length < 2) | ||
| 110 | { | ||
| 111 | this.logger.LogError($"The RuntimeIdentifier '{runtimeIdentifier}' is not valid."); | ||
| 112 | |||
| 113 | return false; | ||
| 114 | } | ||
| 115 | |||
| 116 | var os = ridParts[0]; | ||
| 117 | |||
| 118 | if (!os.StartsWith("win", StringComparison.OrdinalIgnoreCase) || (os.Length > 3 && !Int32.TryParse(os.Substring(3), out var _))) | ||
| 119 | { | ||
| 120 | this.logger.LogError($"The RuntimeIdentifier '{runtimeIdentifier}' is not a valid Windows RuntimeIdentifier."); | ||
| 121 | |||
| 122 | return false; | ||
| 123 | } | ||
| 124 | |||
| 125 | // Ensure there is only one platform specified in the RID. | ||
| 126 | foreach (var part in ridParts.Skip(1)) | ||
| 127 | { | ||
| 128 | string platformPart; | ||
| 129 | switch (part.ToLowerInvariant()) | ||
| 130 | { | ||
| 131 | case "x86": | ||
| 132 | case "win32": | ||
| 133 | platformPart = "x86"; | ||
| 134 | break; | ||
| 135 | |||
| 136 | case "x64": | ||
| 137 | case "amd64": | ||
| 138 | platformPart = "x64"; | ||
| 139 | break; | ||
| 140 | |||
| 141 | case "arm": | ||
| 142 | case "arm32": | ||
| 143 | platformPart = "arm"; | ||
| 144 | break; | ||
| 145 | |||
| 146 | case "arm64": | ||
| 147 | platformPart = "arm64"; | ||
| 148 | break; | ||
| 149 | |||
| 150 | default: | ||
| 151 | continue; | ||
| 152 | } | ||
| 153 | |||
| 154 | if (String.IsNullOrEmpty(platform)) | ||
| 155 | { | ||
| 156 | platform = platformPart; | ||
| 157 | } | ||
| 158 | else // there can be only one platform in the RID. | ||
| 159 | { | ||
| 160 | this.logger.LogError($"The RuntimeIdentifier '{runtimeIdentifier}' specifies multiple platforms which is not supported."); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | if (String.IsNullOrEmpty(platform)) | ||
| 165 | { | ||
| 166 | this.logger.LogError($"The RuntimeIdentifier '{runtimeIdentifier}' does not specify a valid platform."); | ||
| 167 | |||
| 168 | return false; | ||
| 169 | } | ||
| 170 | |||
| 171 | return true; | ||
| 172 | } | ||
| 173 | } | ||
| 174 | } | ||
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/WixToolset.Sdk/tools/wix.targets b/src/wix/WixToolset.Sdk/tools/wix.targets index 4de5835f..bf0fdaca 100644 --- a/src/wix/WixToolset.Sdk/tools/wix.targets +++ b/src/wix/WixToolset.Sdk/tools/wix.targets | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | <UsingTask TaskName="CreateProjectReferenceDefineConstantsAndBindPaths" AssemblyFile="$(WixTasksPath)" /> | 40 | <UsingTask TaskName="CreateProjectReferenceDefineConstantsAndBindPaths" AssemblyFile="$(WixTasksPath)" /> |
| 41 | <UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" /> | 41 | <UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" /> |
| 42 | <UsingTask TaskName="ReadTracking" AssemblyFile="$(WixTasksPath)" /> | 42 | <UsingTask TaskName="ReadTracking" AssemblyFile="$(WixTasksPath)" /> |
| 43 | <UsingTask TaskName="ResolveInstallerPlatform" AssemblyFile="$(WixTasksPath)" /> | ||
| 43 | <UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)" /> | 44 | <UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)" /> |
| 44 | <UsingTask TaskName="WixBuild" AssemblyFile="$(WixTasksPath)" /> | 45 | <UsingTask TaskName="WixBuild" AssemblyFile="$(WixTasksPath)" /> |
| 45 | <UsingTask TaskName="WindowsInstallerValidation" AssemblyFile="$(WixTasksPath)" /> | 46 | <UsingTask TaskName="WindowsInstallerValidation" AssemblyFile="$(WixTasksPath)" /> |
| @@ -165,6 +166,7 @@ | |||
| 165 | 166 | ||
| 166 | <!-- Default Compiler properties. --> | 167 | <!-- Default Compiler properties. --> |
| 167 | <PropertyGroup> | 168 | <PropertyGroup> |
| 169 | <_InitialInstallerPlatform>$(InstallerPlatform)</_InitialInstallerPlatform> | ||
| 168 | <InstallerPlatform Condition=" '$(InstallerPlatform)' == '' and ('$(Platform)' == '' or '$(Platform)' == 'Win32' or '$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU') ">x86</InstallerPlatform> | 170 | <InstallerPlatform Condition=" '$(InstallerPlatform)' == '' and ('$(Platform)' == '' or '$(Platform)' == 'Win32' or '$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU') ">x86</InstallerPlatform> |
| 169 | <InstallerPlatform Condition=" '$(InstallerPlatform)' == '' ">$(Platform)</InstallerPlatform> | 171 | <InstallerPlatform Condition=" '$(InstallerPlatform)' == '' ">$(Platform)</InstallerPlatform> |
| 170 | </PropertyGroup> | 172 | </PropertyGroup> |
| @@ -178,6 +180,86 @@ | |||
| 178 | <BindVariable Include="$(WixVariables)" Condition=" '$(WixVariables)' != '' " /> | 180 | <BindVariable Include="$(WixVariables)" Condition=" '$(WixVariables)' != '' " /> |
| 179 | </ItemGroup> | 181 | </ItemGroup> |
| 180 | 182 | ||
| 183 | |||
| 184 | <!-- | ||
| 185 | *********************************************************************************************** | ||
| 186 | *********************************************************************************************** | ||
| 187 | Restore Section | ||
| 188 | *********************************************************************************************** | ||
| 189 | *********************************************************************************************** | ||
| 190 | --> | ||
| 191 | <Target | ||
| 192 | Name="WixTargetFrameworkCheck" | ||
| 193 | BeforeTargets="_LoadRestoreGraphEntryPoints;CollectPackageReferences;Restore" | ||
| 194 | Condition=" ('$(TargetFrameworks)' != '' and '$(TargetFrameworks)' != 'native') or '$(TargetFramework)' != 'native' "> | ||
| 195 | |||
| 196 | <Error | ||
| 197 | Text="The TargetFrameworks property is not supported by the WiX Toolset. Remove the TargetFrameworks property from your project and try building again. TargetFrameworks = $(TargetFrameworks)" | ||
| 198 | File="$(MSBuildProjectFullPath)" | ||
| 199 | Code="WIX9001" | ||
| 200 | Condition=" '$(TargetFrameworks)' != '' " /> | ||
| 201 | |||
| 202 | <Error | ||
| 203 | Text="The TargetFramework property is not supported by the WiX Toolset. Remove the TargetFramework property from your project and try building again. TargetFramework = $(TargetFramework)" | ||
| 204 | File="$(MSBuildProjectFullPath)" | ||
| 205 | Code="WIX9002" | ||
| 206 | Condition=" '$(TargetFramework)' != 'native' " /> | ||
| 207 | </Target> | ||
| 208 | |||
| 209 | <!-- | ||
| 210 | *********************************************************************************************** | ||
| 211 | *********************************************************************************************** | ||
| 212 | Prepare For Build Section | ||
| 213 | *********************************************************************************************** | ||
| 214 | *********************************************************************************************** | ||
| 215 | --> | ||
| 216 | <PropertyGroup> | ||
| 217 | <PrepareForBuildDependsOn> | ||
| 218 | ResolveInstallerPlatform; | ||
| 219 | $(PrepareForBuildDependsOn) | ||
| 220 | </PrepareForBuildDependsOn> | ||
| 221 | </PropertyGroup> | ||
| 222 | |||
| 223 | <!-- | ||
| 224 | ================================================================================================ | ||
| 225 | ResolveInstallerPlatform | ||
| 226 | |||
| 227 | Uses the RuntimeIdentifier to validate and update the InstallerPlatform. If the RuntimeIdentifier is | ||
| 228 | not provided, the InstallerPlatform will continue to mirror the Platform. | ||
| 229 | |||
| 230 | [IN] | ||
| 231 | $(_InitialInstallerPlatform) - Set if InstallerPlatform was explcitly defined in project. | ||
| 232 | $(InstallerPlatform) - InstallerPlatform calculated from initial value of Platform. | ||
| 233 | $(RuntimeIdentfier) - Optional runtime identifier for output. | ||
| 234 | $(Platform) - Optional platform for output. | ||
| 235 | |||
| 236 | [OUT] | ||
| 237 | $(InstallerPlatform) - InstallerPlatform resolved based on the inputs. | ||
| 238 | $(PlatformName) - Potentially updates Platform name if Platform is generic and the RuntimeIdentifier | ||
| 239 | changes the InstallerPlatform. | ||
| 240 | ================================================================================================ | ||
| 241 | --> | ||
| 242 | <Target | ||
| 243 | Name="ResolveInstallerPlatform" | ||
| 244 | Returns="$(InstallerPlatform)"> | ||
| 245 | |||
| 246 | <ResolveInstallerPlatform | ||
| 247 | RuntimeIdentifier="$(RuntimeIdentifier)" | ||
| 248 | InitialInstallerPlatform="$(_InitialInstallerPlatform)" | ||
| 249 | InstallerPlatform="$(InstallerPlatform)" | ||
| 250 | Platform="$(Platform)"> | ||
| 251 | <Output TaskParameter="ResolvedInstallerPlatform" | ||
| 252 | PropertyName="_ResolvedInstallerPlatform" /> | ||
| 253 | <Output TaskParameter="ResolvedPlatform" | ||
| 254 | PropertyName="_ResolvedPlatform" /> | ||
| 255 | </ResolveInstallerPlatform> | ||
| 256 | |||
| 257 | <PropertyGroup> | ||
| 258 | <InstallerPlatform>$(_ResolvedInstallerPlatform)</InstallerPlatform> | ||
| 259 | <PlatformName Condition=" '$(_ResolvedPlatform)' != '' and '$(PlatformName)' == '$(Platform)' ">$(_ResolvedPlatform)</PlatformName> | ||
| 260 | </PropertyGroup> | ||
| 261 | </Target> | ||
| 262 | |||
| 181 | <!-- | 263 | <!-- |
| 182 | *********************************************************************************************** | 264 | *********************************************************************************************** |
| 183 | *********************************************************************************************** | 265 | *********************************************************************************************** |
diff --git a/src/wix/test/WixToolsetTest.BuildTasks/FakeMsbuildLogger.cs b/src/wix/test/WixToolsetTest.BuildTasks/FakeMsbuildLogger.cs new file mode 100644 index 00000000..8bfb6145 --- /dev/null +++ b/src/wix/test/WixToolsetTest.BuildTasks/FakeMsbuildLogger.cs | |||
| @@ -0,0 +1,26 @@ | |||
| 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.Generic; | ||
| 6 | using WixToolset.BuildTasks; | ||
| 7 | |||
| 8 | public class FakeMsbuildLogger : ILogger | ||
| 9 | { | ||
| 10 | public List<string> Messages { get; } = new List<string>(); | ||
| 11 | |||
| 12 | public bool HasLoggedErrors { get; private set; } | ||
| 13 | |||
| 14 | public void LogError(string message) | ||
| 15 | { | ||
| 16 | this.HasLoggedErrors = true; | ||
| 17 | |||
| 18 | this.Messages.Add("Error: " + message); | ||
| 19 | } | ||
| 20 | |||
| 21 | public void LogWarning(string message) | ||
| 22 | { | ||
| 23 | this.Messages.Add("Warning: " + message); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | ||
diff --git a/src/wix/test/WixToolsetTest.BuildTasks/ResolveInstallerPlatformTaskFixture.cs b/src/wix/test/WixToolsetTest.BuildTasks/ResolveInstallerPlatformTaskFixture.cs new file mode 100644 index 00000000..0da2e146 --- /dev/null +++ b/src/wix/test/WixToolsetTest.BuildTasks/ResolveInstallerPlatformTaskFixture.cs | |||
| @@ -0,0 +1,148 @@ | |||
| 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 WixInternal.TestSupport; | ||
| 6 | using WixToolset.BuildTasks; | ||
| 7 | using Xunit; | ||
| 8 | |||
| 9 | public class ResolveInstallerPlatformTaskFixture | ||
| 10 | { | ||
| 11 | |||
| 12 | [Fact] | ||
| 13 | public void Execute_WithOnlyInstallerPlatform_ResolvesCorrectly() | ||
| 14 | { | ||
| 15 | var logger = new FakeMsbuildLogger(); | ||
| 16 | |||
| 17 | var task = new ResolveInstallerPlatform(logger) | ||
| 18 | { | ||
| 19 | InstallerPlatform = "x64", | ||
| 20 | Platform = "", | ||
| 21 | }; | ||
| 22 | |||
| 23 | Assert.True(task.Execute()); | ||
| 24 | |||
| 25 | Assert.Empty(logger.Messages); | ||
| 26 | Assert.Equal("x64", task.ResolvedInstallerPlatform); | ||
| 27 | Assert.Equal("x64", task.ResolvedPlatform); | ||
| 28 | } | ||
| 29 | |||
| 30 | [Fact] | ||
| 31 | public void Execute_WithInvalidRuntimeIdentifier_LogsErrorAndReturnsFalse() | ||
| 32 | { | ||
| 33 | var logger = new FakeMsbuildLogger(); | ||
| 34 | |||
| 35 | var task = new ResolveInstallerPlatform(logger) | ||
| 36 | { | ||
| 37 | RuntimeIdentifier = "win10", | ||
| 38 | }; | ||
| 39 | |||
| 40 | Assert.False(task.Execute()); | ||
| 41 | |||
| 42 | WixAssert.CompareLineByLine( | ||
| 43 | new[] { "Error: The RuntimeIdentifier 'win10' is not valid." }, | ||
| 44 | logger.Messages.ToArray()); | ||
| 45 | } | ||
| 46 | |||
| 47 | [Fact] | ||
| 48 | public void Execute_WithNonWindowsRuntimeIdentifier_LogsErrorAndReturnsFalse() | ||
| 49 | { | ||
| 50 | var logger = new FakeMsbuildLogger(); | ||
| 51 | |||
| 52 | var task = new ResolveInstallerPlatform(logger) | ||
| 53 | { | ||
| 54 | RuntimeIdentifier = "linux-x64", | ||
| 55 | }; | ||
| 56 | |||
| 57 | Assert.False(task.Execute()); | ||
| 58 | |||
| 59 | WixAssert.CompareLineByLine( | ||
| 60 | new[] { "Error: The RuntimeIdentifier 'linux-x64' is not a valid Windows RuntimeIdentifier." }, | ||
| 61 | logger.Messages.ToArray()); | ||
| 62 | } | ||
| 63 | |||
| 64 | [Fact] | ||
| 65 | public void Execute_WithRuntimeIdentifierSpecifyingMultiplePlatforms_LogsErrorAndReturnsFalse() | ||
| 66 | { | ||
| 67 | var logger = new FakeMsbuildLogger(); | ||
| 68 | |||
| 69 | var task = new ResolveInstallerPlatform(logger) | ||
| 70 | { | ||
| 71 | RuntimeIdentifier = "win10-x64-arm64", | ||
| 72 | Platform = "", | ||
| 73 | }; | ||
| 74 | |||
| 75 | Assert.False(task.Execute()); | ||
| 76 | |||
| 77 | WixAssert.CompareLineByLine( | ||
| 78 | new[] { "Error: The RuntimeIdentifier 'win10-x64-arm64' specifies multiple platforms which is not supported." }, | ||
| 79 | logger.Messages.ToArray()); | ||
| 80 | |||
| 81 | // Despite the logged error the platform resolver sets the first platform it finds. | ||
| 82 | Assert.Equal("x64", task.ResolvedInstallerPlatform); | ||
| 83 | Assert.Equal("x64", task.ResolvedPlatform); | ||
| 84 | } | ||
| 85 | |||
| 86 | [Fact] | ||
| 87 | public void Execute_WithRuntimeIdentifierAndInitialInstallerPlatformMismatch_LogsErrorAndReturnsFalse() | ||
| 88 | { | ||
| 89 | var logger = new FakeMsbuildLogger(); | ||
| 90 | |||
| 91 | var task = new ResolveInstallerPlatform(logger) | ||
| 92 | { | ||
| 93 | RuntimeIdentifier = "win10-x64", | ||
| 94 | InitialInstallerPlatform = "x86", | ||
| 95 | Platform = "", | ||
| 96 | }; | ||
| 97 | |||
| 98 | Assert.False(task.Execute()); | ||
| 99 | |||
| 100 | WixAssert.CompareLineByLine( | ||
| 101 | new[] { "Error: The RuntimeIdentifier 'win10-x64' resolves to platform 'x64', which conflicts with the provided InstallerPlatform 'x86'." }, | ||
| 102 | logger.Messages.ToArray()); | ||
| 103 | |||
| 104 | Assert.Null(task.ResolvedInstallerPlatform); | ||
| 105 | Assert.Null(task.ResolvedPlatform); | ||
| 106 | } | ||
| 107 | |||
| 108 | [Fact] | ||
| 109 | public void Execute_WithRuntimeIdentifierAndInitialInstallerPlatformMatches_ResolvesToPlatform() | ||
| 110 | { | ||
| 111 | var logger = new FakeMsbuildLogger(); | ||
| 112 | |||
| 113 | var task = new ResolveInstallerPlatform(logger) | ||
| 114 | { | ||
| 115 | RuntimeIdentifier = "win10-x64", | ||
| 116 | InitialInstallerPlatform = "x64", | ||
| 117 | Platform = "", | ||
| 118 | }; | ||
| 119 | |||
| 120 | Assert.True(task.Execute()); | ||
| 121 | |||
| 122 | Assert.Empty(logger.Messages); | ||
| 123 | Assert.Equal("x64", task.ResolvedInstallerPlatform); | ||
| 124 | Assert.Equal("x64", task.ResolvedPlatform); | ||
| 125 | } | ||
| 126 | |||
| 127 | [Fact] | ||
| 128 | public void Execute_WithMismatchedPlatformProperty_LogsWarningButReturnsTrue() | ||
| 129 | { | ||
| 130 | var logger = new FakeMsbuildLogger(); | ||
| 131 | |||
| 132 | var task = new ResolveInstallerPlatform(logger) | ||
| 133 | { | ||
| 134 | RuntimeIdentifier = "win10-x64", | ||
| 135 | Platform = "x86", | ||
| 136 | }; | ||
| 137 | |||
| 138 | Assert.True(task.Execute()); | ||
| 139 | |||
| 140 | WixAssert.CompareLineByLine( | ||
| 141 | new[] { "Warning: The provided Platform 'x86' does not match the resolved InstallerPlatform 'x64'. The output will be built using 'x64'." }, | ||
| 142 | logger.Messages.ToArray()); | ||
| 143 | |||
| 144 | Assert.Equal("x64", task.ResolvedInstallerPlatform); | ||
| 145 | Assert.Null(task.ResolvedPlatform); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | } | ||
diff --git a/src/wix/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.v3.ncrunchproject b/src/wix/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.v3.ncrunchproject index f1d03cd7..78596c6c 100644 --- a/src/wix/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.v3.ncrunchproject +++ b/src/wix/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.v3.ncrunchproject | |||
| @@ -2,7 +2,9 @@ | |||
| 2 | <Settings> | 2 | <Settings> |
| 3 | <HiddenComponentWarnings /> | 3 | <HiddenComponentWarnings /> |
| 4 | <IgnoredTests> | 4 | <IgnoredTests> |
| 5 | <AllTestsSelector /> | 5 | <FixtureTestSelector> |
| 6 | <FixtureName>WixToolsetTest.BuildTasks.WixBuildTaskFixture</FixtureName> | ||
| 7 | </FixtureTestSelector> | ||
| 6 | </IgnoredTests> | 8 | </IgnoredTests> |
| 7 | </Settings> | 9 | </Settings> |
| 8 | </ProjectConfiguration> \ No newline at end of file | 10 | </ProjectConfiguration> \ No newline at end of file |
diff --git a/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs b/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs index ba5093ac..408bab2f 100644 --- a/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs +++ b/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs | |||
| @@ -12,6 +12,8 @@ namespace WixToolsetTest.Sdk | |||
| 12 | using System.Linq; | 12 | using System.Linq; |
| 13 | using Microsoft.VisualStudio.TestTools.UnitTesting; | 13 | using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 14 | using WixInternal.MSTestSupport; | 14 | using WixInternal.MSTestSupport; |
| 15 | using WixToolset.Data; | ||
| 16 | using WixToolset.Data.Symbols; | ||
| 15 | 17 | ||
| 16 | [TestClass] | 18 | [TestClass] |
| 17 | public class MsbuildFixture | 19 | public class MsbuildFixture |
| @@ -648,6 +650,42 @@ namespace WixToolsetTest.Sdk | |||
| 648 | [DataRow(BuildSystem.DotNetCoreSdk)] | 650 | [DataRow(BuildSystem.DotNetCoreSdk)] |
| 649 | [DataRow(BuildSystem.MSBuild)] | 651 | [DataRow(BuildSystem.MSBuild)] |
| 650 | [DataRow(BuildSystem.MSBuild64)] | 652 | [DataRow(BuildSystem.MSBuild64)] |
| 653 | public void CanBuildWixlibWithRid(BuildSystem buildSystem) | ||
| 654 | { | ||
| 655 | var sourceFolder = TestData.Get(@"TestData", "Wixlib", "WithBadFiles"); | ||
| 656 | |||
| 657 | using (var fs = new TestDataFolderFileSystem()) | ||
| 658 | { | ||
| 659 | fs.Initialize(sourceFolder); | ||
| 660 | var baseFolder = fs.BaseFolder; | ||
| 661 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 662 | var projectPath = Path.Combine(baseFolder, "SkipBadFiles.wixproj"); | ||
| 663 | |||
| 664 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] | ||
| 665 | { | ||
| 666 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath), | ||
| 667 | "-p:RuntimeIdentifier=win-arm64", | ||
| 668 | }); | ||
| 669 | result.AssertSuccess(); | ||
| 670 | |||
| 671 | var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem); | ||
| 672 | WixAssert.Single(wixBuildCommands); | ||
| 673 | |||
| 674 | var wixlib = Intermediate.Load(Path.Combine(binFolder, "Release", "SkipBadFiles.wixlib")); | ||
| 675 | var properties = wixlib.Sections.SelectMany(s => s.Symbols).OfType<PropertySymbol>().ToList(); | ||
| 676 | WixAssert.CompareLineByLine( | ||
| 677 | [ | ||
| 678 | "Property sysBUILDARCH=arm64", | ||
| 679 | "Property Platform=arm64", | ||
| 680 | "Property InstallerPlatform=arm64" | ||
| 681 | ], [.. properties.Select(p => $"Property {p.Id.Id}={p.Value}")]); | ||
| 682 | } | ||
| 683 | } | ||
| 684 | |||
| 685 | [TestMethod] | ||
| 686 | [DataRow(BuildSystem.DotNetCoreSdk)] | ||
| 687 | [DataRow(BuildSystem.MSBuild)] | ||
| 688 | [DataRow(BuildSystem.MSBuild64)] | ||
| 651 | public void CanBuildPackageIncludingSimpleWixlib(BuildSystem buildSystem) | 689 | public void CanBuildPackageIncludingSimpleWixlib(BuildSystem buildSystem) |
| 652 | { | 690 | { |
| 653 | var sourceFolder = TestData.Get(@"TestData", "Wixlib"); | 691 | var sourceFolder = TestData.Get(@"TestData", "Wixlib"); |
| @@ -779,6 +817,36 @@ namespace WixToolsetTest.Sdk | |||
| 779 | [DataRow(BuildSystem.DotNetCoreSdk)] | 817 | [DataRow(BuildSystem.DotNetCoreSdk)] |
| 780 | [DataRow(BuildSystem.MSBuild)] | 818 | [DataRow(BuildSystem.MSBuild)] |
| 781 | [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)] | ||
| 782 | public void CanBuildMultiTargetingWixlibUsingRidsWithReleaseAndDebug(BuildSystem buildSystem) | 850 | public void CanBuildMultiTargetingWixlibUsingRidsWithReleaseAndDebug(BuildSystem buildSystem) |
| 783 | { | 851 | { |
| 784 | var sourceFolder = TestData.Get(@"TestData", "MultiTargetingWixlib"); | 852 | var sourceFolder = TestData.Get(@"TestData", "MultiTargetingWixlib"); |
| @@ -850,6 +918,64 @@ namespace WixToolsetTest.Sdk | |||
| 850 | [DataRow(BuildSystem.DotNetCoreSdk)] | 918 | [DataRow(BuildSystem.DotNetCoreSdk)] |
| 851 | [DataRow(BuildSystem.MSBuild)] | 919 | [DataRow(BuildSystem.MSBuild)] |
| 852 | [DataRow(BuildSystem.MSBuild64)] | 920 | [DataRow(BuildSystem.MSBuild64)] |
| 921 | public void CannotBuildWithTargetFrameworks(BuildSystem buildSystem) | ||
| 922 | { | ||
| 923 | var sourceFolder = TestData.Get(@"TestData", "WithTargetFrameworkError"); | ||
| 924 | |||
| 925 | using (var fs = new TestDataFolderFileSystem()) | ||
| 926 | { | ||
| 927 | fs.Initialize(sourceFolder); | ||
| 928 | var baseFolder = Path.Combine(fs.BaseFolder, "TargetFrameworkError"); | ||
| 929 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 930 | var filesFolder = Path.Combine(binFolder, "Release", @"PFiles\"); | ||
| 931 | var projectPath = Path.Combine(baseFolder, "TargetFrameworkError.wixproj"); | ||
| 932 | |||
| 933 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, [ | ||
| 934 | "-Restore", | ||
| 935 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath) | ||
| 936 | ]); | ||
| 937 | |||
| 938 | var errors = GetDistinctErrorMessages(result.Output, baseFolder); | ||
| 939 | WixAssert.CompareLineByLine(new[] | ||
| 940 | { | ||
| 941 | @"<basefolder>\TargetFrameworkError.wixproj : error WIX9002: The TargetFramework property is not supported by the WiX Toolset. Remove the TargetFramework property from your project and try building again. TargetFramework = net472", | ||
| 942 | }, errors); | ||
| 943 | } | ||
| 944 | } | ||
| 945 | |||
| 946 | [TestMethod] | ||
| 947 | [DataRow(BuildSystem.DotNetCoreSdk)] | ||
| 948 | [DataRow(BuildSystem.MSBuild)] | ||
| 949 | [DataRow(BuildSystem.MSBuild64)] | ||
| 950 | public void CannotBuildWithTargetFramework(BuildSystem buildSystem) | ||
| 951 | { | ||
| 952 | var sourceFolder = TestData.Get(@"TestData", "WithTargetFrameworkError"); | ||
| 953 | |||
| 954 | using (var fs = new TestDataFolderFileSystem()) | ||
| 955 | { | ||
| 956 | fs.Initialize(sourceFolder); | ||
| 957 | var baseFolder = Path.Combine(fs.BaseFolder, "TargetFrameworksError"); | ||
| 958 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 959 | var filesFolder = Path.Combine(binFolder, "Release", @"PFiles\"); | ||
| 960 | var projectPath = Path.Combine(baseFolder, "TargetFrameworksError.wixproj"); | ||
| 961 | |||
| 962 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, [ | ||
| 963 | "-Restore", | ||
| 964 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath) | ||
| 965 | ]); | ||
| 966 | |||
| 967 | var errors = GetDistinctErrorMessages(result.Output, baseFolder); | ||
| 968 | WixAssert.CompareLineByLine(new[] | ||
| 969 | { | ||
| 970 | @"<basefolder>\TargetFrameworksError.wixproj : error WIX9001: The TargetFrameworks property is not supported by the WiX Toolset. Remove the TargetFrameworks property from your project and try building again. TargetFrameworks = net8.0", | ||
| 971 | }, errors); | ||
| 972 | } | ||
| 973 | } | ||
| 974 | |||
| 975 | [TestMethod] | ||
| 976 | [DataRow(BuildSystem.DotNetCoreSdk)] | ||
| 977 | [DataRow(BuildSystem.MSBuild)] | ||
| 978 | [DataRow(BuildSystem.MSBuild64)] | ||
| 853 | public void CanBuildWithWarningWhenExtensionIsMissing(BuildSystem buildSystem) | 979 | public void CanBuildWithWarningWhenExtensionIsMissing(BuildSystem buildSystem) |
| 854 | { | 980 | { |
| 855 | var sourceFolder = TestData.Get(@"TestData", "WixlibMissingExtension"); | 981 | var sourceFolder = TestData.Get(@"TestData", "WixlibMissingExtension"); |
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> | ||
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworkError/Package.wxs b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworkError/Package.wxs new file mode 100644 index 00000000..ac49711f --- /dev/null +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworkError/Package.wxs | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Id="WixTest.Package" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation"> | ||
| 3 | <File Source="doesnotexist.txt" /> | ||
| 4 | </Package> | ||
| 5 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworkError/TargetFrameworkError.wixproj b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworkError/TargetFrameworkError.wixproj new file mode 100644 index 00000000..3b6e1300 --- /dev/null +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworkError/TargetFrameworkError.wixproj | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | <Project> | ||
| 2 | <Import Project="$(WixMSBuildProps)" /> | ||
| 3 | |||
| 4 | <PropertyGroup> | ||
| 5 | <TargetFramework>net472</TargetFramework> | ||
| 6 | </PropertyGroup> | ||
| 7 | |||
| 8 | <Import Project="$(WixTargetsPath)" /> | ||
| 9 | </Project> | ||
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworksError/Package.wxs b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworksError/Package.wxs new file mode 100644 index 00000000..ac49711f --- /dev/null +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworksError/Package.wxs | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Id="WixTest.Package" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation"> | ||
| 3 | <File Source="doesnotexist.txt" /> | ||
| 4 | </Package> | ||
| 5 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworksError/TargetFrameworksError.wixproj b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworksError/TargetFrameworksError.wixproj new file mode 100644 index 00000000..b3f4777f --- /dev/null +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/WithTargetFrameworkError/TargetFrameworksError/TargetFrameworksError.wixproj | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | <Project> | ||
| 2 | <Import Project="$(WixMSBuildProps)" /> | ||
| 3 | |||
| 4 | <PropertyGroup> | ||
| 5 | <TargetFrameworks>net8.0</TargetFrameworks> | ||
| 6 | </PropertyGroup> | ||
| 7 | |||
| 8 | <Import Project="$(WixTargetsPath)" /> | ||
| 9 | </Project> | ||
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/Wixlib/WithBadFiles/Library.wxs b/src/wix/test/WixToolsetTest.Sdk/TestData/Wixlib/WithBadFiles/Library.wxs index bcf79a1f..f946fcc6 100644 --- a/src/wix/test/WixToolsetTest.Sdk/TestData/Wixlib/WithBadFiles/Library.wxs +++ b/src/wix/test/WixToolsetTest.Sdk/TestData/Wixlib/WithBadFiles/Library.wxs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
| 2 | <Fragment> | 2 | <Fragment> |
| 3 | <StandardDirectory Id="ProgramFilesFolder"> | 3 | <Property Id="sysBUILDARCH" Value="$(sys.BUILDARCH)" /> |
| 4 | <Directory Id="WixLibFolder" /> | 4 | <Property Id="Platform" Value="$(Platform)" /> |
| 5 | </StandardDirectory> | 5 | <Property Id="InstallerPlatform" Value="$(InstallerPlatform)" /> |
| 6 | </Fragment> | 6 | </Fragment> |
| 7 | </Wix> | 7 | </Wix> |
