Skip to content

nirbar/PowerShellWixExtension

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PowerShellWixExtension

A Wix Extension for running PowerShell scripts

NuGet Package

NuGet AppVeyor

All ready to add to an existing Wix project. Grab the latest version from https://www.nuget.org/packages/PowerShellWixExtension/

Getting Started

  1. Add a reference to the PowerShellWixExtension.dll in your Wix Setup Project (NuGet package recommended)
  2. Add namespace to .wxs file
    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:powershell="http://schemas.gardiner.net.au/PowerShellWixExtensionSchema">
  1. To execute a .ps1 file that ships with the project
   <powershell:File Id="PSFile1" File="[#TestPs1]" Arguments="&quot;First Argument&quot; 2"/>
  1. To execute inline script use
    <powershell:Script Id="Script2">
      <![CDATA[
        # Write-Host "Number 2";

        for ($i = 1; $i -le 100; $i++) 
        {
          Write-Progress -Activity "Activity" -Status "Status $i% complete" -CurrentOperation "Operation $i" -PercentComplete $i
          Start-Sleep -Milliseconds 5 
        }

        ]]>
    </powershell:Script>

Notes

Custom sequences

You can customise when a set of scripts are run by adding your own element inside your element. eg.

      <InstallExecuteSequence>
        <Custom Action="PowerShellScriptsDeferred" After="RegisterUser">NOT Installed</Custom>
      </InstallExecuteSequence>

The four defined actions are:

  1. PowerShellScriptsDeferred
  2. PowerShellScriptsElevatedDeferred
  3. PowerShellFilesDeferred
  4. PowerShellFilesElevatedDeferred

Inline Scripts

  • Be aware that if your inline script uses square brackets [ ], you'll need to escape them like [\[] [\]] otherwise they will be interpreted as MSI properties (unless that is what you wanted!)

About

Wix Extension for running PowerShell

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 91.8%
  • PowerShell 8.2%