Search code examples
asp.netjenkinsmsbuildcontinuous-integrationmsdeploy

Deploy from command line using MSBUILD and or MSDEPLOY (.NET 3.5)


I'm trying to get my website deployed by a Jenkins job.

I'm using the following command line sentence, with no success:

"C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe" myproj.csproj /p:DeployOnBuild=true

I've also tried:

"C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe" myproj.csproj  /p:Configuration=Debug /p:OutputPath="obj\debug" /p:DeployIisAppPath="Default Web Site/demo" 

None works although my project is compiled properly.

WHen I go to C:\inetpub\wwwroot nothing new is there. I want my site to start running and be accesible from my browser in Localhost.


Solution

  • You can use MSDeploy to deploy your web app using the following MSBuild arguments

    /p:Configuration=release
    /p:DeployOnBuild=True 
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://targetServer:8172/MsDeploy.axd
    /p:DeployIisAppPath=MySite 
    /p:AllowUntrustedCertificate=True
    /p:Username=
    /p:AuthType=NTLM
    

    MSDeploy, however, has proven to be better solution for us. We use MSBuild to create an MSDeploy package and then we can deploy that package to many environments using MSDeploy.exe. Build once, deploy many. Here is an overview of WebDeploy which may be helpful:

    http://dotnetcatch.com/2016/02/25/the-anatomy-of-a-webdeploy-package/