From 321c30138c82390ea5ad6b0a612dff294203a877 Mon Sep 17 00:00:00 2001 From: StefanStojanovic Date: Tue, 25 Oct 2022 22:40:36 +0200 Subject: Add NetFx .NET compatibility check for MSI (#262) Adds new custom element in NetFx extension for running NetCoreCheck.exe tool from within the MSI installer - ``. The checks are run before evaluating launch conditions, so their results can be used in those conditions. There is no limitation on the number of checks that can be run, so installer may query various runtimes on different platforms and versions and with different roll forward policies. Fixes https://github.com/wixtoolset/issues/issues/6264 --- src/ext/NetFx/ca/netfxca.cpp | 144 ++++++++++++++ src/ext/NetFx/ca/netfxca.def | 1 + src/ext/NetFx/ca/netfxca.vcxproj | 2 +- src/ext/NetFx/ca/precomp.h | 3 + .../WixToolsetTest.Netfx/NetfxExtensionFixture.cs | 12 ++ src/ext/NetFx/wixext/NetFxCompiler.cs | 213 ++++++++++++++++++++- src/ext/NetFx/wixext/NetFxExtensionData.cs | 2 + src/ext/NetFx/wixext/NetfxTableDefinitions.cs | 16 ++ .../Symbols/NetFxDotNetCompatibilityCheckSymbol.cs | 79 ++++++++ .../NetFx/wixext/Symbols/NetfxSymbolDefinitions.cs | 6 + src/ext/NetFx/wixlib/NetFxExtension_Platform.wxi | 9 + src/ext/NetFx/wixlib/netfx.wixproj | 6 + .../SetBuildNumber/Directory.Packages.props.pp | 6 + 13 files changed, 496 insertions(+), 3 deletions(-) create mode 100644 src/ext/NetFx/wixext/Symbols/NetFxDotNetCompatibilityCheckSymbol.cs diff --git a/src/ext/NetFx/ca/netfxca.cpp b/src/ext/NetFx/ca/netfxca.cpp index f0704790..cd086c53 100644 --- a/src/ext/NetFx/ca/netfxca.cpp +++ b/src/ext/NetFx/ca/netfxca.cpp @@ -36,6 +36,10 @@ LPCWSTR vcsNgenStrongName = L"SELECT `Name`,`Value` FROM `MsiAssemblyName` WHERE `Component_`=?"; enum eNgenStrongName { ngsnName = 1, ngsnValue }; +LPCWSTR vscDotNetCompatibilityCheckQuery = + L"SELECT `Platform`, `RuntimeType`, `Version`, `RollForward`, `Property` FROM `Wix4NetFxDotNetCheck`"; +enum eDotNetCompatibilityCheckQuery { platform = 1, runtimeType, version, rollForward, property }; + // Searches subdirectories of the given path for the highest version of ngen.exe available static HRESULT GetNgenVersion( __in LPWSTR pwzParentPath, @@ -500,6 +504,15 @@ extern "C" UINT __stdcall SchedNetFx( hr = WcaInitialize(hInstall, "SchedNetFx"); ExitOnFailure(hr, "failed to initialize"); + // If Wix4NetFxNativeImage table doesn't exist skip the rest of this custom action + hr = WcaTableExists(L"Wix4NetFxNativeImage"); + if (S_FALSE == hr) + { + hr = S_OK; + ExitFunction(); + } + ExitOnFailure(hr, "failed to check if table Wix4NetFxNativeImage exists"); + hr = GetNgenPath(&pwz32Ngen, FALSE); f32NgenExeExists = SUCCEEDED(hr); if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr) @@ -879,3 +892,134 @@ LExit: return WcaFinalize(er); } +/****************************************************************** + DotNetCompatibilityCheck - entry point for NetFx Custom Action + +*******************************************************************/ +extern "C" UINT __stdcall DotNetCompatibilityCheck( + __in MSIHANDLE hInstall + ) +{ +// AssertSz(FALSE, "debug DotNetCompatibilityCheck"); + + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + PMSIHANDLE hView = NULL; + PMSIHANDLE hRec = NULL; + LPWSTR pwzPlatform = NULL; + LPWSTR pwzNetCoreCheckBinaryId = NULL; + LPWSTR pwzNetCoreCheckDirectoryName = NULL; + LPWSTR pwzNetCoreCheckDirectoryPath = NULL; + LPWSTR pwzNetCoreCheckFilePath = NULL; + LPWSTR pwzRuntimeType = NULL; + LPWSTR pwzVersion = NULL; + LPWSTR pwzRollForward = NULL; + LPWSTR pwzProperty = NULL; + LPWSTR pwzCommandLine = NULL; + HANDLE hProcess = NULL; + DWORD dwExitCode = 0; + + // Initialize + hr = WcaInitialize(hInstall, "DotNetCompatibilityCheck"); + ExitOnFailure(hr, "failed to initialize"); + + // If Wix4NetFxDotNetCheck table doesn't exist skip the rest of this custom action + hr = WcaTableExists(L"Wix4NetFxDotNetCheck"); + if (S_FALSE == hr) + { + hr = S_OK; + ExitFunction(); + } + ExitOnFailure(hr, "failed to check if table Wix4NetFxDotNetCheck exists"); + + // Open view on .NET compatibility check table + hr = WcaOpenExecuteView(vscDotNetCompatibilityCheckQuery, &hView); + ExitOnFailure(hr, "failed to open view on Wix4NetFxDotNetCheck table"); + + // Go through all records and run NetCorCheck.exe for each + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + // Extract NetCoreCheck.exe for platform to temp directory + hr = WcaGetRecordString(hRec, platform, &pwzPlatform); + ExitOnFailure(hr, "failed to get Wix4NetFxDotNetCheck.Platform"); + + hr = StrAllocFormatted(&pwzNetCoreCheckBinaryId, L"Wix4NetCheck_%ls", pwzPlatform); + ExitOnFailure(hr, "failed to get NetCoreCheck binary id for platform %ls", pwzPlatform); + + hr = GuidCreate(&pwzNetCoreCheckDirectoryName); + ExitOnFailure(hr, "failed to set NetCoreCheck directory name"); + + hr = PathCreateTempDirectory(NULL, pwzNetCoreCheckDirectoryName, 1, &pwzNetCoreCheckDirectoryPath); + ExitOnFailure(hr, "failed to make NetCoreCheck directory path for name %ls", pwzNetCoreCheckDirectoryName); + + hr = StrAllocFormatted(&pwzNetCoreCheckFilePath, L"%lsNetCoreCheck.exe", pwzNetCoreCheckDirectoryPath); + ExitOnFailure(hr, "failed to set NetCoreCheck file path for directory %ls", pwzNetCoreCheckDirectoryPath); + + hr = WcaExtractBinaryToFile(pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath); + ExitOnFailure(hr, "failed to extract NetCoreCheck from binary '%ls' to file %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath); + + // Read all NetCoreCheck.exe parameters and property + hr = WcaGetRecordString(hRec, runtimeType, &pwzRuntimeType); + ExitOnFailure(hr, "failed to get Wix4NetFxDotNetCheck.RuntimeType"); + + hr = WcaGetRecordString(hRec, version, &pwzVersion); + ExitOnFailure(hr, "failed to get Wix4NetFxDotNetCheck.Version"); + + hr = WcaGetRecordString(hRec, rollForward, &pwzRollForward); + ExitOnFailure(hr, "failed to get Wix4NetFxDotNetCheck.RollForward"); + + hr = WcaGetRecordString(hRec, property, &pwzProperty); + ExitOnFailure(hr, "failed to get Wix4NetFxDotNetCheck.Property"); + + // Run NetCoreCheck.exe and store its result in property + hr = StrAllocFormatted(&pwzCommandLine, L"-n %ls -v %ls -r %ls", pwzRuntimeType, pwzVersion, pwzRollForward); + ExitOnFailure(hr, "failed to set NetCoreCheck command line"); + WcaLog(LOGMSG_VERBOSE, "Command: %ls %ls", pwzNetCoreCheckFilePath, pwzCommandLine); + + hr = ProcExec(pwzNetCoreCheckFilePath, pwzCommandLine, SW_HIDE, &hProcess); + ExitOnFailure(hr, "failed to run NetCoreCheck from binary '%ls' with command line: %ls %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath, pwzCommandLine); + + hr = ProcWaitForCompletion(hProcess, INFINITE, &dwExitCode); + ExitOnFailure(hr, "failed to finish NetCoreCheck from binary '%ls' with command line: %ls %ls", pwzNetCoreCheckBinaryId, pwzNetCoreCheckFilePath, pwzCommandLine); + WcaLog(LOGMSG_VERBOSE, "Exit code: %lu", dwExitCode); + ReleaseHandle(hProcess); + + hr = WcaSetIntProperty(pwzProperty, dwExitCode); + ExitOnFailure(hr, "failed to set NetCoreCheck result in %ls", pwzProperty); + + // Delete extracted NetCoreCheck.exe + DirEnsureDelete(pwzNetCoreCheckDirectoryPath, TRUE, TRUE); + } + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "failed while looping through all dot net compatibility checks"); + +LExit: + // Delete extracted NetCoreCheck.exe + if (NULL != pwzNetCoreCheckDirectoryPath) + { + DirEnsureDelete(pwzNetCoreCheckDirectoryPath, TRUE, TRUE); + } + + // Release allocated resources + ReleaseStr(pwzPlatform); + ReleaseStr(pwzNetCoreCheckBinaryId); + ReleaseStr(pwzNetCoreCheckDirectoryName); + ReleaseStr(pwzNetCoreCheckDirectoryPath); + ReleaseStr(pwzNetCoreCheckFilePath); + ReleaseStr(pwzRuntimeType); + ReleaseStr(pwzVersion); + ReleaseStr(pwzRollForward); + ReleaseStr(pwzProperty); + ReleaseStr(pwzCommandLine); + ReleaseHandle(hProcess); + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} diff --git a/src/ext/NetFx/ca/netfxca.def b/src/ext/NetFx/ca/netfxca.def index c1d01f5f..3b930756 100644 --- a/src/ext/NetFx/ca/netfxca.def +++ b/src/ext/NetFx/ca/netfxca.def @@ -6,3 +6,4 @@ LIBRARY "netfxca" EXPORTS SchedNetFx ExecNetFx + DotNetCompatibilityCheck diff --git a/src/ext/NetFx/ca/netfxca.vcxproj b/src/ext/NetFx/ca/netfxca.vcxproj index 93276ea1..0158a656 100644 --- a/src/ext/NetFx/ca/netfxca.vcxproj +++ b/src/ext/NetFx/ca/netfxca.vcxproj @@ -42,7 +42,7 @@ - msi.lib + msi.lib;rpcrt4.lib diff --git a/src/ext/NetFx/ca/precomp.h b/src/ext/NetFx/ca/precomp.h index f7b537ed..db618bce 100644 --- a/src/ext/NetFx/ca/precomp.h +++ b/src/ext/NetFx/ca/precomp.h @@ -10,6 +10,9 @@ #include "fileutil.h" #include "strutil.h" #include "pathutil.h" +#include "procutil.h" +#include "dirutil.h" +#include "guidutil.h" #include "caDecor.h" #include "cost.h" diff --git a/src/ext/NetFx/test/WixToolsetTest.Netfx/NetfxExtensionFixture.cs b/src/ext/NetFx/test/WixToolsetTest.Netfx/NetfxExtensionFixture.cs index 6a75f30f..a03d47d6 100644 --- a/src/ext/NetFx/test/WixToolsetTest.Netfx/NetfxExtensionFixture.cs +++ b/src/ext/NetFx/test/WixToolsetTest.Netfx/NetfxExtensionFixture.cs @@ -85,7 +85,11 @@ namespace WixToolsetTest.Netfx var results = build.BuildAndQuery(Build, "Binary", "CustomAction", "Wix4NetFxNativeImage"); WixAssert.CompareLineByLine(new[] { + "Binary:Wix4NetCheck_arm64\t[Binary data]", + "Binary:Wix4NetCheck_x64\t[Binary data]", + "Binary:Wix4NetCheck_x86\t[Binary data]", "Binary:Wix4NetFxCA_X86\t[Binary data]", + "CustomAction:Wix4NetFxDotNetCompatibilityCheck_X86\t1\tWix4NetFxCA_X86\tDotNetCompatibilityCheck\t", "CustomAction:Wix4NetFxExecuteNativeImageCommitInstall_X86\t3649\tWix4NetFxCA_X86\tExecNetFx\t", "CustomAction:Wix4NetFxExecuteNativeImageCommitUninstall_X86\t3649\tWix4NetFxCA_X86\tExecNetFx\t", "CustomAction:Wix4NetFxExecuteNativeImageInstall_X86\t3137\tWix4NetFxCA_X86\tExecNetFx\t", @@ -104,7 +108,11 @@ namespace WixToolsetTest.Netfx var results = build.BuildAndQuery(BuildX64, "Binary", "CustomAction", "Wix4NetFxNativeImage"); WixAssert.CompareLineByLine(new[] { + "Binary:Wix4NetCheck_arm64\t[Binary data]", + "Binary:Wix4NetCheck_x64\t[Binary data]", + "Binary:Wix4NetCheck_x86\t[Binary data]", "Binary:Wix4NetFxCA_X64\t[Binary data]", + "CustomAction:Wix4NetFxDotNetCompatibilityCheck_X64\t1\tWix4NetFxCA_X64\tDotNetCompatibilityCheck\t", "CustomAction:Wix4NetFxExecuteNativeImageCommitInstall_X64\t3649\tWix4NetFxCA_X64\tExecNetFx\t", "CustomAction:Wix4NetFxExecuteNativeImageCommitUninstall_X64\t3649\tWix4NetFxCA_X64\tExecNetFx\t", "CustomAction:Wix4NetFxExecuteNativeImageInstall_X64\t3137\tWix4NetFxCA_X64\tExecNetFx\t", @@ -123,7 +131,11 @@ namespace WixToolsetTest.Netfx var results = build.BuildAndQuery(BuildARM64, "Binary", "CustomAction", "Wix4NetFxNativeImage"); WixAssert.CompareLineByLine(new[] { + "Binary:Wix4NetCheck_arm64\t[Binary data]", + "Binary:Wix4NetCheck_x64\t[Binary data]", + "Binary:Wix4NetCheck_x86\t[Binary data]", "Binary:Wix4NetFxCA_A64\t[Binary data]", + "CustomAction:Wix4NetFxDotNetCompatibilityCheck_A64\t1\tWix4NetFxCA_A64\tDotNetCompatibilityCheck\t", "CustomAction:Wix4NetFxExecuteNativeImageCommitInstall_A64\t3649\tWix4NetFxCA_A64\tExecNetFx\t", "CustomAction:Wix4NetFxExecuteNativeImageCommitUninstall_A64\t3649\tWix4NetFxCA_A64\tExecNetFx\t", "CustomAction:Wix4NetFxExecuteNativeImageInstall_A64\t3137\tWix4NetFxCA_A64\tExecNetFx\t", diff --git a/src/ext/NetFx/wixext/NetFxCompiler.cs b/src/ext/NetFx/wixext/NetFxCompiler.cs index 739618e9..f3c91918 100644 --- a/src/ext/NetFx/wixext/NetFxCompiler.cs +++ b/src/ext/NetFx/wixext/NetFxCompiler.cs @@ -40,7 +40,6 @@ namespace WixToolset.Netfx break; } break; - case "Bundle": case "Fragment": switch (element.Name.LocalName) { @@ -50,8 +49,45 @@ namespace WixToolset.Netfx case "DotNetCoreSearchRef": this.ParseDotNetCoreSearchRefElement(intermediate, section, element); break; + case "DotNetCompatibilityCheck": + this.ParseDotNetCompatibilityCheckElement(intermediate, section, element); + break; + case "DotNetCompatibilityCheckRef": + this.ParseDotNetCompatibilityCheckRefElement(intermediate, section, element); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + case "Bundle": + switch (element.Name.LocalName) + { + case "DotNetCoreSearch": + this.ParseDotNetCoreSearchElement(intermediate, section, element); + break; + case "DotNetCoreSearchRef": + this.ParseDotNetCoreSearchRefElement(intermediate, section, element); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + case "Package": + case "Module": + switch (element.Name.LocalName) + { + case "DotNetCompatibilityCheck": + this.ParseDotNetCompatibilityCheckElement(intermediate, section, element); + break; + case "DotNetCompatibilityCheckRef": + this.ParseDotNetCompatibilityCheckRefElement(intermediate, section, element); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; } - break; default: this.ParseHelper.UnexpectedElement(parentElement, element); @@ -325,5 +361,178 @@ namespace WixToolset.Netfx }); } } + + /// + /// Parses a DotNetCompatibilityCheck element. + /// + /// The element to parse. + private void ParseDotNetCompatibilityCheckElement(Intermediate intermediate, IntermediateSection section, XElement element) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + string property = null; + string runtimeType = null; + string platform = null; + string version = null; + string rollForward = "Minor"; + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Property": + property = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "RuntimeType": + runtimeType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (runtimeType.ToLower()) + { + case "aspnet": + runtimeType = "Microsoft.AspNetCore.App"; + break; + case "desktop": + runtimeType = "Microsoft.WindowsDesktop.App"; + break; + case "core": + runtimeType = "Microsoft.NETCore.App"; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, runtimeType, "aspnet", "desktop", "core")); + break; + } + break; + case "Platform": + platform = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (platform.ToLower()) + { + case "x86": + case "x64": + case "arm64": + platform = platform.ToLower(); + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, platform, "x86", "x64", "arm64")); + break; + } + break; + case "Version": + version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + case "RollForward": + rollForward = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (rollForward.ToLower()) + { + case "latestmajor": + rollForward = "LatestMajor"; + break; + case "major": + rollForward = "Major"; + break; + case "latestminor": + rollForward = "LatestMinor"; + break; + case "minor": + rollForward = "Minor"; + break; + case "latestpatch": + rollForward = "LatestPatch"; + break; + case "disable": + rollForward = "Disable"; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, rollForward, "latestmajor", "major", "latestminor", "minor", "latestpatch", "disable")); + break; + } + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("ndncc", property, runtimeType, platform, version); + } + + if (String.IsNullOrEmpty(property)) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Property")); + } + + if (String.IsNullOrEmpty(runtimeType)) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "RuntimeType")); + } + + if (String.IsNullOrEmpty(platform)) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Platform")); + } + + if (String.IsNullOrEmpty(version)) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Version")); + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4NetFxDotNetCompatibilityCheck", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + + if (!this.Messaging.EncounteredError) + { + section.AddSymbol(new NetFxDotNetCompatibilityCheckSymbol(sourceLineNumbers, id) + { + RuntimeType = runtimeType, + Platform = platform, + Version = version, + RollForward = rollForward, + Property = property, + }); + } + } + + /// + /// Parses a DotNetCompatibilityCheckRef element. + /// + /// The element to parse. + private void ParseDotNetCompatibilityCheckRefElement(Intermediate intermediate, IntermediateSection section, XElement element) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + var refId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, NetfxSymbolDefinitions.NetFxDotNetCompatibilityCheck, refId); + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + } } } diff --git a/src/ext/NetFx/wixext/NetFxExtensionData.cs b/src/ext/NetFx/wixext/NetFxExtensionData.cs index 61d618cf..8dd9e003 100644 --- a/src/ext/NetFx/wixext/NetFxExtensionData.cs +++ b/src/ext/NetFx/wixext/NetFxExtensionData.cs @@ -10,6 +10,8 @@ namespace WixToolset.Netfx /// public sealed class NetfxExtensionData : BaseExtensionData { + public override string DefaultCulture => "en-US"; + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) { symbolDefinition = NetfxSymbolDefinitions.ByName(name); diff --git a/src/ext/NetFx/wixext/NetfxTableDefinitions.cs b/src/ext/NetFx/wixext/NetfxTableDefinitions.cs index 57e35323..6be1abe7 100644 --- a/src/ext/NetFx/wixext/NetfxTableDefinitions.cs +++ b/src/ext/NetFx/wixext/NetfxTableDefinitions.cs @@ -22,9 +22,25 @@ namespace WixToolset.Netfx symbolIdIsPrimaryKey: true ); + public static readonly TableDefinition NetFxDotNetCompatibilityCheck = new TableDefinition( + "Wix4NetFxDotNetCheck", + NetfxSymbolDefinitions.NetFxDotNetCompatibilityCheck, + new[] + { + new ColumnDefinition("NetFxDotNetCompatibilityCheck", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("RuntimeType", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The type of .NET runtime being checked for. Possible values: aspnet, desktop and core", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Platform", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Text, description: "Sets the platform for the .NET runtime being checked for. Possible values: x86, x64 and arm64", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Version", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Version, description: "The version of the .NET runtime being checked for (e.g. 3.1.10, 5.0.1).", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("RollForward", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Sets the roll-forward policy that the application is using. Possible values: latestmajor, major, latestminor, minor, latestpatch and disable", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Property", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, description: "Name of the property in which to place the result of the check.", modularizeType: ColumnModularizeType.Column), + }, + symbolIdIsPrimaryKey: true + ); + public static readonly TableDefinition[] All = new[] { NetFxNativeImage, + NetFxDotNetCompatibilityCheck }; } } diff --git a/src/ext/NetFx/wixext/Symbols/NetFxDotNetCompatibilityCheckSymbol.cs b/src/ext/NetFx/wixext/Symbols/NetFxDotNetCompatibilityCheckSymbol.cs new file mode 100644 index 00000000..a46cf17f --- /dev/null +++ b/src/ext/NetFx/wixext/Symbols/NetFxDotNetCompatibilityCheckSymbol.cs @@ -0,0 +1,79 @@ +// 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. + +namespace WixToolset.Netfx +{ + using WixToolset.Data; + using WixToolset.Netfx.Symbols; + + public static partial class NetfxSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition NetFxDotNetCompatibilityCheck = new IntermediateSymbolDefinition( + NetfxSymbolDefinitionType.NetFxDotNetCompatibilityCheck.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(NetFxDotNetCompatibilityCheckSymbollFields.RuntimeType), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(NetFxDotNetCompatibilityCheckSymbollFields.Platform), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(NetFxDotNetCompatibilityCheckSymbollFields.Version), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(NetFxDotNetCompatibilityCheckSymbollFields.RollForward), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(NetFxDotNetCompatibilityCheckSymbollFields.Property), IntermediateFieldType.String), + }, + typeof(NetFxDotNetCompatibilityCheckSymbol)); + } +} + +namespace WixToolset.Netfx.Symbols +{ + using WixToolset.Data; + + public enum NetFxDotNetCompatibilityCheckSymbollFields + { + RuntimeType, + Platform, + Version, + RollForward, + Property, + } + + public class NetFxDotNetCompatibilityCheckSymbol : IntermediateSymbol + { + public NetFxDotNetCompatibilityCheckSymbol() : base(NetfxSymbolDefinitions.NetFxDotNetCompatibilityCheck, null, null) + { + } + + public NetFxDotNetCompatibilityCheckSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(NetfxSymbolDefinitions.NetFxDotNetCompatibilityCheck, sourceLineNumber, id) + { + } + + public IntermediateField this[NetFxDotNetCompatibilityCheckSymbollFields index] => this.Fields[(int)index]; + + public string RuntimeType + { + get => this.Fields[(int)NetFxDotNetCompatibilityCheckSymbollFields.RuntimeType].AsString(); + set => this.Set((int)NetFxDotNetCompatibilityCheckSymbollFields.RuntimeType, value); + } + + public string Platform + { + get => this.Fields[(int)NetFxDotNetCompatibilityCheckSymbollFields.Platform].AsString(); + set => this.Set((int)NetFxDotNetCompatibilityCheckSymbollFields.Platform, value); + } + + public string Version + { + get => this.Fields[(int)NetFxDotNetCompatibilityCheckSymbollFields.Version].AsString(); + set => this.Set((int)NetFxDotNetCompatibilityCheckSymbollFields.Version, value); + } + + public string RollForward + { + get => this.Fields[(int)NetFxDotNetCompatibilityCheckSymbollFields.RollForward].AsString(); + set => this.Set((int)NetFxDotNetCompatibilityCheckSymbollFields.RollForward, value); + } + + public string Property + { + get => this.Fields[(int)NetFxDotNetCompatibilityCheckSymbollFields.Property].AsString(); + set => this.Set((int)NetFxDotNetCompatibilityCheckSymbollFields.Property, value); + } + } +} diff --git a/src/ext/NetFx/wixext/Symbols/NetfxSymbolDefinitions.cs b/src/ext/NetFx/wixext/Symbols/NetfxSymbolDefinitions.cs index 862eba16..ad729dd4 100644 --- a/src/ext/NetFx/wixext/Symbols/NetfxSymbolDefinitions.cs +++ b/src/ext/NetFx/wixext/Symbols/NetfxSymbolDefinitions.cs @@ -10,10 +10,13 @@ namespace WixToolset.Netfx { NetFxNativeImage, NetFxNetCoreSearch, + NetFxDotNetCompatibilityCheck } public static partial class NetfxSymbolDefinitions { + public static readonly Version Version = new Version("4.0.0"); + public static IntermediateSymbolDefinition ByName(string name) { if (!Enum.TryParse(name, out NetfxSymbolDefinitionType type)) @@ -33,6 +36,9 @@ namespace WixToolset.Netfx case NetfxSymbolDefinitionType.NetFxNetCoreSearch: return NetfxSymbolDefinitions.NetFxNetCoreSearch; + + case NetfxSymbolDefinitionType.NetFxDotNetCompatibilityCheck: + return NetfxSymbolDefinitions.NetFxDotNetCompatibilityCheck; default: throw new ArgumentOutOfRangeException(nameof(type)); diff --git a/src/ext/NetFx/wixlib/NetFxExtension_Platform.wxi b/src/ext/NetFx/wixlib/NetFxExtension_Platform.wxi index f607c72d..c9c8af02 100644 --- a/src/ext/NetFx/wixlib/NetFxExtension_Platform.wxi +++ b/src/ext/NetFx/wixlib/NetFxExtension_Platform.wxi @@ -10,6 +10,7 @@ + @@ -17,11 +18,19 @@ + + + + + + + + diff --git a/src/ext/NetFx/wixlib/netfx.wixproj b/src/ext/NetFx/wixlib/netfx.wixproj index bc6a1172..734e64da 100644 --- a/src/ext/NetFx/wixlib/netfx.wixproj +++ b/src/ext/NetFx/wixlib/netfx.wixproj @@ -11,6 +11,9 @@ + + + @@ -33,5 +36,8 @@ + + + diff --git a/src/internal/SetBuildNumber/Directory.Packages.props.pp b/src/internal/SetBuildNumber/Directory.Packages.props.pp index 4869df82..f59c9742 100644 --- a/src/internal/SetBuildNumber/Directory.Packages.props.pp +++ b/src/internal/SetBuildNumber/Directory.Packages.props.pp @@ -93,4 +93,10 @@ + + + + + + -- cgit v1.2.3-55-g6feb