Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CustomAction1/CustomAction.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<!--
Use supportedRuntime tags to explicitly specify the version(s) of the .NET Framework runtime that
the custom action should run on. If no versions are specified, the chosen version of the runtime
will be the "best" match to what WixToolset.Dtf.CustomAction.dll was built against.

WARNING: leaving the version unspecified is dangerous as it introduces a risk of compatibility
problems with future versions of the .NET Framework runtime. It is highly recommended that you specify
only the version(s) of the .NET Framework runtime that you have tested against.

For more information https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/startup-element
-->
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
18 changes: 18 additions & 0 deletions CustomAction1/CustomAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using WixToolset.Dtf.WindowsInstaller;

namespace CustomAction1
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");

return ActionResult.Success;
}
}
}
14 changes: 14 additions & 0 deletions CustomAction1/CustomAction1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Content Include="CustomAction.config" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="WixToolset.Dtf.CustomAction" Version="5.0.0" />
<PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="5.0.0" />
</ItemGroup>
</Project>
58 changes: 7 additions & 51 deletions PowerShellActions/PowerShellActions.csproj
Original file line number Diff line number Diff line change
@@ -1,58 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0A83F788-68C1-4533-8732-6B8E3FBC5282}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PowerShellActions</RootNamespace>
<AssemblyName>PowerShellActions</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<WixCATargetsPath Condition=" '$(WixCATargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.CA.targets</WixCATargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.Deployment.WindowsInstaller" />
<Content Include="CustomAction.config" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<Compile Include="CustomAction.cs" />
<Compile Include="IExitCode.cs" />
<Compile Include="PowerShellTask.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WixHost.cs" />
<Compile Include="WixHostRawUserInterface.cs" />
<Compile Include="WixHostUserInterface.cs" />
<Content Include="CustomAction.config" />
<PackageReference Include="WixToolset.Dtf.CustomAction" Version="4.0.5" />
<PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.5" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(WixCATargetsPath)" />
</Project>
179 changes: 53 additions & 126 deletions PowerShellLibrary/Library.wxs
Original file line number Diff line number Diff line change
@@ -1,160 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<Binary Id="CA_DLL" SourceFile="$(var.PowerShellActions.TargetDir)PowerShellActions.CA.dll" />

<CustomAction Id="PowerShellScriptsImmediate"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsImmediate"
Execute="immediate"
Return="check" />

<CustomAction Id="PowerShellScriptsDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsDeferred"
Impersonate="yes"
Execute="deferred"
Return="check" />
<CustomAction Id="PowerShellScriptsImmediate" DllEntry="PowerShellScriptsImmediate" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsDeferred" DllEntry="PowerShellScriptsDeferred" Impersonate="yes" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsUninstall"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsUninstall"
Execute="immediate"
Return="check" />

<CustomAction Id="PowerShellScriptsUninstallDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsUninstallDeferred"
Impersonate="yes"
Execute="deferred"
Return="check" />

<CustomAction Id="PowerShellScriptsElevatedImmediate"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsElevatedImmediate"
Execute="immediate"
Return="check" />

<CustomAction Id="PowerShellScriptsElevatedDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsElevatedDeferred"
Impersonate="no"
Execute="deferred"
Return="check" />

<CustomAction Id="PowerShellScriptsElevatedUninstall"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsElevatedUninstall"
Execute="immediate"
Return="check" />

<CustomAction Id="PowerShellScriptsElevatedUninstallDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellScriptsElevatedUninstallDeferred"
Impersonate="no"
Execute="deferred"
Return="check" />
<CustomAction Id="PowerShellScriptsUninstall" DllEntry="PowerShellScriptsUninstall" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsUninstallDeferred" DllEntry="PowerShellScriptsUninstallDeferred" Impersonate="yes" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsElevatedImmediate" DllEntry="PowerShellScriptsElevatedImmediate" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsElevatedDeferred" DllEntry="PowerShellScriptsElevatedDeferred" Impersonate="no" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsElevatedUninstall" DllEntry="PowerShellScriptsElevatedUninstall" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellScriptsElevatedUninstallDeferred" DllEntry="PowerShellScriptsElevatedUninstallDeferred" Impersonate="no" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesImmediate"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesImmediate"
Execute="immediate"
Return="check" />

