aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2019-01-19 13:03:02 -0600
committerSean Hall <r.sean.hall@gmail.com>2019-01-19 13:08:19 -0600
commit985ba427f8cd12b7b74d62f83a8b304764e6077b (patch)
treea1e7aec475299134b9b77191bc6885e961c4a045
parentdcfc3e2e369958d58dc070e3dbb8992e147b7a05 (diff)
downloadwix-985ba427f8cd12b7b74d62f83a8b304764e6077b.tar.gz
wix-985ba427f8cd12b7b74d62f83a8b304764e6077b.tar.bz2
wix-985ba427f8cd12b7b74d62f83a8b304764e6077b.zip
Integrate into latest v4
-rw-r--r--.editorconfig37
-rw-r--r--PowerShell.wixext.sln63
-rw-r--r--appveyor.cmd13
-rw-r--r--appveyor.yml40
-rw-r--r--nuget.config14
-rw-r--r--src/Directory.Build.props26
-rw-r--r--src/Directory.Build.targets48
-rw-r--r--src/FindLocalWix.props8
-rw-r--r--src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs26
-rw-r--r--src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl11
-rw-r--r--src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs21
-rw-r--r--src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs13
-rw-r--r--src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt1
-rw-r--r--src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj38
-rw-r--r--src/wixext/PSCompiler.cs106
-rw-r--r--src/wixext/PSErrors.cs30
-rw-r--r--src/wixext/PSExtensionData.cs26
-rw-r--r--src/wixext/PSWarnings.cs30
-rw-r--r--src/wixext/PowerShellExtensionFactory.cs17
-rw-r--r--src/wixext/WixPSExtension.csproj43
-rw-r--r--src/wixext/WixToolset.PowerShell.wixext.csproj29
-rw-r--r--src/wixext/WixToolset.PowerShell.wixext.targets11
-rw-r--r--src/wixext/messages.xml20
-rw-r--r--src/wixlib/PSExtension.wixproj19
-rw-r--r--src/wixlib/packages.config5
-rw-r--r--src/wixlib/powershell.wixproj35
-rw-r--r--version.json11
27 files changed, 588 insertions, 153 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..1d72e683
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,37 @@
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# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig
4# then update all of the repos.
5
6root = true
7
8[*]
9charset = utf-8
10indent_style = space
11indent_size = 4
12trim_trailing_whitespace = true
13
14[*.{cs,vb}]
15dotnet_sort_system_directives_first = true
16
17[*.cs]
18csharp_indent_case_contents = true : error
19csharp_indent_switch_labels = true : error
20csharp_new_line_before_open_brace = all
21csharp_prefer_braces = true : error
22csharp_style_expression_bodied_methods = when_on_single_line : suggestion
23csharp_style_expression_bodied_constructors = when_on_single_line : suggestion
24csharp_style_expression_bodied_operators = when_on_single_line : suggestion
25csharp_style_expression_bodied_properties = when_on_single_line : suggestion
26csharp_style_expression_bodied_indexers = when_on_single_line : suggestion
27csharp_style_expression_bodied_accessors = when_on_single_line : suggestion
28csharp_style_var_elsewhere = true : suggestion
29csharp_style_var_for_built_in_types = true : suggestion
30csharp_style_var_when_type_is_apparent = true : suggestion
31dotnet_style_qualification_for_event = true : error
32dotnet_style_qualification_for_field = true : error
33dotnet_style_qualification_for_method = true : error
34dotnet_style_qualification_for_property = true : error
35
36[*.targets]
37indent_size = 2
diff --git a/PowerShell.wixext.sln b/PowerShell.wixext.sln
new file mode 100644
index 00000000..24be219a
--- /dev/null
+++ b/PowerShell.wixext.sln
@@ -0,0 +1,63 @@
1
2Microsoft Visual Studio Solution File, Format Version 12.00
3# Visual Studio 15
4VisualStudioVersion = 15.0.27130.2003
5MinimumVisualStudioVersion = 15.0.26124.0
6Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "powershell", "src\wixlib\powershell.wixproj", "{9D4CCDFC-840C-4D4E-A9B0-3D6015480645}"
7EndProject
8Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.PowerShell.wixext", "src\wixext\WixToolset.PowerShell.wixext.csproj", "{6F1482DF-1598-4D88-BDAA-B9D0E0242139}"
9EndProject
10Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.PowerShell", "src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj", "{BFD10109-F4F3-4530-BE3B-802342D411F7}"
11EndProject
12Global
13 GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 Debug|Any CPU = Debug|Any CPU
15 Debug|x64 = Debug|x64
16 Debug|x86 = Debug|x86
17 Release|Any CPU = Release|Any CPU
18 Release|x64 = Release|x64
19 Release|x86 = Release|x86
20 EndGlobalSection
21 GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.ActiveCfg = Debug|x86
23 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.Build.0 = Debug|x86
24 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x64.ActiveCfg = Debug|x86
25 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.ActiveCfg = Debug|x86
26 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.Build.0 = Debug|x86
27 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.ActiveCfg = Release|x86
28 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.Build.0 = Release|x86
29 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x64.ActiveCfg = Release|x86
30 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.ActiveCfg = Release|x86
31 {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.Build.0 = Release|x86
32 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.ActiveCfg = Debug|Any CPU
35 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.Build.0 = Debug|Any CPU
36 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.ActiveCfg = Debug|Any CPU
37 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.Build.0 = Debug|Any CPU
38 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.Build.0 = Release|Any CPU
40 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.ActiveCfg = Release|Any CPU
41 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.Build.0 = Release|Any CPU
42 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.ActiveCfg = Release|Any CPU
43 {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.Build.0 = Release|Any CPU
44 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.ActiveCfg = Debug|Any CPU
47 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.Build.0 = Debug|Any CPU
48 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.ActiveCfg = Debug|Any CPU
49 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.Build.0 = Debug|Any CPU
50 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.Build.0 = Release|Any CPU
52 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.ActiveCfg = Release|Any CPU
53 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.Build.0 = Release|Any CPU
54 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.ActiveCfg = Release|Any CPU
55 {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.Build.0 = Release|Any CPU
56 EndGlobalSection
57 GlobalSection(SolutionProperties) = preSolution
58 HideSolutionNode = FALSE
59 EndGlobalSection
60 GlobalSection(ExtensibilityGlobals) = postSolution
61 SolutionGuid = {60A3EA0F-9313-47F8-BF6B-74478A57B577}
62 EndGlobalSection
63EndGlobal
diff --git a/appveyor.cmd b/appveyor.cmd
new file mode 100644
index 00000000..27d33a5d
--- /dev/null
+++ b/appveyor.cmd
@@ -0,0 +1,13 @@
1@setlocal
2@pushd %~dp0
3
4nuget restore
5
6msbuild -p:Configuration=Release -t:Restore
7
8msbuild -p:Configuration=Release src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj
9
10msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.PowerShell.wixext.csproj
11
12@popd
13@endlocal \ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 00000000..c1df03cc
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,40 @@
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# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml
4# then update all of the repos.
5
6branches:
7 only:
8 - master
9 - develop
10
11image: Visual Studio 2017
12
13version: 0.0.0.{build}
14configuration: Release
15
16environment:
17 DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
18 DOTNET_CLI_TELEMETRY_OPTOUT: 1
19 NUGET_XMLDOC_MODE: skip
20
21build_script:
22 - appveyor.cmd
23
24pull_requests:
25 do_not_increment_build_number: true
26
27nuget:
28 disable_publish_on_pr: true
29
30skip_branch_with_pr: true
31skip_tags: true
32
33artifacts:
34- path: build\Release\**\*.nupkg
35 name: nuget
36
37notifications:
38- provider: Slack
39 incoming_webhook:
40 secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA=
diff --git a/nuget.config b/nuget.config
new file mode 100644
index 00000000..f4f0704e
--- /dev/null
+++ b/nuget.config
@@ -0,0 +1,14 @@
1<?xml version="1.0" encoding="utf-8"?>
2<configuration>
3 <packageSources>
4 <clear />
5 <add key="wixtoolset-data" value="https://ci.appveyor.com/nuget/wixtoolset-data" />
6 <add key="wixtoolset-extensibility" value="https://ci.appveyor.com/nuget/wixtoolset-extensibility" />
7 <add key="wixtoolset-core" value="https://ci.appveyor.com/nuget/wixtoolset-core" />
8 <add key="wixtoolset-core-native" value="https://ci.appveyor.com/nuget/wixtoolset-core-native" />
9 <add key="wixtoolset-dtf" value="https://ci.appveyor.com/nuget/wixtoolset-dtf" />
10 <add key="wixtoolset-tools" value="https://ci.appveyor.com/nuget/wixtoolset-tools" />
11 <add key="wixbuildtools" value="https://ci.appveyor.com/nuget/wixbuildtools" />
12 <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
13 </packageSources>
14</configuration> \ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 00000000..e853e22d
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3<!--
4 Do NOT modify this file. Update the canonical version in Home\repo-template\src\Directory.Build.props
5 then update all of the repos.
6-->
7<Project>
8 <PropertyGroup>
9 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
10 <EnableSourceLink Condition=" '$(NCrunch)' == '1' ">false</EnableSourceLink>
11
12 <ProjectName Condition=" '$(ProjectName)' == '' ">$(MSBuildProjectName)</ProjectName>
13 <BaseOutputPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\))</BaseOutputPath>
14 <BaseIntermediateOutputPath>$(BaseOutputPath)obj\$(ProjectName)\</BaseIntermediateOutputPath>
15 <OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath>
16
17 <Authors>WiX Toolset Team</Authors>
18 <Company>WiX Toolset</Company>
19 <Copyright>Copyright (c) .NET Foundation and contributors. All rights reserved.</Copyright>
20 <PackageLicenseExpression>MS-RL</PackageLicenseExpression>
21 <Product>WiX Toolset</Product>
22 </PropertyGroup>
23
24 <Import Project="Cpp.Build.props" Condition=" '$(MSBuildProjectExtension)'=='.vcxproj' " />
25 <Import Project="Custom.Build.props" Condition=" Exists('Custom.Build.props') " />
26</Project>
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
new file mode 100644
index 00000000..dac7452a
--- /dev/null
+++ b/src/Directory.Build.targets
@@ -0,0 +1,48 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3<!--
4 Do NOT modify this file. Update the canonical version in Home\repo-template\src\Directory.Build.targets
5 then update all of the repos.
6-->
7<!--
8 Replace PackageReferences with ProjectReferences when the projects can be found in .sln.
9 See the original here: https://github.com/dotnet/sdk/issues/1151#issuecomment-385133284
10-->
11<Project>
12 <PropertyGroup>
13 <ReplacePackageReferences>true</ReplacePackageReferences>
14 <TheSolutionPath Condition=" '$(NCrunch)'=='' ">$(SolutionPath)</TheSolutionPath>
15 <TheSolutionPath Condition=" '$(NCrunch)'=='1' ">$(NCrunchOriginalSolutionPath)</TheSolutionPath>
16 </PropertyGroup>
17
18 <Choose>
19 <When Condition="$(ReplacePackageReferences) AND '$(TheSolutionPath)' != '' AND '$(TheSolutionPath)' != '*undefined*' AND Exists('$(TheSolutionPath)')">
20
21 <PropertyGroup>
22 <SolutionFileContent>$([System.IO.File]::ReadAllText($(TheSolutionPath)))</SolutionFileContent>
23 <SmartSolutionDir>$([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) ))</SmartSolutionDir>
24 <RegexPattern>(?&lt;="[PackageName]", ")(.*)(?=", ")</RegexPattern>
25 </PropertyGroup>
26
27 <ItemGroup>
28 <!-- Keep the identity of the PackageReference -->
29 <SmartPackageReference Include="@(PackageReference)">
30 <PackageName>%(Identity)</PackageName>
31 <InSolution>$(SolutionFileContent.Contains('\%(Identity).csproj'))</InSolution>
32 </SmartPackageReference>
33
34 <!-- Filter them by mapping them to another ItemGroup using the WithMetadataValue item function -->
35 <PackageInSolution Include="@(SmartPackageReference->WithMetadataValue('InSolution', True))">
36 <Pattern>$(RegexPattern.Replace('[PackageName]','%(PackageName)') )</Pattern>
37 <SmartPath>$([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)'))</SmartPath>
38 </PackageInSolution>
39
40 <ProjectReference Include="@(PackageInSolution->'$(SmartSolutionDir)\%(SmartPath)' )"/>
41
42 <!-- Remove the package references that are now referenced as projects -->
43 <PackageReference Remove="@(PackageInSolution->'%(PackageName)' )"/>
44 </ItemGroup>
45
46 </When>
47 </Choose>
48</Project>
diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props
new file mode 100644
index 00000000..a784e352
--- /dev/null
+++ b/src/FindLocalWix.props
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <PropertyGroup>
6 <WixTargetsPath Condition=" '$(Configuration)' == 'Debug' And Exists('$(MSBuildThisFileDirectory)..\..\Tools\README.md') ">$(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets</WixTargetsPath>
7 </PropertyGroup>
8</Project>
diff --git a/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs b/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs
new file mode 100644
index 00000000..b2f27ecf
--- /dev/null
+++ b/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.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
3namespace WixToolsetTest.PowerShell
4{
5 using WixBuildTools.TestSupport;
6 using WixToolset.Core.TestPackage;
7 using WixToolset.PowerShell;
8 using Xunit;
9
10 public class PowerShellExtensionFixture
11 {
12 [Fact]
13 public void CantBuildUsingTypesFileWithoutSnapIn()
14 {
15 var folder = TestData.Get(@"TestData\TypesFile");
16 var build = new Builder(folder, typeof(PowerShellExtensionFactory), new[] { folder });
17
18 WixRunnerResult wixRunnerResult = null;
19 var results = build.BuildAndQuery(args => {
20 wixRunnerResult = WixRunner.Execute(args);
21 });
22 Assert.NotNull(wixRunnerResult);
23 Assert.Equal((int)PSErrors.Ids.NeitherIdSpecified, wixRunnerResult.ExitCode);
24 }
25 }
26}
diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl
new file mode 100644
index 00000000..38c12ac1
--- /dev/null
+++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This file contains the declaration of all the localizable strings.
5-->
6<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7
8 <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 <String Id="FeatureTitle">MsiPackage</String>
10
11</WixLocalization>
diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs
new file mode 100644
index 00000000..cdc323ec
--- /dev/null
+++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
4 <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
5
6 <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
7 <MediaTemplate />
8
9 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
10 <ComponentGroupRef Id="ProductComponents" />
11 </Feature>
12 </Product>
13
14 <Fragment>
15 <Directory Id="TARGETDIR" Name="SourceDir">
16 <Directory Id="ProgramFilesFolder">
17 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
18 </Directory>
19 </Directory>
20 </Fragment>
21</Wix>
diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs
new file mode 100644
index 00000000..049f9a51
--- /dev/null
+++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3 xmlns:powershell="http://wixtoolset.org/schemas/v4/wxs/powershell">
4 <Fragment>
5 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
6 <Component>
7 <File Source="example.txt">
8 <powershell:TypesFile />
9 </File>
10 </Component>
11 </ComponentGroup>
12 </Fragment>
13</Wix>
diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt
new file mode 100644
index 00000000..1b4ffe8a
--- /dev/null
+++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt
@@ -0,0 +1 @@
This is example.txt. \ No newline at end of file
diff --git a/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj
new file mode 100644
index 00000000..0b5dfac4
--- /dev/null
+++ b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj
@@ -0,0 +1,38 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netcoreapp2.1</TargetFramework>
7 <IsPackable>false</IsPackable>
8 </PropertyGroup>
9
10 <PropertyGroup>
11 <NoWarn>NU1701</NoWarn>
12 </PropertyGroup>
13
14 <ItemGroup>
15 <Content Include="TestData\TypesFile\example.txt" CopyToOutputDirectory="PreserveNewest" />
16 <Content Include="TestData\TypesFile\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
17 <Content Include="TestData\TypesFile\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
18 <Content Include="TestData\TypesFile\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
19 </ItemGroup>
20
21 <ItemGroup>
22 <ProjectReference Include="..\..\wixext\WixToolset.Powershell.wixext.csproj" />
23 </ItemGroup>
24
25 <ItemGroup>
26 <PackageReference Include="WixToolset.Core.TestPackage" Version="4.0.*" PrivateAssets="all" />
27 </ItemGroup>
28
29 <ItemGroup>
30 <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" />
31 </ItemGroup>
32
33 <ItemGroup>
34 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
35 <PackageReference Include="xunit" Version="2.4.0" />
36 <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
37 </ItemGroup>
38</Project>
diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs
index 61eb287c..200d3fb4 100644
--- a/src/wixext/PSCompiler.cs
+++ b/src/wixext/PSCompiler.cs
@@ -1,30 +1,24 @@
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 2
3namespace WixToolset.Extensions 3namespace WixToolset.PowerShell
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Globalization; 7 using System.Globalization;
8 using System.Xml.Linq; 8 using System.Xml.Linq;
9 using WixToolset.Data; 9 using WixToolset.Data;
10 using WixToolset.Data.Rows; 10 using WixToolset.Data.Tuples;
11 using WixToolset.Extensibility; 11 using WixToolset.Extensibility;
12 12
13 /// <summary> 13 /// <summary>
14 /// The compiler for the WiX Toolset Internet Information Services Extension. 14 /// The compiler for the WiX Toolset PowerShell Extension.
15 /// </summary> 15 /// </summary>
16 public sealed class PSCompiler : CompilerExtension 16 public sealed class PSCompiler : BaseCompilerExtension
17 { 17 {
18 private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}"; 18 private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}";
19 private const string VarPrefix = "PSVersionMajor"; 19 private const string VarPrefix = "PSVersionMajor";
20 20
21 /// <summary> 21 public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/powershell";
22 /// Instantiate a new PSCompiler.
23 /// </summary>
24 public PSCompiler()
25 {
26 this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/powershell";
27 }
28 22
29 /// <summary> 23 /// <summary>
30 /// Processes an element for the Compiler. 24 /// Processes an element for the Compiler.
@@ -33,7 +27,7 @@ namespace WixToolset.Extensions
33 /// <param name="parentElement">Parent element of element to process.</param> 27 /// <param name="parentElement">Parent element of element to process.</param>
34 /// <param name="element">Element to process.</param> 28 /// <param name="element">Element to process.</param>
35 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> 29 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
36 public override void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context) 30 public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
37 { 31 {
38 switch (parentElement.Name.LocalName) 32 switch (parentElement.Name.LocalName)
39 { 33 {
@@ -44,25 +38,25 @@ namespace WixToolset.Extensions
44 switch (element.Name.LocalName) 38 switch (element.Name.LocalName)
45 { 39 {
46 case "FormatsFile": 40 case "FormatsFile":
47 this.ParseExtensionsFile(element, "Formats", fileId, componentId); 41 this.ParseExtensionsFile(intermediate, section, element, "Formats", fileId, componentId);
48 break; 42 break;
49 43
50 case "SnapIn": 44 case "SnapIn":
51 this.ParseSnapInElement(element, fileId, componentId); 45 this.ParseSnapInElement(intermediate, section, element, fileId, componentId);
52 break; 46 break;
53 47
54 case "TypesFile": 48 case "TypesFile":
55 this.ParseExtensionsFile(element, "Types", fileId, componentId); 49 this.ParseExtensionsFile(intermediate, section, element, "Types", fileId, componentId);
56 break; 50 break;
57 51
58 default: 52 default:
59 this.Core.UnexpectedElement(parentElement, element); 53 this.ParseHelper.UnexpectedElement(parentElement, element);
60 break; 54 break;
61 } 55 }
62 break; 56 break;
63 57
64 default: 58 default:
65 this.Core.UnexpectedElement(parentElement, element); 59 this.ParseHelper.UnexpectedElement(parentElement, element);
66 break; 60 break;
67 } 61 }
68 } 62 }
@@ -73,9 +67,9 @@ namespace WixToolset.Extensions
73 /// <param name="node">Element to parse.</param> 67 /// <param name="node">Element to parse.</param>
74 /// <param name="fileId">Identifier for parent file.</param> 68 /// <param name="fileId">Identifier for parent file.</param>
75 /// <param name="componentId">Identifier for parent component.</param> 69 /// <param name="componentId">Identifier for parent component.</param>
76 private void ParseSnapInElement(XElement node, string fileId, string componentId) 70 private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId)
77 { 71 {
78 SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); 72 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
79 string id = null; 73 string id = null;
80 string assemblyName = null; 74 string assemblyName = null;
81 string customSnapInType = null; 75 string customSnapInType = null;
@@ -93,52 +87,52 @@ namespace WixToolset.Extensions
93 switch (attrib.Name.LocalName) 87 switch (attrib.Name.LocalName)
94 { 88 {
95 case "Id": 89 case "Id":
96 id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); 90 id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
97 break; 91 break;
98 92
99 case "CustomSnapInType": 93 case "CustomSnapInType":
100 customSnapInType = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 94 customSnapInType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
101 break; 95 break;
102 96
103 case "Description": 97 case "Description":
104 description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 98 description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
105 break; 99 break;
106 100
107 case "DescriptionIndirect": 101 case "DescriptionIndirect":
108 descriptionIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 102 descriptionIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
109 break; 103 break;
110 104
111 case "RequiredPowerShellVersion": 105 case "RequiredPowerShellVersion":
112 string ver = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); 106 string ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib);
113 requiredPowerShellVersion = new Version(ver); 107 requiredPowerShellVersion = new Version(ver);
114 break; 108 break;
115 109
116 case "Vendor": 110 case "Vendor":
117 vendor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 111 vendor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
118 break; 112 break;
119 113
120 case "VendorIndirect": 114 case "VendorIndirect":
121 vendorIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 115 vendorIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
122 break; 116 break;
123 117
124 case "Version": 118 case "Version":
125 version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); 119 version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib);
126 break; 120 break;
127 121
128 default: 122 default:
129 this.Core.UnexpectedAttribute(node, attrib); 123 this.ParseHelper.UnexpectedAttribute(node, attrib);
130 break; 124 break;
131 } 125 }
132 } 126 }
133 else 127 else
134 { 128 {
135 this.Core.ParseExtensionAttribute(node, attrib); 129 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
136 } 130 }
137 } 131 }
138 132
139 if (null == id) 133 if (null == id)
140 { 134 {
141 this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); 135 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
142 } 136 }
143 137
144 // Default to require PowerShell 1.0. 138 // Default to require PowerShell 1.0.
@@ -161,19 +155,19 @@ namespace WixToolset.Extensions
161 switch (child.Name.LocalName) 155 switch (child.Name.LocalName)
162 { 156 {
163 case "FormatsFile": 157 case "FormatsFile":
164 this.ParseExtensionsFile(child, "Formats", id, componentId); 158 this.ParseExtensionsFile(intermediate, section, child, "Formats", id, componentId);
165 break; 159 break;
166 case "TypesFile": 160 case "TypesFile":
167 this.ParseExtensionsFile(child, "Types", id, componentId); 161 this.ParseExtensionsFile(intermediate, section, child, "Types", id, componentId);
168 break; 162 break;
169 default: 163 default:
170 this.Core.UnexpectedElement(node, child); 164 this.ParseHelper.UnexpectedElement(node, child);
171 break; 165 break;
172 } 166 }
173 } 167 }
174 else 168 else
175 { 169 {
176 this.Core.ParseExtensionElement(node, child); 170 this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child);
177 } 171 }
178 } 172 }
179 173
@@ -182,54 +176,54 @@ namespace WixToolset.Extensions
182 // for use in Formats and Types files. PowerShell v2 still uses 1. 176 // for use in Formats and Types files. PowerShell v2 still uses 1.
183 int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; 177 int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major;
184 178
185 WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); 179 var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id));
186 wixVariableRow.Id = String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id); 180 var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable", variableId);
187 wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); 181 wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture);
188 wixVariableRow.Overridable = false; 182 wixVariableRow.Overridable = false;
189 183
190 int registryRoot = 2; // HKLM 184 int registryRoot = 2; // HKLM
191 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); 185 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id);
192 186
193 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); 187 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false);
194 188
195 // set the assembly name automatically when binding. 189 // set the assembly name automatically when binding.
196 // processorArchitecture is not handled correctly by PowerShell v1.0 190 // processorArchitecture is not handled correctly by PowerShell v1.0
197 // so format the assembly name explicitly. 191 // so format the assembly name explicitly.
198 assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); 192 assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId);
199 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); 193 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false);
200 194
201 if (null != customSnapInType) 195 if (null != customSnapInType)
202 { 196 {
203 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); 197 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false);
204 } 198 }
205 199
206 if (null != description) 200 if (null != description)
207 { 201 {
208 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); 202 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false);
209 } 203 }
210 204
211 if (null != descriptionIndirect) 205 if (null != descriptionIndirect)
212 { 206 {
213 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); 207 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false);
214 } 208 }
215 209
216 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); 210 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false);
217 211
218 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); 212 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false);
219 213
220 if (null != vendor) 214 if (null != vendor)
221 { 215 {
222 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); 216 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false);
223 } 217 }
224 218
225 if (null != vendorIndirect) 219 if (null != vendorIndirect)
226 { 220 {
227 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); 221 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false);
228 } 222 }
229 223
230 if (null != version) 224 if (null != version)
231 { 225 {
232 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); 226 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false);
233 } 227 }
234 } 228 }
235 229
@@ -240,9 +234,9 @@ namespace WixToolset.Extensions
240 /// <param name="valueName">Registry value name.</param> 234 /// <param name="valueName">Registry value name.</param>
241 /// <param name="id">Idendifier for parent file or snap-in.</param> 235 /// <param name="id">Idendifier for parent file or snap-in.</param>
242 /// <param name="componentId">Identifier for parent component.</param> 236 /// <param name="componentId">Identifier for parent component.</param>
243 private void ParseExtensionsFile(XElement node, string valueName, string id, string componentId) 237 private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId)
244 { 238 {
245 SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); 239 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
246 string fileId = null; 240 string fileId = null;
247 string snapIn = null; 241 string snapIn = null;
248 242
@@ -253,38 +247,38 @@ namespace WixToolset.Extensions
253 switch (attrib.Name.LocalName) 247 switch (attrib.Name.LocalName)
254 { 248 {
255 case "FileId": 249 case "FileId":
256 fileId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 250 fileId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
257 snapIn = id; 251 snapIn = id;
258 break; 252 break;
259 253
260 case "SnapIn": 254 case "SnapIn":
261 fileId = id; 255 fileId = id;
262 snapIn = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 256 snapIn = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
263 break; 257 break;
264 258
265 default: 259 default:
266 this.Core.UnexpectedAttribute(node, attrib); 260 this.ParseHelper.UnexpectedAttribute(node, attrib);
267 break; 261 break;
268 } 262 }
269 } 263 }
270 else 264 else
271 { 265 {
272 this.Core.ParseExtensionAttribute(node, attrib); 266 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
273 } 267 }
274 } 268 }
275 269
276 if (null == fileId && null == snapIn) 270 if (null == fileId && null == snapIn)
277 { 271 {
278 this.Core.OnMessage(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); 272 this.Messaging.Write(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName));
279 } 273 }
280 274
281 this.Core.ParseForExtensionElements(node); 275 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
282 276
283 int registryRoot = 2; // HKLM 277 int registryRoot = 2; // HKLM
284 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); 278 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn);
285 279
286 this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId); 280 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId);
287 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); 281 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false);
288 } 282 }
289 } 283 }
290} 284}
diff --git a/src/wixext/PSErrors.cs b/src/wixext/PSErrors.cs
new file mode 100644
index 00000000..704cf5cd
--- /dev/null
+++ b/src/wixext/PSErrors.cs
@@ -0,0 +1,30 @@
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
3namespace WixToolset.PowerShell
4{
5 using System.Resources;
6 using WixToolset.Data;
7
8 public static class PSErrors
9 {
10 public static Message NeitherIdSpecified(SourceLineNumber sourceLineNumbers, string element)
11 {
12 return Message(sourceLineNumbers, Ids.NeitherIdSpecified, "Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element.", element);
13 }
14
15 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
16 {
17 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
18 }
19
20 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
21 {
22 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args);
23 }
24
25 public enum Ids
26 {
27 NeitherIdSpecified = 5301,
28 }
29 }
30}
diff --git a/src/wixext/PSExtensionData.cs b/src/wixext/PSExtensionData.cs
index 578bda91..d9a2d2e7 100644
--- a/src/wixext/PSExtensionData.cs
+++ b/src/wixext/PSExtensionData.cs
@@ -1,34 +1,30 @@
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 2
3namespace WixToolset.Extensions 3namespace WixToolset.PowerShell
4{ 4{
5 using System;
6 using System.Reflection;
7 using WixToolset.Data; 5 using WixToolset.Data;
8 using WixToolset.Extensibility; 6 using WixToolset.Extensibility;
9 7
10 /// <summary> 8 /// <summary>
11 /// The WiX Toolset PowerShell Extension. 9 /// The WiX Toolset PowerShell Extension.
12 /// </summary> 10 /// </summary>
13 public sealed class PSExtensionData : ExtensionData 11 public sealed class PSExtensionData : BaseExtensionData
14 { 12 {
15 /// <summary> 13 /// <summary>
16 /// Gets the library associated with this extension. 14 /// Gets the default culture.
17 /// </summary> 15 /// </summary>
18 /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> 16 /// <value>The default culture.</value>
19 /// <returns>The loaded library.</returns> 17 public override string DefaultCulture => "en-US";
20 public override Library GetLibrary(TableDefinitionCollection tableDefinitions) 18
19 public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition)
21 { 20 {
22 return PSExtensionData.GetExtensionLibrary(tableDefinitions); 21 tupleDefinition = null;
22 return tupleDefinition != null;
23 } 23 }
24 24
25 /// <summary> 25 public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions)
26 /// Internal mechanism to access the extension's library.
27 /// </summary>
28 /// <returns>Extension's library.</returns>
29 internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions)
30 { 26 {
31 return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.ps.wixlib", tableDefinitions); 27 return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", tupleDefinitions);
32 } 28 }
33 } 29 }
34} 30}
diff --git a/src/wixext/PSWarnings.cs b/src/wixext/PSWarnings.cs
new file mode 100644
index 00000000..9be14948
--- /dev/null
+++ b/src/wixext/PSWarnings.cs
@@ -0,0 +1,30 @@
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
3namespace WixToolset.PowerShell
4{
5 using System.Resources;
6 using WixToolset.Data;
7
8 public static class PSWarnings
9 {
10 public static Message DeprecatedAssemblyNameAttribute(SourceLineNumber sourceLineNumbers)
11 {
12 return Message(sourceLineNumbers, Ids.DeprecatedAssemblyNameAttribute, "The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically.");
13 }
14
15 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
16 {
17 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
18 }
19
20 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
21 {
22 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, resourceManager, resourceName, args);
23 }
24
25 public enum Ids
26 {
27 DeprecatedAssemblyNameAttribute = 5350,
28 }
29 }
30}
diff --git a/src/wixext/PowerShellExtensionFactory.cs b/src/wixext/PowerShellExtensionFactory.cs
new file mode 100644
index 00000000..22a4ad88
--- /dev/null
+++ b/src/wixext/PowerShellExtensionFactory.cs
@@ -0,0 +1,17 @@
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
3namespace WixToolset.PowerShell
4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Extensibility;
8
9 public class PowerShellExtensionFactory : BaseExtensionFactory
10 {
11 protected override IEnumerable<Type> ExtensionTypes => new[]
12 {
13 typeof(PSCompiler),
14 typeof(PSExtensionData),
15 };
16 }
17}
diff --git a/src/wixext/WixPSExtension.csproj b/src/wixext/WixPSExtension.csproj
deleted file mode 100644
index f9349ef1..00000000
--- a/src/wixext/WixPSExtension.csproj
+++ /dev/null
@@ -1,43 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4
5<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
6 <PropertyGroup>
7 <ProjectGuid>{6F1482DF-1598-4D88-BDAA-B9D0E0242139}</ProjectGuid>
8 <AssemblyName>WixPSExtension</AssemblyName>
9 <OutputType>Library</OutputType>
10 <RootNamespace>WixToolset.Extensions</RootNamespace>
11 </PropertyGroup>
12 <ItemGroup>
13 <Compile Include="AssemblyInfo.cs" />
14 <Compile Include="PSCompiler.cs" />
15 <Compile Include="PSExtensionData.cs" />
16 <MsgGenSource Include="Data\messages.xml">
17 <ResourcesLogicalName>$(RootNamespace).Data.Messages.resources</ResourcesLogicalName>
18 </MsgGenSource>
19 <EmbeddedFlattenedResource Include="Xsd\ps.xsd">
20 <LogicalName>$(RootNamespace).Xsd.ps.xsd</LogicalName>
21 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22 </EmbeddedFlattenedResource>
23 <XsdGenSource Include="Xsd\ps.xsd">
24 <CommonNamespace>WixToolset.Data.Serialize</CommonNamespace>
25 <Namespace>WixToolset.Extensions.Serialize.PS</Namespace>
26 </XsdGenSource>
27 <EmbeddedResource Include="$(OutputPath)\ps.wixlib">
28 <Link>Data\ps.wixlib</Link>
29 </EmbeddedResource>
30 </ItemGroup>
31 <ItemGroup>
32 <Reference Include="System" />
33 <Reference Include="System.Xml" />
34 <ProjectReference Include="..\..\..\libs\WixToolset.Data\WixToolset.Data.csproj" />
35 <ProjectReference Include="..\..\..\libs\WixToolset.Extensibility\WixToolset.Extensibility.csproj" />
36 <ProjectReference Include="..\..\..\tools\wix\Wix.csproj" />
37 <ProjectReference Include="..\wixlib\PSExtension.wixproj">
38 <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
39 </ProjectReference>
40 <Reference Include="System.Xml.Linq" />
41 </ItemGroup>
42 <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" />
43</Project>
diff --git a/src/wixext/WixToolset.PowerShell.wixext.csproj b/src/wixext/WixToolset.PowerShell.wixext.csproj
new file mode 100644
index 00000000..666e8aba
--- /dev/null
+++ b/src/wixext/WixToolset.PowerShell.wixext.csproj
@@ -0,0 +1,29 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netstandard2.0</TargetFramework>
7 <RootNamespace>WixToolset.PowerShell</RootNamespace>
8 <Description>WiX Toolset PowerShell Extension</Description>
9 <Title>WiX Toolset PowerShell Extension</Title>
10 <IsTool>true</IsTool>
11 <ContentTargetFolders>build</ContentTargetFolders>
12 </PropertyGroup>
13 <ItemGroup>
14 <Content Include="$(MSBuildThisFileName).targets" />
15 <Content Include="ps.xsd" PackagePath="tools" />
16 <EmbeddedResource Include="$(OutputPath)..\powershell.wixlib" />
17 </ItemGroup>
18 <ItemGroup>
19 <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" PrivateAssets="all" />
20 </ItemGroup>
21
22 <ItemGroup>
23 <ProjectReference Include="..\wixlib\powershell.wixproj" ReferenceOutputAssembly="false" Condition=" '$(NCrunch)'=='' " />
24 </ItemGroup>
25
26 <ItemGroup>
27 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" />
28 </ItemGroup>
29</Project>
diff --git a/src/wixext/WixToolset.PowerShell.wixext.targets b/src/wixext/WixToolset.PowerShell.wixext.targets
new file mode 100644
index 00000000..bf06e1e4
--- /dev/null
+++ b/src/wixext/WixToolset.PowerShell.wixext.targets
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
5 <PropertyGroup>
6 <WixToolsetPowerShellWixextPath Condition=" '$(WixToolsetPowerShellWixextPath)' == '' ">$(MSBuildThisFileDirectory)..\tools\WixToolset.PowerShell.wixext.dll</WixToolsetPowerShellWixextPath>
7 </PropertyGroup>
8 <ItemGroup>
9 <WixExtension Include="$(WixToolsetPowerShellWixextPath)" />
10 </ItemGroup>
11</Project>
diff --git a/src/wixext/messages.xml b/src/wixext/messages.xml
deleted file mode 100644
index ef715640..00000000
--- a/src/wixext/messages.xml
+++ /dev/null
@@ -1,20 +0,0 @@
1<?xml version='1.0' encoding='utf-8'?>
2<!-- 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. -->
3
4
5<Messages Namespace="WixToolset.Extensions" Resources="Data.Messages" xmlns="http://schemas.microsoft.com/genmsgs/2004/07/messages">
6 <Class Name="PSErrors" ContainerName="PSErrorEventArgs" BaseContainerName="WixErrorEventArgs">
7 <Message Id="NeitherIdSpecified" Number="5301">
8 <Instance>Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element.
9 <Parameter Type="System.String" Name="element" />
10 </Instance>
11 </Message>
12 </Class>
13 <Class Name="PSWarnings" ContainerName="PSWarningEventArgs" BaseContainerName="WixWarningEventArgs">
14 <Message Id="DeprecatedAssemblyNameAttribute" Number="5350">
15 <Instance>The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically.</Instance>
16 </Message>
17 </Class>
18 <Class Name="PSVerboses" ContainerName="PSVerboseEventArgs" BaseContainerName="WixVerboseEventArgs">
19 </Class>
20</Messages>
diff --git a/src/wixlib/PSExtension.wixproj b/src/wixlib/PSExtension.wixproj
deleted file mode 100644
index da2b6463..00000000
--- a/src/wixlib/PSExtension.wixproj
+++ /dev/null
@@ -1,19 +0,0 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<!-- 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. -->
3
4
5<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
6 <PropertyGroup>
7 <ProjectGuid>{9d4ccdfc-840c-4d4e-a9b0-3d6015480645}</ProjectGuid>
8 <OutputName>ps</OutputName>
9 <OutputType>Library</OutputType>
10 <BindFiles>true</BindFiles>
11 <Pedantic>true</Pedantic>
12 </PropertyGroup>
13
14 <ItemGroup>
15 <Compile Include="PSExtension.wxs" />
16 </ItemGroup>
17
18 <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" />
19</Project>
diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config
new file mode 100644
index 00000000..7964daed
--- /dev/null
+++ b/src/wixlib/packages.config
@@ -0,0 +1,5 @@
1<?xml version="1.0" encoding="utf-8"?>
2<packages>
3 <package id="Nerdbank.GitVersioning" version="2.1.65" developmentDependency="true" targetFramework="net40" />
4 <package id="WixToolset.MSBuild" version="4.0.0-build-0035" developmentDependency="true" targetFramework="net40" />
5</packages> \ No newline at end of file
diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj
new file mode 100644
index 00000000..eba605dc
--- /dev/null
+++ b/src/wixlib/powershell.wixproj
@@ -0,0 +1,35 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<!-- 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. -->
3<Project DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0">
4 <Import Project="..\..\packages\WixToolset.MSBuild.4.0.0-build-0035\build\WixToolset.MSBuild.props" Condition="Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0035\build\WixToolset.MSBuild.props')" />
5 <Import Project="..\FindLocalWix.props" />
6 <PropertyGroup>
7 <ProjectGuid>{9d4ccdfc-840c-4d4e-a9b0-3d6015480645}</ProjectGuid>
8 <OutputName>powershell</OutputName>
9 <OutputType>Library</OutputType>
10 <BindFiles>true</BindFiles>
11 <Pedantic>true</Pedantic>
12 </PropertyGroup>
13
14 <ItemGroup>
15 <Compile Include="PSExtension.wxs" />
16 </ItemGroup>
17
18 <ItemGroup>
19 <None Include="packages.config" />
20 </ItemGroup>
21
22 <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' AND Exists('$(WixTargetsPath)') " />
23 <Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets') " />
24 <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
25 <Error Text="WiX Toolset build tools (v4.0 or later) must be installed to build this project. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
26 </Target>
27 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
28 <PropertyGroup>
29 <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>
30 </PropertyGroup>
31 <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'))" />
32 <Error Condition="!Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0035\build\WixToolset.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.MSBuild.4.0.0-build-0035\build\WixToolset.MSBuild.props'))" />
33 </Target>
34 <Import Project="..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" />
35</Project>
diff --git a/version.json b/version.json
new file mode 100644
index 00000000..5f857771
--- /dev/null
+++ b/version.json
@@ -0,0 +1,11 @@
1{
2 "version": "4.0",
3 "publicReleaseRefSpec": [
4 "^refs/heads/master$"
5 ],
6 "cloudBuild": {
7 "buildNumber": {
8 "enabled": true
9 }
10 }
11}