Automated Version control and Deployment Pre and Post build scripts for Visual Studio

The scripts below provide an easy way to auto update version numbers as you build in Visual Studio (see the Pre-Build Script) and also to Deploy your builds to a WebServer via a Zip and Manifest file. Fair Warning: this does edit your Application.cs or Application.vb file – so I’d advise make a backup before experimenting. Also, maybe experiment with a dummy project before trying it your production solution??

Set-up

The simplest set-up is for single assembly applications. You should create a new Shared Project in your solution (this essentially just creates a folder in your solution folder and keeps your repos neat!) called BuildScripts. For all scenarios, place the file psReplace.ps1 in this Project. For single assembly applications, both your pre and post build scripts can also go in here.

For Solutions where you may wish to auto-version or auto-deploy more than one assembly, you can create separate BuildScrpits folders in the root of each Project folder. Just ensure you read the notes at the start of each pre + post script and make the necessary changes to the pre and post build script entries in the Build settings in VS.

Auto-Versioning (two scripts required):

PreBuild.bat:

psReplace.ps1:

Deployment:

PoatBuild.bat:

 

About stigzler 47 Articles
Chief crook and wattle bosher.

1 Trackback / Pingback

  1. Automate publishing to your personal NuGet repo – Mago

Leave a Reply

Your email address will not be published.


*