From 7a934bcfb8d460b0cf91a51caa956a8bbff14edf Mon Sep 17 00:00:00 2001 From: Bob Arnson <bob@joyofsetup.com> Date: Mon, 28 Oct 2019 21:17:09 -0400 Subject: Modernize tuple creation and update dependencies. --- src/ca/fwca.vcxproj | 23 ++++----------- src/ca/packages.config | 4 +-- .../WixToolsetTest.Firewall.csproj | 12 ++++++-- src/wixext/FirewallCompiler.cs | 33 ++++++++++------------ .../FirewallWindowsInstallerBackendExtension.cs | 5 +++- src/wixext/Tuples/FirewallTupleDefinitions.cs | 3 +- src/wixext/Tuples/WixFirewallExceptionTuple.cs | 19 ++++--------- src/wixext/tables.xml | 2 +- src/wixlib/firewall.wixproj | 4 +-- src/wixlib/packages.config | 2 +- 10 files changed, 47 insertions(+), 60 deletions(-) diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index a933ed06..de77df9b 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -1,10 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> - <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="..\..\packages\WixToolset.DUtil.4.0.6\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.6\build\WixToolset.DUtil.props')" /> - <Import Project="..\..\packages\WixToolset.WcaUtil.4.0.2\build\WixToolset.WcaUtil.props" Condition="Exists('..\..\packages\WixToolset.WcaUtil.4.0.2\build\WixToolset.WcaUtil.props')" /> - + <Import Project="..\..\packages\WixToolset.WcaUtil.4.0.8\build\WixToolset.WcaUtil.props" Condition="Exists('..\..\packages\WixToolset.WcaUtil.4.0.8\build\WixToolset.WcaUtil.props')" /> + <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" /> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -15,7 +13,6 @@ <Platform>Win32</Platform> </ProjectConfiguration> </ItemGroup> - <PropertyGroup Label="Globals"> <ProjectGuid>{F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}</ProjectGuid> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -25,40 +22,32 @@ <ProjectModuleDefinitionFile>fwca.def</ProjectModuleDefinitionFile> <Description>WiX Toolset Firewall CustomAction</Description> </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <PropertyGroup> <ProjectAdditionalLinkLibraries>msi.lib</ProjectAdditionalLinkLibraries> </PropertyGroup> - <ItemGroup> <ClCompile Include="dllmain.cpp"> <PrecompiledHeader>Create</PrecompiledHeader> </ClCompile> <ClCompile Include="firewall.cpp" /> </ItemGroup> - <ItemGroup> <ClInclude Include="cost.h" /> <ClInclude Include="CustomMsiErrors.h" /> <ClInclude Include="precomp.h" /> </ItemGroup> - <ItemGroup> - <None Include="packages.config" /> <None Include="fwca.def" /> + <None Include="packages.config" /> </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>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}.</ErrorText> </PropertyGroup> - <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.6\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.6\build\WixToolset.DUtil.props'))" /> - <Error Condition="!Exists('..\..\packages\WixToolset.WcaUtil.4.0.2\build\WixToolset.WcaUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.WcaUtil.4.0.2\build\WixToolset.WcaUtil.props'))" /> + <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" /> + <Error Condition="!Exists('..\..\packages\WixToolset.WcaUtil.4.0.8\build\WixToolset.WcaUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.WcaUtil.4.0.8\build\WixToolset.WcaUtil.props'))" /> </Target> -</Project> - +</Project> \ No newline at end of file diff --git a/src/ca/packages.config b/src/ca/packages.config index b87f9ab4..4e9403bf 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="WixToolset.DUtil" version="4.0.6" targetFramework="native" /> - <package id="WixToolset.WcaUtil" version="4.0.2" targetFramework="native" /> + <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" /> + <package id="WixToolset.WcaUtil" version="4.0.8" targetFramework="native" /> </packages> \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj index d9c026f2..306f4b5f 100644 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -23,6 +23,9 @@ </ItemGroup> <ItemGroup> + <PackageReference Include="WixToolset.Core" Version="4.0.*" PrivateAssets="all" /> + <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" PrivateAssets="all" /> + <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" PrivateAssets="all" /> <PackageReference Include="WixToolset.Core.TestPackage" Version="4.0.*" PrivateAssets="all" /> </ItemGroup> @@ -31,8 +34,11 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" /> - <PackageReference Include="xunit" Version="2.4.0" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" /> + <PackageReference Include="xunit" Version="2.4.1" /> + <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> + <PrivateAssets>all</PrivateAssets> + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> + </PackageReference> </ItemGroup> </Project> diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 0696b4b1..353afff3 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -4,10 +4,10 @@ namespace WixToolset.Firewall { using System; using System.Collections.Generic; - using System.Globalization; using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Firewall.Tuples; /// <summary> /// The compiler for the WiX Toolset Firewall Extension. @@ -255,13 +255,18 @@ namespace WixToolset.Firewall fileId = file; } - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixFirewallException", id); - row.Set(1, name); - row.Set(2, remoteAddresses); + var tuple = new WixFirewallExceptionTuple(sourceLineNumbers, id) + { + Name = name, + RemoteAddresses = remoteAddresses, + Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, + ComponentRef = componentId, + Description = description, + }; if (!String.IsNullOrEmpty(port)) { - row.Set(3, port); + tuple.Port = port; if (!protocol.HasValue) { @@ -270,32 +275,24 @@ namespace WixToolset.Firewall } } - if (protocol.HasValue) - { - row.Set(4, protocol); - } + tuple.Protocol = protocol.Value; if (!String.IsNullOrEmpty(fileId)) { - row.Set(5, $"[#{fileId}]"); + tuple.Program = $"[#{fileId}]"; this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); } else if (!String.IsNullOrEmpty(program)) { - row.Set(5, program); + tuple.Program = program; } if (CompilerConstants.IntegerNotSet != attributes) { - row.Set(6, attributes); + tuple.Attributes = attributes; } - // Default is "all" - row.Set(7, profile ?? FirewallConstants.NET_FW_PROFILE2_ALL); - - row.Set(8, componentId); - - row.Set(9, description); + section.Tuples.Add(tuple); if (this.Context.Platform == Platform.ARM) { diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index a3949e69..47a01ac0 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -1,9 +1,10 @@ -// 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. +// 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.Firewall { using System.Linq; using System.Xml; + using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; @@ -13,6 +14,8 @@ namespace WixToolset.Firewall protected override TableDefinition[] TableDefinitionsForTuples => Tables; + public override bool TryAddTupleToOutput(IntermediateTuple tuple, WindowsInstallerData output) => this.BackendHelper.TryAddTupleToOutputMatchingTableDefinitions(tuple, output, this.TableDefinitionsForTuples, true); + private static TableDefinition[] LoadTables() { using (var resourceStream = typeof(FirewallWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs index 79fc28cf..df595c18 100644 --- a/src/wixext/Tuples/FirewallTupleDefinitions.cs +++ b/src/wixext/Tuples/FirewallTupleDefinitions.cs @@ -15,7 +15,6 @@ namespace WixToolset.Firewall.Tuples FirewallTupleDefinitionNames.WixFirewallException, new[] { - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.WixFirewallException), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), @@ -23,7 +22,7 @@ namespace WixToolset.Firewall.Tuples new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), }, typeof(WixFirewallExceptionTuple)); diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs index 715a4b9b..3c7cda3a 100644 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs @@ -6,7 +6,6 @@ namespace WixToolset.Firewall.Tuples public enum WixFirewallExceptionTupleFields { - WixFirewallException, Name, RemoteAddresses, Port, @@ -14,7 +13,7 @@ namespace WixToolset.Firewall.Tuples Program, Attributes, Profile, - Component_, + ComponentRef, Description, } @@ -30,12 +29,6 @@ namespace WixToolset.Firewall.Tuples public IntermediateField this[WixFirewallExceptionTupleFields index] => this.Fields[(int)index]; - public string WixFirewallException - { - get => this.Fields[(int)WixFirewallExceptionTupleFields.WixFirewallException].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.WixFirewallException, value); - } - public string Name { get => this.Fields[(int)WixFirewallExceptionTupleFields.Name].AsString(); @@ -54,9 +47,9 @@ namespace WixToolset.Firewall.Tuples set => this.Set((int)WixFirewallExceptionTupleFields.Port, value); } - public int Protocol + public int? Protocol { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Protocol].AsNumber(); + get => this.Fields[(int)WixFirewallExceptionTupleFields.Protocol].AsNullableNumber(); set => this.Set((int)WixFirewallExceptionTupleFields.Protocol, value); } @@ -78,10 +71,10 @@ namespace WixToolset.Firewall.Tuples set => this.Set((int)WixFirewallExceptionTupleFields.Profile, value); } - public string Component_ + public string ComponentRef { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Component_].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.Component_, value); + get => this.Fields[(int)WixFirewallExceptionTupleFields.ComponentRef].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.ComponentRef, value); } public string Description diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml index 5b408b96..b0c32305 100644 --- a/src/wixext/tables.xml +++ b/src/wixext/tables.xml @@ -17,7 +17,7 @@ <columnDefinition name="Program" type="string" length="255" nullable="yes" modularize="property" category="formatted" description="Exception for a program (formatted path name)." /> <columnDefinition name="Attributes" type="number" length="4" nullable="yes" - minValue="0" maxValue="65536" description="Vital=1" /> + description="Vital=1" /> <columnDefinition name="Profile" type="number" length="4" nullable="no" category="integer" minValue="1" maxValue="2147483647" description="Profile (1=domain; 2=private; 4=public; 2147483647=all)." /> <columnDefinition name="Component_" type="string" length="72" modularize="column" diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index 71a17115..e14c29ed 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <Project DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0"> - <Import Project="..\..\packages\WixToolset.MSBuild.4.0.0-build-0005\build\WixToolset.MSBuild.props" Condition="Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0005\build\WixToolset.MSBuild.props')" /> + <Import Project="..\..\packages\WixToolset.MSBuild.4.0.0-build-0051\build\WixToolset.MSBuild.props" Condition="Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0051\build\WixToolset.MSBuild.props')" /> <Import Project="..\FindLocalWix.props" /> <PropertyGroup> <ProjectGuid>{1acffefd-505a-41a5-acbf-a02b7b473aa2}</ProjectGuid> @@ -38,7 +38,7 @@ <ErrorText>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}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> - <Error Condition="!Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0005\build\WixToolset.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.MSBuild.4.0.0-build-0005\build\WixToolset.MSBuild.props'))" /> + <Error Condition="!Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0051\build\WixToolset.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.MSBuild.4.0.0-build-0051\build\WixToolset.MSBuild.props'))" /> </Target> <Import Project="..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" /> </Project> \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index f3d424e1..1ae2b79f 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Nerdbank.GitVersioning" version="2.1.65" developmentDependency="true" targetFramework="net40" /> - <package id="WixToolset.MSBuild" version="4.0.0-build-0005" developmentDependency="true" targetFramework="net40" /> + <package id="WixToolset.MSBuild" version="4.0.0-build-0051" developmentDependency="true" targetFramework="net40" /> </packages> \ No newline at end of file -- cgit v1.2.3-55-g6feb