<CustomAction Id="PowerShellFilesDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesDeferred"
Impersonate="yes"
Execute="deferred"
Return="check" />

<CustomAction Id="PowerShellFilesUninstall"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesUninstall"
Execute="immediate"
Return="check" />
<CustomAction Id="PowerShellFilesImmediate" DllEntry="PowerShellFilesImmediate" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesDeferred" DllEntry="PowerShellFilesDeferred" Impersonate="yes" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesUninstall" DllEntry="PowerShellFilesUninstall" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesUninstallDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesUninstallDeferred"
Impersonate="yes"
Execute="deferred"
Return="check" />

<CustomAction Id="PowerShellFilesElevatedImmediate"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesElevatedImmediate"
Execute="immediate"
Return="check" />
<CustomAction Id="PowerShellFilesUninstallDeferred" DllEntry="PowerShellFilesUninstallDeferred" Impersonate="yes" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesElevatedImmediate" DllEntry="PowerShellFilesElevatedImmediate" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesElevatedDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesElevatedDeferred"
Impersonate="no"
Execute="deferred"
Return="check" />

<CustomAction Id="PowerShellFilesElevatedUninstall"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesElevatedUninstall"
Execute="immediate"
Return="check" />

<CustomAction Id="PowerShellFilesElevatedUninstallDeferred"
BinaryKey="CA_DLL"
DllEntry="PowerShellFilesElevatedUninstallDeferred"
Impersonate="no"
Execute="deferred"
Return="check" />
<CustomAction Id="PowerShellFilesElevatedDeferred" DllEntry="PowerShellFilesElevatedDeferred" Impersonate="no" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesElevatedUninstall" DllEntry="PowerShellFilesElevatedUninstall" Execute="immediate" Return="check" BinaryRef="CA_DLL" />

<CustomAction Id="PowerShellFilesElevatedUninstallDeferred" DllEntry="PowerShellFilesElevatedUninstallDeferred" Impersonate="no" Execute="deferred" Return="check" BinaryRef="CA_DLL" />

<InstallExecuteSequence>
<!-- These are the 'immediate' actions that prep the data for the 'deferred' actions-->
<Custom Action="PowerShellScriptsImmediate" Before="PowerShellScriptsDeferred" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellScriptsImmediate" Before="PowerShellScriptsDeferred" Overridable="yes" Condition="NOT Installed" />

<Custom Action="PowerShellScriptsElevatedImmediate" Before="PowerShellScriptsElevatedDeferred" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellScriptsElevatedImmediate" Before="PowerShellScriptsElevatedDeferred" Overridable="yes" Condition="NOT Installed" />

<Custom Action="PowerShellFilesImmediate" Before="PowerShellFilesDeferred" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellFilesImmediate" Before="PowerShellFilesDeferred" Overridable="yes" Condition="NOT Installed" />

<Custom Action="PowerShellFilesElevatedImmediate" Before="PowerShellFilesElevatedDeferred" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellFilesElevatedImmediate" Before="PowerShellFilesElevatedDeferred" Overridable="yes" Condition="NOT Installed" />

<!-- 'Deferred' actions -->
<Custom Action="PowerShellScriptsDeferred" After="InstallFiles" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellScriptsDeferred" After="InstallFiles" Overridable="yes" Condition="NOT Installed" />

<Custom Action="PowerShellScriptsElevatedDeferred" After="InstallFiles" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellScriptsElevatedDeferred" After="InstallFiles" Overridable="yes" Condition="NOT Installed" />

<Custom Action="PowerShellFilesDeferred" After="InstallFiles" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellFilesDeferred" After="InstallFiles" Overridable="yes" Condition="NOT Installed" />

