Search code examples
msbuildcommand-line-argumentsmsdeploy

Specifying project name in msdeploy


I've got two web projects in one solution, and I'd like to deploy them both using msbuild and WebDeploy (this happens through a CI server).

Currently, I'm running a command line:

C:\ProjectFolder>msbuild <solution>.sln
    /p:Configuration=<Release>
    /p:OutputPath=bin
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>
    /p:MSDeployPublishMethod=WMSVC

This deploys one project, as expected. But how can I deploy the other as well? There's nowhere in this command line where I specified a project name - why did it choose one project to deploy over the other?

Ideally, I'd be able to deploy two project with the same command, something like

...

    /p:Project=Project1
    /p:DeployIisAppPath=<SiteName>/Project1
    /p:Project=Project2
    /p:DeployIisAppPath=<SiteName>/Project2

But I doubt that's possible. Alternatively, I just want to know how to specify a project name in the command line.


Solution

  • I think it would be better to divide the single call to three:
    - Build sln;
    - Deploy site1;
    - Deploy site2;

    msbuild.exe <solution>.sln
        /p:Configuration=<Release>
        /p:OutputPath=bin
    
    msbuild.exe project1dir\proj1.csproj
        /p:Configuration=<Release>
        /p:OutputPath=<Path to common bin>
        /p:DeployOnBuild=True
        /p:DeployTarget=MSDeployPublish
        /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
        /p:username=<user>
        /p:password=<password>
        /p:AllowUntrustedCertificate=True
        /p:DeployIisAppPath=<SiteName>/Project1
        /p:MSDeployPublishMethod=WMSVC
    
    msbuild.exe project1dir\proj2.csproj
        /p:Configuration=<Release>
        /p:OutputPath=<Path to common bin>
        /p:DeployOnBuild=True
        /p:DeployTarget=MSDeployPublish
        /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
        /p:username=<user>
        /p:password=<password>
        /p:AllowUntrustedCertificate=True
        /p:DeployIisAppPath=<SiteName>/Project2
        /p:MSDeployPublishMethod=WMSVC