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

Intro

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.

Set-up

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.

There are some subtle difference if using on .net Framework or .net/.net Core so make sure you read the intro notes on the scripts. 

Auto-Versioning (two scripts required)

PreBuild.bat:

psReplace.ps1:

Auto Deployment:

PostBuild.bat:

 

About stigzler 48 Articles
Chief crook and wattle bosher.

Be the first to comment

Leave a Reply

Your email address will not be published.


*