From 03db7922de5b7e04300e0ed09e24f7b8890ec2e8 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 13:22:13 -0700 Subject: Move DifxApp.wixext into ext --- src/ext/DifxApp/CSharp.Build.props | 11 ++ src/ext/DifxApp/DifxApp.wixext.sln | 63 ++++++++ src/ext/DifxApp/Directory.Build.props | 29 ++++ src/ext/DifxApp/Directory.Build.targets | 48 ++++++ src/ext/DifxApp/README.md | 2 + src/ext/DifxApp/appveyor.cmd | 14 ++ src/ext/DifxApp/appveyor.yml | 40 +++++ src/ext/DifxApp/nuget.config | 17 +++ .../DifxAppExtensionFixture.cs | 36 +++++ .../TestData/UsingDriver/Package.en-us.wxl | 11 ++ .../TestData/UsingDriver/Package.wxs | 15 ++ .../TestData/UsingDriver/PackageComponents.wxs | 12 ++ .../TestData/UsingDriver/example.txt | 1 + .../WixToolsetTest.DifxApp.csproj | 41 ++++++ src/ext/DifxApp/wix.snk | Bin 0 -> 596 bytes src/ext/DifxApp/wixext/DifxAppCompiler.cs | 161 +++++++++++++++++++++ src/ext/DifxApp/wixext/DifxAppDecompiler.cs | 98 +++++++++++++ src/ext/DifxApp/wixext/DifxAppExtensionData.cs | 23 +++ src/ext/DifxApp/wixext/DifxAppExtensionFactory.cs | 18 +++ src/ext/DifxApp/wixext/DifxAppTableDefinitions.cs | 26 ++++ ...ifxAppWindowsInstallerBackendBinderExtension.cs | 13 ++ .../wixext/Symbols/DifxAppSymbolDefinitions.cs | 39 +++++ .../wixext/Symbols/MsiDriverPackagesSymbol.cs | 63 ++++++++ .../wixext/WixToolset.DifxApp.wixext.csproj | 28 ++++ .../wixext/WixToolset.DifxApp.wixext.targets | 11 ++ .../DifxApp/wixlib/DifxAppExtension_Platform.wxi | 22 +++ src/ext/DifxApp/wixlib/DifxAppExtension_x64.wxs | 8 + src/ext/DifxApp/wixlib/DifxAppExtension_x86.wxs | 8 + src/ext/DifxApp/wixlib/caSuffix.wxi | 28 ++++ src/ext/DifxApp/wixlib/difxapp.wixproj | 14 ++ src/ext/DifxApp/wixlib/x64/DIFxApp.dll | Bin 0 -> 153080 bytes src/ext/DifxApp/wixlib/x64/DIFxAppA.dll | Bin 0 -> 707464 bytes src/ext/DifxApp/wixlib/x86/DIFxApp.dll | Bin 0 -> 122248 bytes src/ext/DifxApp/wixlib/x86/DIFxAppA.dll | Bin 0 -> 364424 bytes src/ext/global.json | 5 + 35 files changed, 905 insertions(+) create mode 100644 src/ext/DifxApp/CSharp.Build.props create mode 100644 src/ext/DifxApp/DifxApp.wixext.sln create mode 100644 src/ext/DifxApp/Directory.Build.props create mode 100644 src/ext/DifxApp/Directory.Build.targets create mode 100644 src/ext/DifxApp/README.md create mode 100644 src/ext/DifxApp/appveyor.cmd create mode 100644 src/ext/DifxApp/appveyor.yml create mode 100644 src/ext/DifxApp/nuget.config create mode 100644 src/ext/DifxApp/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs create mode 100644 src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.en-us.wxl create mode 100644 src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.wxs create mode 100644 src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/PackageComponents.wxs create mode 100644 src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/example.txt create mode 100644 src/ext/DifxApp/test/WixToolsetTest.DifxApp/WixToolsetTest.DifxApp.csproj create mode 100644 src/ext/DifxApp/wix.snk create mode 100644 src/ext/DifxApp/wixext/DifxAppCompiler.cs create mode 100644 src/ext/DifxApp/wixext/DifxAppDecompiler.cs create mode 100644 src/ext/DifxApp/wixext/DifxAppExtensionData.cs create mode 100644 src/ext/DifxApp/wixext/DifxAppExtensionFactory.cs create mode 100644 src/ext/DifxApp/wixext/DifxAppTableDefinitions.cs create mode 100644 src/ext/DifxApp/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs create mode 100644 src/ext/DifxApp/wixext/Symbols/DifxAppSymbolDefinitions.cs create mode 100644 src/ext/DifxApp/wixext/Symbols/MsiDriverPackagesSymbol.cs create mode 100644 src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.csproj create mode 100644 src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.targets create mode 100644 src/ext/DifxApp/wixlib/DifxAppExtension_Platform.wxi create mode 100644 src/ext/DifxApp/wixlib/DifxAppExtension_x64.wxs create mode 100644 src/ext/DifxApp/wixlib/DifxAppExtension_x86.wxs create mode 100644 src/ext/DifxApp/wixlib/caSuffix.wxi create mode 100644 src/ext/DifxApp/wixlib/difxapp.wixproj create mode 100644 src/ext/DifxApp/wixlib/x64/DIFxApp.dll create mode 100644 src/ext/DifxApp/wixlib/x64/DIFxAppA.dll create mode 100644 src/ext/DifxApp/wixlib/x86/DIFxApp.dll create mode 100644 src/ext/DifxApp/wixlib/x86/DIFxAppA.dll create mode 100644 src/ext/global.json (limited to 'src/ext') diff --git a/src/ext/DifxApp/CSharp.Build.props b/src/ext/DifxApp/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/ext/DifxApp/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/ext/DifxApp/DifxApp.wixext.sln b/src/ext/DifxApp/DifxApp.wixext.sln new file mode 100644 index 00000000..2b891405 --- /dev/null +++ b/src/ext/DifxApp/DifxApp.wixext.sln @@ -0,0 +1,63 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30611.23 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "difxapp", "src\wixlib\difxapp.wixproj", "{5066EB93-D8F7-4FAE-B687-024D7A81BD95}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.DifxApp.wixext", "src\wixext\WixToolset.DifxApp.wixext.csproj", "{2256EFD7-E678-4485-818D-986D590068BE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.DifxApp", "src\test\WixToolsetTest.DifxApp\WixToolsetTest.DifxApp.csproj", "{883D7BA3-1ADC-47AC-95B0-221BB0B7788D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Debug|Any CPU.ActiveCfg = Debug|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Debug|Any CPU.Build.0 = Debug|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Debug|x64.ActiveCfg = Debug|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Debug|x86.ActiveCfg = Debug|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Debug|x86.Build.0 = Debug|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Release|Any CPU.ActiveCfg = Release|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Release|Any CPU.Build.0 = Release|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Release|x64.ActiveCfg = Release|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Release|x86.ActiveCfg = Release|x86 + {5066EB93-D8F7-4FAE-B687-024D7A81BD95}.Release|x86.Build.0 = Release|x86 + {2256EFD7-E678-4485-818D-986D590068BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Debug|x64.ActiveCfg = Debug|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Debug|x64.Build.0 = Debug|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Debug|x86.ActiveCfg = Debug|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Debug|x86.Build.0 = Debug|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Release|Any CPU.Build.0 = Release|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Release|x64.ActiveCfg = Release|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Release|x64.Build.0 = Release|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Release|x86.ActiveCfg = Release|Any CPU + {2256EFD7-E678-4485-818D-986D590068BE}.Release|x86.Build.0 = Release|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Debug|x64.ActiveCfg = Debug|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Debug|x64.Build.0 = Debug|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Debug|x86.ActiveCfg = Debug|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Debug|x86.Build.0 = Debug|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Release|Any CPU.Build.0 = Release|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Release|x64.ActiveCfg = Release|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Release|x64.Build.0 = Release|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Release|x86.ActiveCfg = Release|Any CPU + {883D7BA3-1ADC-47AC-95B0-221BB0B7788D}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {60A3EA0F-9313-47F8-BF6B-74478A57B577} + EndGlobalSection +EndGlobal diff --git a/src/ext/DifxApp/Directory.Build.props b/src/ext/DifxApp/Directory.Build.props new file mode 100644 index 00000000..f83cc154 --- /dev/null +++ b/src/ext/DifxApp/Directory.Build.props @@ -0,0 +1,29 @@ + + + + + + Debug + false + MSB3246 + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + + + diff --git a/src/ext/DifxApp/Directory.Build.targets b/src/ext/DifxApp/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/ext/DifxApp/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + diff --git a/src/ext/DifxApp/README.md b/src/ext/DifxApp/README.md new file mode 100644 index 00000000..49f30df8 --- /dev/null +++ b/src/ext/DifxApp/README.md @@ -0,0 +1,2 @@ +# DifxApp.wixext +WixToolset.DifxApp.wixext - DIFxApp WiX Toolset Extension diff --git a/src/ext/DifxApp/appveyor.cmd b/src/ext/DifxApp/appveyor.cmd new file mode 100644 index 00000000..ec37397e --- /dev/null +++ b/src/ext/DifxApp/appveyor.cmd @@ -0,0 +1,14 @@ +@setlocal +@pushd %~dp0 + +nuget restore || exit /b + +msbuild -p:Configuration=Release -t:Restore || exit /b + +msbuild -p:Configuration=Release src\test\WixToolsetTest.DifxApp\WixToolsetTest.DifxApp.csproj || exit /b +dotnet test -c Release --no-build src\test\WixToolsetTest.DifxApp || exit /b + +msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.DifxApp.wixext.csproj || exit /b + +@popd +@endlocal \ No newline at end of file diff --git a/src/ext/DifxApp/appveyor.yml b/src/ext/DifxApp/appveyor.yml new file mode 100644 index 00000000..7c686b04 --- /dev/null +++ b/src/ext/DifxApp/appveyor.yml @@ -0,0 +1,40 @@ +# 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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/ext/DifxApp/nuget.config b/src/ext/DifxApp/nuget.config new file mode 100644 index 00000000..db7aba29 --- /dev/null +++ b/src/ext/DifxApp/nuget.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/DifxApp/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs new file mode 100644 index 00000000..f5166453 --- /dev/null +++ b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/DifxAppExtensionFixture.cs @@ -0,0 +1,36 @@ +// 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 WixToolsetTest.DifxApp +{ + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.DifxApp; + using Xunit; + + public class DifxAppExtensionFixture + { + [Fact] + public void CanBuildUsingDriver() + { + var folder = TestData.Get(@"TestData\UsingDriver"); + var build = new Builder(folder, typeof(DifxAppExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "CustomAction"); + Assert.Equal(new[] + { + "CustomAction:MsiCleanupOnSuccess\t1\tDIFxApp.dll\tCleanupOnSuccess\t", + "CustomAction:MsiInstallDrivers\t3073\tDIFxAppA.dll\tInstallDriverPackages\t", + "CustomAction:MsiProcessDrivers\t1\tDIFxApp.dll\tProcessDriverPackages\t", + "CustomAction:MsiRollbackInstall\t3329\tDIFxAppA.dll\tRollbackInstall\t", + "CustomAction:MsiUninstallDrivers\t3073\tDIFxAppA.dll\tUninstallDriverPackages\t", + }, results); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args) + .AssertSuccess(); + } + } +} diff --git a/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.en-us.wxl b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.wxs b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.wxs new file mode 100644 index 00000000..411893bc --- /dev/null +++ b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/PackageComponents.wxs b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/PackageComponents.wxs new file mode 100644 index 00000000..9609771a --- /dev/null +++ b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/PackageComponents.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/example.txt b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/TestData/UsingDriver/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/DifxApp/test/WixToolsetTest.DifxApp/WixToolsetTest.DifxApp.csproj b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/WixToolsetTest.DifxApp.csproj new file mode 100644 index 00000000..e205d24a --- /dev/null +++ b/src/ext/DifxApp/test/WixToolsetTest.DifxApp/WixToolsetTest.DifxApp.csproj @@ -0,0 +1,41 @@ + + + + + + netcoreapp3.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/DifxApp/wix.snk b/src/ext/DifxApp/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/ext/DifxApp/wix.snk differ diff --git a/src/ext/DifxApp/wixext/DifxAppCompiler.cs b/src/ext/DifxApp/wixext/DifxAppCompiler.cs new file mode 100644 index 00000000..e056988f --- /dev/null +++ b/src/ext/DifxApp/wixext/DifxAppCompiler.cs @@ -0,0 +1,161 @@ +// 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.DifxApp +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.DifxApp.Symbols; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset Driver Install Frameworks for Applications Extension. + /// + public sealed class DifxAppCompiler : BaseCompilerExtension + { + private HashSet components; + + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/difxapp"; + /// + /// Instantiate a new DifxAppCompiler. + /// + public DifxAppCompiler() + { + this.components = new HashSet(); + } + + /// + /// Processes an element for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "Component": + var componentId = context["ComponentId"]; + var directoryId = context["DirectoryId"]; + var componentWin64 = Boolean.Parse(context["Win64"]); + + switch (element.Name.LocalName) + { + case "Driver": + this.ParseDriverElement(intermediate, section, element, componentId, componentWin64); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a Driver element. + /// + /// Element to parse. + /// Identifier for parent component. + private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + int attributes = 0; + var sequence = CompilerConstants.IntegerNotSet; + + // check the number of times a Driver element has been nested under this Component element + if (null != componentId) + { + if (this.components.Contains(componentId)) + { + this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); + } + else + { + this.components.Add(componentId); + } + } + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "AddRemovePrograms": + if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x4; + } + break; + case "DeleteFiles": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x10; + } + break; + case "ForceInstall": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x1; + } + break; + case "Legacy": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x8; + } + break; + case "PlugAndPlayPrompt": + if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x2; + } + break; + case "Sequence": + sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); + break; + default: + this.ParseHelper.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); + } + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); + + if (!this.Messaging.EncounteredError) + { + switch (this.Context.Platform) + { + case Platform.X86: + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MsiProcessDrivers"); + break; + case Platform.X64: + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MsiProcessDrivers_x64"); + break; + } + + var symbol = section.AddSymbol(new MsiDriverPackagesSymbol(sourceLineNumbers) + { + ComponentRef = componentId, + Flags = attributes, + }); + + if (CompilerConstants.IntegerNotSet != sequence) + { + symbol.Sequence = sequence; + } + } + } + } +} diff --git a/src/ext/DifxApp/wixext/DifxAppDecompiler.cs b/src/ext/DifxApp/wixext/DifxAppDecompiler.cs new file mode 100644 index 00000000..e41d8b98 --- /dev/null +++ b/src/ext/DifxApp/wixext/DifxAppDecompiler.cs @@ -0,0 +1,98 @@ +// 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.DifxApp +{ +#if TODO_CONSIDER_DECOMPILER + using System; + using System.Collections; + using System.Globalization; + using WixToolset.Data; + using WixToolset.Extensibility; + using DifxApp = WixToolset.Extensions.Serialize.DifxApp; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset Driver Install Frameworks for Applications Extension. + /// + public sealed class DifxAppDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for Gaming Extension. + /// + public DifxAppDecompiler() + { + this.TableDefinitions = DifxAppExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "MsiDriverPackages": + this.DecompileMsiDriverPackagesTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Decompile the MsiDriverPackages table. + /// + /// The table to decompile. + private void DecompileMsiDriverPackagesTable(Table table) + { + foreach (Row row in table.Rows) + { + DifxApp.Driver driver = new DifxApp.Driver(); + + int attributes = (int)row[1]; + if (0x1 == (attributes & 0x1)) + { + driver.ForceInstall = DifxApp.YesNoType.yes; + } + + if (0x2 == (attributes & 0x2)) + { + driver.PlugAndPlayPrompt = DifxApp.YesNoType.no; + } + + if (0x4 == (attributes & 0x4)) + { + driver.AddRemovePrograms = DifxApp.YesNoType.no; + } + + if (0x8 == (attributes & 0x8)) + { + driver.Legacy = DifxApp.YesNoType.yes; + } + + if (0x10 == (attributes & 0x10)) + { + driver.DeleteFiles = DifxApp.YesNoType.yes; + } + + if (null != row[2]) + { + driver.Sequence = (int)row[2]; + } + + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[0]); + if (null != component) + { + component.AddChild(driver); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component", (string)row[0], "Component")); + } + } + } + } +#endif +} diff --git a/src/ext/DifxApp/wixext/DifxAppExtensionData.cs b/src/ext/DifxApp/wixext/DifxAppExtensionData.cs new file mode 100644 index 00000000..31a95b8e --- /dev/null +++ b/src/ext/DifxApp/wixext/DifxAppExtensionData.cs @@ -0,0 +1,23 @@ +// 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.DifxApp +{ + using WixToolset.Data; + using WixToolset.Extensibility; + + public sealed class DifxAppExtensionData : BaseExtensionData + { + public override string DefaultCulture => "en-US"; + + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = DifxAppSymbolDefinitions.ByName(name); + return symbolDefinition != null; + } + + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) + { + return Intermediate.Load(typeof(DifxAppExtensionData).Assembly, "WixToolset.DifxApp.difxapp.wixlib", symbolDefinitions); + } + } +} diff --git a/src/ext/DifxApp/wixext/DifxAppExtensionFactory.cs b/src/ext/DifxApp/wixext/DifxAppExtensionFactory.cs new file mode 100644 index 00000000..3932685d --- /dev/null +++ b/src/ext/DifxApp/wixext/DifxAppExtensionFactory.cs @@ -0,0 +1,18 @@ +// 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.DifxApp +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class DifxAppExtensionFactory : BaseExtensionFactory + { + protected override IReadOnlyCollection ExtensionTypes => new[] + { + typeof(DifxAppCompiler), + typeof(DifxAppExtensionData), + typeof(DifxAppWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/ext/DifxApp/wixext/DifxAppTableDefinitions.cs b/src/ext/DifxApp/wixext/DifxAppTableDefinitions.cs new file mode 100644 index 00000000..a6c26444 --- /dev/null +++ b/src/ext/DifxApp/wixext/DifxAppTableDefinitions.cs @@ -0,0 +1,26 @@ +// 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.DifxApp +{ + using WixToolset.Data.WindowsInstaller; + + public static class DifxAppTableDefinitions + { + public static readonly TableDefinition MsiDriverPackages = new TableDefinition( + "MsiDriverPackages", + DifxAppSymbolDefinitions.MsiDriverPackages, + new[] + { + new ColumnDefinition("Component", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Name of the component that represents the driver package", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Flags", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 31, description: "Flags for installing and uninstalling driver packages"), + new ColumnDefinition("Sequence", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, description: "Order in which the driver packages are processed"), + }, + symbolIdIsPrimaryKey: false + ); + + public static readonly TableDefinition[] All = new[] + { + MsiDriverPackages, + }; + } +} diff --git a/src/ext/DifxApp/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs b/src/ext/DifxApp/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..41f01175 --- /dev/null +++ b/src/ext/DifxApp/wixext/DifxAppWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,13 @@ +// 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.DifxApp +{ + using System.Collections.Generic; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class DifxAppWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + public override IReadOnlyCollection TableDefinitions => DifxAppTableDefinitions.All; + } +} diff --git a/src/ext/DifxApp/wixext/Symbols/DifxAppSymbolDefinitions.cs b/src/ext/DifxApp/wixext/Symbols/DifxAppSymbolDefinitions.cs new file mode 100644 index 00000000..76f4d88f --- /dev/null +++ b/src/ext/DifxApp/wixext/Symbols/DifxAppSymbolDefinitions.cs @@ -0,0 +1,39 @@ +// 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.DifxApp +{ + using System; + using WixToolset.Data; + + public enum DifxAppSymbolDefinitionType + { + MsiDriverPackages, + } + + public static partial class DifxAppSymbolDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out DifxAppSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(DifxAppSymbolDefinitionType type) + { + switch (type) + { + case DifxAppSymbolDefinitionType.MsiDriverPackages: + return DifxAppSymbolDefinitions.MsiDriverPackages; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/ext/DifxApp/wixext/Symbols/MsiDriverPackagesSymbol.cs b/src/ext/DifxApp/wixext/Symbols/MsiDriverPackagesSymbol.cs new file mode 100644 index 00000000..2fd91bc8 --- /dev/null +++ b/src/ext/DifxApp/wixext/Symbols/MsiDriverPackagesSymbol.cs @@ -0,0 +1,63 @@ +// 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.DifxApp +{ + using WixToolset.Data; + using WixToolset.DifxApp.Symbols; + + public static partial class DifxAppSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition MsiDriverPackages = new IntermediateSymbolDefinition( + DifxAppSymbolDefinitionType.MsiDriverPackages.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(MsiDriverPackagesSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(MsiDriverPackagesSymbolFields.Flags), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(MsiDriverPackagesSymbolFields.Sequence), IntermediateFieldType.Number), + }, + typeof(MsiDriverPackagesSymbol)); + } +} + +namespace WixToolset.DifxApp.Symbols +{ + using WixToolset.Data; + + public enum MsiDriverPackagesSymbolFields + { + ComponentRef, + Flags, + Sequence, + } + + public class MsiDriverPackagesSymbol : IntermediateSymbol + { + public MsiDriverPackagesSymbol() : base(DifxAppSymbolDefinitions.MsiDriverPackages, null, null) + { + } + + public MsiDriverPackagesSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DifxAppSymbolDefinitions.MsiDriverPackages, sourceLineNumber, id) + { + } + + public IntermediateField this[MsiDriverPackagesSymbolFields index] => this.Fields[(int)index]; + + public string ComponentRef + { + get => this.Fields[(int)MsiDriverPackagesSymbolFields.ComponentRef].AsString(); + set => this.Set((int)MsiDriverPackagesSymbolFields.ComponentRef, value); + } + + public int Flags + { + get => this.Fields[(int)MsiDriverPackagesSymbolFields.Flags].AsNumber(); + set => this.Set((int)MsiDriverPackagesSymbolFields.Flags, value); + } + + public int? Sequence + { + get => this.Fields[(int)MsiDriverPackagesSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)MsiDriverPackagesSymbolFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.csproj b/src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.csproj new file mode 100644 index 00000000..50d3debf --- /dev/null +++ b/src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.csproj @@ -0,0 +1,28 @@ + + + + + + netstandard2.0 + WixToolset.DifxApp + WiX Toolset DIFxApp Extension + WiX Toolset DIFxApp Extension + true + build + + + + + + + + + + + + + + + + + diff --git a/src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.targets b/src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.targets new file mode 100644 index 00000000..b01d4116 --- /dev/null +++ b/src/ext/DifxApp/wixext/WixToolset.DifxApp.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.DifxApp.wixext.dll + + + + + diff --git a/src/ext/DifxApp/wixlib/DifxAppExtension_Platform.wxi b/src/ext/DifxApp/wixlib/DifxAppExtension_Platform.wxi new file mode 100644 index 00000000..b8d613c9 --- /dev/null +++ b/src/ext/DifxApp/wixlib/DifxAppExtension_Platform.wxi @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/DifxApp/wixlib/DifxAppExtension_x64.wxs b/src/ext/DifxApp/wixlib/DifxAppExtension_x64.wxs new file mode 100644 index 00000000..3c534363 --- /dev/null +++ b/src/ext/DifxApp/wixlib/DifxAppExtension_x64.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/ext/DifxApp/wixlib/DifxAppExtension_x86.wxs b/src/ext/DifxApp/wixlib/DifxAppExtension_x86.wxs new file mode 100644 index 00000000..d352a272 --- /dev/null +++ b/src/ext/DifxApp/wixlib/DifxAppExtension_x86.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/ext/DifxApp/wixlib/caSuffix.wxi b/src/ext/DifxApp/wixlib/caSuffix.wxi new file mode 100644 index 00000000..a56a2393 --- /dev/null +++ b/src/ext/DifxApp/wixlib/caSuffix.wxi @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/DifxApp/wixlib/difxapp.wixproj b/src/ext/DifxApp/wixlib/difxapp.wixproj new file mode 100644 index 00000000..2ae9a097 --- /dev/null +++ b/src/ext/DifxApp/wixlib/difxapp.wixproj @@ -0,0 +1,14 @@ + + + + + Library + true + en-us + + + + + + + diff --git a/src/ext/DifxApp/wixlib/x64/DIFxApp.dll b/src/ext/DifxApp/wixlib/x64/DIFxApp.dll new file mode 100644 index 00000000..69a44cc8 Binary files /dev/null and b/src/ext/DifxApp/wixlib/x64/DIFxApp.dll differ diff --git a/src/ext/DifxApp/wixlib/x64/DIFxAppA.dll b/src/ext/DifxApp/wixlib/x64/DIFxAppA.dll new file mode 100644 index 00000000..99458040 Binary files /dev/null and b/src/ext/DifxApp/wixlib/x64/DIFxAppA.dll differ diff --git a/src/ext/DifxApp/wixlib/x86/DIFxApp.dll b/src/ext/DifxApp/wixlib/x86/DIFxApp.dll new file mode 100644 index 00000000..678a9d95 Binary files /dev/null and b/src/ext/DifxApp/wixlib/x86/DIFxApp.dll differ diff --git a/src/ext/DifxApp/wixlib/x86/DIFxAppA.dll b/src/ext/DifxApp/wixlib/x86/DIFxAppA.dll new file mode 100644 index 00000000..3ac0838d Binary files /dev/null and b/src/ext/DifxApp/wixlib/x86/DIFxAppA.dll differ diff --git a/src/ext/global.json b/src/ext/global.json new file mode 100644 index 00000000..23dd3fa6 --- /dev/null +++ b/src/ext/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0211" + } +} -- cgit v1.2.3-55-g6feb