Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I delete existing files when deploying an ASP.Net 5 Web App to Azure

I've got a web application in ASP.Net 5 with the source in VS Team Services. Using the Team Services build system, I'd like to deploy it directly to Azure for Continuous Deployment.

I've followed the steps here: https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5

However, when the website is deployed, only the new files are added and existing ones are overridden. Any deleted files are not removed. This means that extra controllers that were removed during refactoring (for example) still hang around.

Is there a way to force the deployment to wipe out any existing deployed website before putting the new one in place?

I've already run into an issue where the site is unable to deploy due to files being locked. I fixed this by wrapping the publish command in commands to start/stop the site:

Stop-AzureWebsite -Name $websiteName

. $publishScript -publishProperties $publishProperties  -packOutput $packOutput

Start-AzureWebsite -Name $websiteName

In theory I could instead remove and create the website, but that seems a bit heavy handed...

like image 997
Alasdair Ross Avatar asked Aug 18 '15 18:08

Alasdair Ross


People also ask

How do I deploy an ASP NET application from Visual Studio to app service?

In Solution Explorer, right-click on the project and click Publish. Visual Studio can create a new App Service resource, but this update will be published over the existing deployment. In the Pick a publish target dialog, select App Service from the list on the left, and then select Select Existing. Click Publish.


2 Answers

Another option, using the publish profile:

enter image description here

like image 182
dannl Avatar answered Sep 21 '22 22:09

dannl


Add this to your MSBuild parameters:

/p:SkipExtraFilesOnServer=False

Additional parameters here:

Valid Parameters for MSDeploy via MSBuild

like image 27
Bruno Faria Avatar answered Sep 21 '22 22:09

Bruno Faria