No Image

Agile DevOps – Case of using Jenkins for multiple sites, implementations, and environments for .NET Cloud Apps (Part-2)

With multiple projects created on different versions of Visual Studio, we forced the build to compile on a single target VS version using the /p and the /tv command line parameter.

Below is an example of the msbuild commands called in sequence to build all the project files with specific msbuild targets that work with publishing profiles to package the entire site in a ZIP file. 

msbuild.exe D:\Jenkins\Workspace\DEV\AdminPortal\AdminPortal.csproj /tv:12.0 /p:VisualStudioVersion=14.0 /p:Configuration=Release /t:Package

msbuild.exe D:\Jenkins\Workspace\DEV\CustomerPortal\CustomerPortal.csproj /tv:12.0 /p:VisualStudioVersion=14.0 /p:Configuration=Release /t:Package

msbuild.exe D:\Jenkins\Workspace\DEV\Webservice\Webservice.csproj /tv:12.0 /p:VisualStudioVersion=14.0 /p:Configuration=Release /t:Package
<MSBuild Targets="Package" Projects=...

We created two Jenkins projects. One to build and another to deploy the packages to various environments. The first project was configured to download all code from the git repo, restore the NuGet packages, build all .csproj projects, one at a time, using the /t: Package option and specifying the configuration using the /p: Configuration parameter as given as shown in the above example.

Once all our sites were built successfully the second project was chained in Jenkins to invoke the deployment project to web deploy each site to the DEV environment. We added multiple sites to be deployed sequentially. Below are a few command lines for the deployment.

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='D:\Jenkins\Workspace\DEV\AdminPortal\bin\Package\' -dest:auto,computerName='https://DEVSERVER:8172/msdeploy.axd', userName='DOMAIN\User',password='password',AuthType='Basic',includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"D:\Jenkins\Configs\DEVELOP\AdminPortal\Customer1.SetParameters.xml" -allowUntrusted -preSync:runCommand="C:\Windows\System32\inetsrv\appcmd stop site /" -postSync:runCommand="C:\Windows\System32\inetsrv\appcmd start site /"

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='D:\Jenkins\Workspace\DEV\CustomerPortal\bin\Package\' -dest:auto,computerName='https://DEVSERVER:8172/msdeploy.axd', userName='DOMAIN\User',password='password',AuthType='Basic',includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"D:\Jenkins\Configs\DEVELOP\ CustomerPortal\Customer1.SetParameters.xml" -allowUntrusted -preSync:runCommand="C:\Windows\System32\inetsrv\appcmd stop site /" -postSync:runCommand="C:\Windows\System32\inetsrv\appcmd start site /"

Let’s take a look at the parameters in the web deploy command line from the Customer Portal

-source:package='D:\Jenkins\Workspace\DEV\CustomerPortal\bin\ Package\'

Specify the ZIP package created in the Build process


Specify the Parameters of the destination IIS Server, including UserName and password to connect to the server.


The sync operation synchronizes data between a source and a destination.

-setParamFile:"D:\Jenkins\Configs\DEVELOP\ CustomerPortal\Customer1.SetParameters.xml"

The SetParamters.xml file is very important for us as we use this to get the IIS Application path where the application needs to be deployed, along with the Web.config transformations that we need to do at deploy time. Refer to the section Folder structure of SetParameters.xml for more information.

 -preSync:runCommand="C:\Windows\System32\inetsrv\appcmd stop site /" 

In case you want to run some command on the destination server before the web deploy starts to copy files; you can specify it using the –pre-sync parameter, We are forcing the website to be stopped so that we don’t get any issues in the deploy process. We also faced some ACL issues, so better to stop the site and deploy

-postSync:runCommand="C:\Windows\System32\inetsrv\appcmd start site /"

Need to start the site again, post the deployment process.

Explore more details in (Part 3)