<Custom Action="PowerShellFilesElevatedDeferred" After="InstallFiles" Overridable="yes">NOT Installed</Custom>
<Custom Action="PowerShellFilesElevatedDeferred" After="InstallFiles" Overridable="yes" Condition="NOT Installed" />

<!-- 'Uninstall immediate' actions -->
<Custom Action="PowerShellScriptsUninstall" Before="PowerShellScriptsUninstallDeferred" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellScriptsUninstall" Before="PowerShellScriptsUninstallDeferred" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<Custom Action="PowerShellScriptsElevatedUninstall" Before="PowerShellScriptsElevatedUninstallDeferred" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellScriptsElevatedUninstall" Before="PowerShellScriptsElevatedUninstallDeferred" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<Custom Action="PowerShellFilesUninstall" Before="PowerShellFilesUninstallDeferred" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellFilesUninstall" Before="PowerShellFilesUninstallDeferred" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<Custom Action="PowerShellFilesElevatedUninstall" Before="PowerShellFilesElevatedUninstallDeferred" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellFilesElevatedUninstall" Before="PowerShellFilesElevatedUninstallDeferred" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<!-- 'Uninstall deferred' actions -->
<Custom Action="PowerShellScriptsUninstallDeferred" After="RemoveFiles" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellScriptsUninstallDeferred" After="RemoveFiles" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<Custom Action="PowerShellScriptsElevatedUninstallDeferred" After="RemoveFiles" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellScriptsElevatedUninstallDeferred" After="RemoveFiles" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<Custom Action="PowerShellFilesUninstallDeferred" After="RemoveFiles" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellFilesUninstallDeferred" After="RemoveFiles" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />

<Custom Action="PowerShellFilesElevatedUninstallDeferred" After="RemoveFiles" Overridable="yes">REMOVE="ALL"</Custom>
<Custom Action="PowerShellFilesElevatedUninstallDeferred" After="RemoveFiles" Overridable="yes" Condition="REMOVE=&quot;ALL&quot;" />
</InstallExecuteSequence>

<UI>
<ProgressText Action="PowerShellFilesDeferred">PowerShell Files</ProgressText>
<ProgressText Action="PowerShellScriptsDeferred">PowerShell Inline</ProgressText>
<ProgressText Action="PowerShellScriptsElevatedDeferred">PowerShell Inline (elevated)</ProgressText>
<ProgressText Action="PowerShellFilesElevatedDeferred">PowerShell Files (elevated)</ProgressText>

<ProgressText Action="PowerShellFilesUninstallDeferred">PowerShell Uninstall Files</ProgressText>
<ProgressText Action="PowerShellScriptsUninstallDeferred">PowerShell Uninstall Inline</ProgressText>
<ProgressText Action="PowerShellScriptsElevatedUninstallDeferred">PowerShell Uninstall Inline (elevated)</ProgressText>
<ProgressText Action="PowerShellFilesElevatedUninstallDeferred">PowerShell Uninstall Files (elevated)</ProgressText>
<ProgressText Action="PowerShellFilesDeferred" Message="PowerShell Files" />
<ProgressText Action="PowerShellScriptsDeferred" Message="PowerShell Inline" />
<ProgressText Action="PowerShellScriptsElevatedDeferred" Message="PowerShell Inline (elevated)" />
<ProgressText Action="PowerShellFilesElevatedDeferred" Message="PowerShell Files (elevated)" />

<ProgressText Action="PowerShellFilesUninstallDeferred" Message="PowerShell Uninstall Files" />
<ProgressText Action="PowerShellScriptsUninstallDeferred" Message="PowerShell Uninstall Inline" />
<ProgressText Action="PowerShellScriptsElevatedUninstallDeferred" Message="PowerShell Uninstall Inline (elevated)" />
<ProgressText Action="PowerShellFilesElevatedUninstallDeferred" Message="PowerShell Uninstall Files (elevated)" />
</UI>
</Fragment>
</Wix>
Loading
Loading