With VS 2012 (and above), those versions have removed the capability to create deployment projects. We use 3rd party tools to build setup/MSI packages at the moment. This works very well for us in our on-prem environments. With the integration of cloud services, we took the approach of consolidating most of the build process and output to our cloud instance. This also means, having the capabilities of hosted (cloud) build controllers to make use of other 3rd party tools (in this case build MSI’s) however, we cannot install additional apps on hosted cloud build controllers. The other approach was to use hybrid solution where we use build services on the cloud however the actual build controller resides on our on-prem infrastructure. This was an approach that I’m willing to take but I’d like to take it further and really push all the mechanisms to the cloud. Further researching, VS 2012 (and above) still has the capability to develop setup projects. The only downside is that: It’s a separate extension in Visual Studio (which is really not a big concern) and that MSBUILD doesn’t support building deployment project files (.VDPROJ).
Luckily, devenv.exe (when used correctly) allows you to build solutions with deployment project files. More importantly, you can run it on a command line and with the right switches, you can build deployment projects files which outputs MSI packages.
First and foremost, use these extension package to install deployment project templates for Visual Studio (2012) and above:
Microsoft Visual Studio 2013 Installer Projects
Further context, I’m not going to elaborate on the steps to create deployment projects using the templates in Visual Studio, however, here’s a very good article that I’m going to reference to get you started:
Visual Studio Create Setup project to deploy web application in IIS
Note that given some of our MSIs are used for deploying web applications (Yes, let’s have the discussion later why we use MSI’s for web deployments J), the article above is suitable for this context.The end result though is generating MSI’s regardless whether it’s a Web or Windows setup project.
Create a powershell script that calls devenv process and invoke parameters for the location of your solution file, project file and configuration (release, debug, etc…)
The exact syntax would be:
Start-Process -FilePath "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv" -ArgumentList "$SolutionPath /build $ConifugrationMode /project $ProjectPath /projectconfig $ConifugrationMode"
Save the powershell script in source control
In our case, we use VSO GIT. The script file doesn’t need to go on any folder structure as you will see later.
Create a build definition in VSO Build
Start of by creating a build definition in VSO. Go to “Builds” in your team project, click on the “+”.
Select Visual Studio. (Note that probably this UI may change given that features and changes do occur more frequently in VSO).
“Deleting” and “Adding” the correct build steps
Given that we’re using devenv process to build the solution and generate the MSI packages, we don’t need the initial steps to build the code with the deployment project. All we need for this example are 2 steps
Run a powershell script:
Publish build artifacts:
Powershell Build Step
The key for this step is to ensure that you provide the correct set of variables for the location for your solution and project file.
Script filename: Basically click on the ellipses and browse through your repository to select the powershell script that runs devenv.exe
Arguments: Make sure that you use the correct configuration variables. Simply copy and paste this line:
.\<yourpowershellscript>.ps1 -SolutionPath “$(Build.Repository.LocalPath)\<locationofthesln>\XXX.sln” -ProjectPath “$(Build.Repository.LocalPath)\<locationofthevdproj>\XXX.VDPROJ” -ConifugrationMode $(BuildConfiguration)
The variables that I used here are:
$(Build.Repository.LocalPath) = this is where the build controller will hold the temporary build files
$(BuildConfiguration) = configuration setting that’s under the “Variables” section for your build:
NOTE: Here’s a complete list of build variables for VSO:
Publish Build Artifacts Step
Contents: select the location where your MSI is located. I used the following syntax since my MSI packages are under setup\release\**
Artifact Name: This is just the name of your drop location.
Complete Build definition
Here’s an image of what it should like including a successful build: