Get msbuild to remotely deploy a clean application remotely

We use msbuild to deploy an ASP.NET MVC application on several different servers. However, msbuild does not seem to delete the remote application folder first (this just updates the files). Our msbuild command line looks like this:

"C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ msbuild.exe" OurWebProject.csproj / P: BaseIntermediateOutputPath = c: \ temp \ tempfolder \ / P: Configuration = Release / P: DeployOnBuild = True / P: DeployTarget = MSDeployPublish / P: MsDeployServiceUrl = https: //192.168.0.83: 8172 / MsDeploy.axd / P: AllowUntrustedCertificate = True / P: MSDeployPublishMethod = WMSvc / P: CreatePackageOnPubeb = TruePebeb = TrueManager = true Somepassword

Is msbuild smart enough to sync files, eliminating the need for a clean deployment every time? If not, is there an easy way to delete files first?

We use web.config transformations, so web.config is rebuilt / redistributed every time (well, since we want the application pool to restart every time it is deployed).

+5
source share
2 answers

I'm not sure if there are specific options for the msbuild command, but maybe you could add a target to your project? You can create:

<Target Name=CleanServerFolders>
  <Exec Command="psexec \\$(serverIP) -u $(serverUserName) -p $(serverUserPassword) del $(projectFolderOnServer)"
</Target>

PsExec, : http://technet.microsoft.com/en-us/sysinternals/bb897553. Microsoft, , . msbuild ( ):

msbuild.exe /t:Build,CleanServerFolders,Deploy ...etc

.

<Project>
  ...
  <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
  <Target Name="AfterBuild"><CallTarget Targets="CleanServerFolders"/></Target>
</Project>

, Microsoft.VisualBasic.targets - .vbproj. #, Microsoft.CSharp.targets( MSDN)

+2

robocopy? msbuild msbuild ? . http://msbuildextensionpack.codeplex.com/

robocopy . robocopy/? .

0

All Articles