An add-in for Visual Studio that allows you to run a PowerShell script before the build process begins or after it when it completes without errors.

Currently, there's no installation project so you will have to install it manually.

  1. Download the latest release.
  2. Unpack the files out of the VSPowerBatch directory inside the zip file to a location that Visual Studio can look for it, you can check it out by going to the options, the Add-In Security tab, all the available paths are specified there.
  3. The add-in should appear in the Add-In Manager of Visual Studio, if Visual Studio was open, try to restart it.
  4. Finally, enable the add-in, if you want to run it every time just check the Start option.

Where do I put the PowerShell script?

The PowerShell script must be located in the same location of the solution file (.sln) and the name of the file must follow the name of the solution, so if the name is "project.sln" then it should either be "project.pre.ps1" to run it before the build starts or "project.post.ps1" to run it when the build completes.

Macros

Instead of hard-code the solution location and some other meaningful values you can insert macros into the script and it will be translated by the add-in into the necessary values.

Here is the complete list.

Macro Description
%ConfigurationName% The name of the current project configuration, for example, "Debug|Any CPU".
%SolutionDir% The absolute path name of the solution without the file name of the solution.
%SolutionFileName% The file name of the solution.
%SolutionName% The name of the solution.
%SolutionPath% The absolute path name of the solution including the file name of the solution.

All the macros are currently case-sensitive.

Visual Studio Support

It currently set to work on Visual Studio 2012 but it should work on all the versions of Visual Studio, however, you will have to make a tiny modification to the VSPowerBatch.AddIn file and change the version number to the version of Visual Studio you have installed, you can find the correct version number here, at the version history table, you need to copy/paste the internal version value.

Last edited Mar 16 at 5:19 AM by EyalShilony, version 32