Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:26:52+00:00 2026-05-23T15:26:52+00:00

We are using msbuild to deploy an ASP.NET MVC application to a few different

  • 0

We are using msbuild to deploy an ASP.NET MVC application to a few different servers. However, msbuild does not appear to delete the remote application folder first (it just seems to update 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:CreatePackageOnPublish=True /P:UserName=ARemoteWebDeployUser /P:Password=SomePassword

Is msbuild really ‘smart’ enough to sync the files, eliminating the need for a clean deployment each time? If not, is there an easy way to have the files deleted first?

We are using web.config transforms, so the web.config is rebuilt/redeployed every time (a good thing, since we want the app pool to restart on each deploy).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:26:53+00:00Added an answer on May 23, 2026 at 3:26 pm

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

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

    If you don’t know PsExec, look here: http://technet.microsoft.com/en-us/sysinternals/bb897553 . It’s a lightweight tool from Microsoft, probably the best option to run commands on server.
    And then modify your msbuild command to call this target (but then you need to specify all other default targets in this command):

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

    Eventually you can add a post build events to your project file(s).

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

    Of course Microsoft.VisualBasic.targets is a file for .vbproj projects. If you’re using c#, then try Microsoft.CSharp.targets (better check the name on MSDN)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using TeamCity 4.5.1 to build and deploy an ASP.Net application to development.
I am looking for a solution to deploy ASP.NET application from SVN in one
I have a current build process which does a .NET build using MSBuild and
I am using MSBuild to build my stuff. I want to use CruiseControl.net as
Does anyone have a good way to build MSI (vdproj) projects using MsBuild or
I have nant set up to build my ASP.NET MVC project and it works
I have an application consisting of an ASP.NET web application, a couple of Windows
I'm using IIS6, Web Deploy Agent Service, and MSBuild's MSDeploy hooks to deploy. It
I've been deploying ASP.NET websites and managing their configurations using the web configuration transforms
I'm trying to deploy a web application using MSDeploy, on Team Build in TFS.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.