From aecff401f974f603cb78b8a665000b2a93490e80 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 5 Apr 2020 21:27:11 +1000 Subject: Modernize NetfxCompiler and table definitions. --- src/Directory.Build.props | 4 ++- .../WixToolsetTest.Netfx.csproj | 15 +++++------ src/wixext/NetFxCompiler.cs | 12 ++++----- src/wixext/NetfxTableDefinitions.cs | 29 ++++++++++++++++++++++ .../NetfxWindowsInstallerBackendExtension.cs | 18 +------------- src/wixlib/netfx.wixproj | 4 +-- src/wixlib/packages.config | 2 +- 7 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 src/wixext/NetfxTableDefinitions.cs diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e853e22d..a22f4470 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,6 +8,7 @@ Debug false + MSB3246 $(MSBuildProjectName) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) @@ -21,6 +22,7 @@ WiX Toolset - + + diff --git a/src/test/WixToolsetTest.Netfx/WixToolsetTest.Netfx.csproj b/src/test/WixToolsetTest.Netfx/WixToolsetTest.Netfx.csproj index 4c2e1444..88303fcd 100644 --- a/src/test/WixToolsetTest.Netfx/WixToolsetTest.Netfx.csproj +++ b/src/test/WixToolsetTest.Netfx/WixToolsetTest.Netfx.csproj @@ -3,7 +3,7 @@ - netcoreapp2.1 + netcoreapp3.1 false @@ -23,10 +23,10 @@ - - - - + + + + @@ -36,9 +36,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/wixext/NetFxCompiler.cs b/src/wixext/NetFxCompiler.cs index 4916994e..58c8c0f6 100644 --- a/src/wixext/NetFxCompiler.cs +++ b/src/wixext/NetFxCompiler.cs @@ -53,14 +53,14 @@ namespace WixToolset.Netfx /// The file identifier of the parent element. private void ParseNativeImageElement(Intermediate intermediate, IntermediateSection section, XElement element, string fileId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string appBaseDirectory = null; string assemblyApplication = null; int attributes = 0x8; // 32bit is on by default int priority = 3; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -75,7 +75,7 @@ namespace WixToolset.Netfx // See if a formatted value is specified. if (-1 == appBaseDirectory.IndexOf("[", StringComparison.Ordinal)) { - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Directory", appBaseDirectory); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Directory, appBaseDirectory); } break; case "AssemblyApplication": @@ -84,7 +84,7 @@ namespace WixToolset.Netfx // See if a formatted value is specified. if (-1 == assemblyApplication.IndexOf("[", StringComparison.Ordinal)) { - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", assemblyApplication); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, assemblyApplication); } break; case "Debug": @@ -140,7 +140,7 @@ namespace WixToolset.Netfx if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("nni", fileId); } this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); @@ -149,7 +149,7 @@ namespace WixToolset.Netfx if (!this.Messaging.EncounteredError) { - section.Tuples.Add(new NetFxNativeImageTuple(sourceLineNumbers, id) + section.AddTuple(new NetFxNativeImageTuple(sourceLineNumbers, id) { FileRef = fileId, Priority = priority, diff --git a/src/wixext/NetfxTableDefinitions.cs b/src/wixext/NetfxTableDefinitions.cs new file mode 100644 index 00000000..378f6def --- /dev/null +++ b/src/wixext/NetfxTableDefinitions.cs @@ -0,0 +1,29 @@ +// 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.WindowsInstaller; + + public static class NetfxTableDefinitions + { + public static readonly TableDefinition NetFxNativeImage = new TableDefinition( + "Wix4NetFxNativeImage", + new[] + { + new ColumnDefinition("Wix4NetFxNativeImage", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("File_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "File", keyColumn: 1, description: "The assembly for which a native image will be generated.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Priority", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 3, description: "The priority for generating this native image: 0 is syncronous, 1-3 represent various levels of queued generation."), + new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 2147483647, description: "Integer containing bit flags representing native image attributes."), + new ColumnDefinition("File_Application", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "The application which loads this assembly.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Directory_ApplicationBase", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "The directory containing the application which loads this assembly.", modularizeType: ColumnModularizeType.Column), + }, + tupleDefinitionName: "NetFxNativeImage", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + NetFxNativeImage, + }; + } +} diff --git a/src/wixext/NetfxWindowsInstallerBackendExtension.cs b/src/wixext/NetfxWindowsInstallerBackendExtension.cs index 7e30d396..e1404c1a 100644 --- a/src/wixext/NetfxWindowsInstallerBackendExtension.cs +++ b/src/wixext/NetfxWindowsInstallerBackendExtension.cs @@ -8,22 +8,6 @@ namespace WixToolset.Netfx public class NetfxWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { - private static readonly TableDefinition[] Tables = new[] { - new TableDefinition( - "Wix4NetFxNativeImage", - "NetFxNativeImage", - new[] - { - new ColumnDefinition("Wix4NetFxNativeImage", ColumnType.String, 72, true, false, ColumnCategory.Identifier, description: "The primary key, a non-localized token."), - new ColumnDefinition("File_", ColumnType.String, 0, false, false, ColumnCategory.Identifier, keyTable:"File", keyColumn: 1, description: "The assembly for which a native image will be generated."), - new ColumnDefinition("Priority", ColumnType.Number, 2, false, false, ColumnCategory.Integer, maxValue: 3, description: "The priority for generating this native image: 0 is syncronous, 1-3 represent various levels of queued generation."), - new ColumnDefinition("Attributes", ColumnType.Number, 4, false, false, ColumnCategory.Integer, maxValue: 2147483647, description: "Integer containing bit flags representing native image attributes."), - new ColumnDefinition("File_Application", ColumnType.String, 72, false, true, ColumnCategory.Formatted, description: "The application which loads this assembly."), - new ColumnDefinition("Directory_ApplicationBase", ColumnType.String, 72, false, true, ColumnCategory.Formatted, description: "The directory containing the application which loads this assembly."), - } - ), - }; - - public override IEnumerable TableDefinitions { get => Tables; } + public override IEnumerable TableDefinitions => NetfxTableDefinitions.All; } } diff --git a/src/wixlib/netfx.wixproj b/src/wixlib/netfx.wixproj index aefce69b..62a35745 100644 --- a/src/wixlib/netfx.wixproj +++ b/src/wixlib/netfx.wixproj @@ -1,7 +1,7 @@ - + {45e4a6ac-3190-4e17-83f0-9935ffa5dc2b} @@ -45,7 +45,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index a543c00f..d7f7cfd7 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb