WebDeploy with MSBuild Not Deploying from TeamCity

前端 未结 6 1374
不思量自难忘°
不思量自难忘° 2021-02-08 13:34

I am trying to use MSDeploy to deploy an MVC project to the server using TeamCity. When I do this on my computer in powershell, using the following command:

msbu         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 14:09

    I use MSBuild.exe to package to zip, and MSdeploy.exe to deploy in separate steps.

    To deploy the package.zip file on the command line:

    "C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy.exe" -verb:sync 
         -source:package="C:\Build\MyAppName.Debug.zip" 
         -dest:auto,wmsvc=webservername,username=webdeploy,password=******* 
         -allowUntrusted=true
    

    This command is also worth explaining in detail:

    -verb:sync : makes the web site sync from the source to the destination

    -source:package="C:\Build\MyAppName.Debug.zip" : source is an MSBuild zip file package

    -dest:auto,wmsvc=webservername : use the settings in the package file to deploy to the server. The user account is an OS-level account with permission. The hostname is specified, but not the IIS web site name (which is previously specified in the MSBuild project file in the project properties).

    You can modify parameters based on your configuration. I like it this way because with separate steps, its easier to debug problems.

    Use TeamCity build step and the command line runner.

    Update: If you want an example of how to build the ZIP package using MSBuild, try something like this:

    "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
    MyWebApp/MyWebApp/MyWebApp.csproj
    /T:Package
    /P:Configuration=Debug;PackageLocation="C:\Build\MyWebApp.Debug.zip"
    

    This should work the same on your local PC as well as on the CI server.

提交回复
热议问题