I have two MVC 3 web projects one for a mobile application and the other is the regular desktop web application, the last to be added was the mobile application, I have a build definition that deploys every time I check in the code (gated check in).

My problem is that since I have added the mobile the build definition takes that project as a default, so I'd like to know if I can specify "a default web project" in this case I'd like to deploy the desktop version instead the mobile.

I'd like to know if I can specify that from the build arguments, the configuration is the following:

/p:Configuration=Dev /p:Platform="Any CPU" /p:DeployOnBuild=true /p:DeployTarget=MSDeployPublish /p:MSDeployPublishMethod=WMSVC /p:MsDeployServiceUrl=https://IP:Port/msdeploy.axd /p:username=xxx /p:password=xxx /p:AllowUntrustedCertificate=True /p:DeployIisAppPath=Path

and in the "projects to build" option I have the solution of the project (sln file)

any ideas?

有帮助吗?

解决方案

Instead of adding the additional properties to the MSBuild command line, edit the project file and set the properties inside the project file. If needed, create a specific Configuration to put these in so that the deployment doesn't always happen in Visual Studio.

 <PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == false">
      <DeployOnBuild>true</DeployOnBuild>
      <MSDeployTarget>MSDeployPublish</MSDeployTarget>
      ....
      ....
 </PropertyGroup>

That way the project file will know when to deploy. If needed you can stick these items inside the Dev|AnyCPU PropertyGroup which is already present, but that way it will always build inside Visual Studio.

To be able to trigger deployment through the command line, you must make sure that each project listens to its own command line parameter.

 <PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == false">
      <DeployOnBuild Condition="'$(DeployDefaultWebsiteOnBuild)' == 'true'>true</DeployOnBuild>
      <MSDeployTarget>MSDeployPublish</MSDeployTarget>
      ....
      ....
 </PropertyGroup>

As you can see I've added a condition to the DeployOnBuild which will set it to true if DeployDefaultWebsiteOnBuild is set to true. Now you can set that property from the commandline.

 /p:DeployDefaultWebsiteOnBuild=true
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top