title: Azure Web App: Delete all files before publish
body: <p>When publishing to our Azure Web App using the following Powershell script, we often have issues whereby files from the previous publish cause runtime errors.</p>
  
  <pre><code>param($websiteName, $packOutput)
  
  $website = Get-AzureWebsite -Name $websiteName
  
  # get the scm url to use with MSDeploy.  By default this will be the second in the array
  $msdeployurl = $website.EnabledHostNames[1]
  
  $publishProperties = @{'WebPublishMethod'='MSDeploy';
                          'MSDeployServiceUrl'=$msdeployurl;
                          'DeployIisAppPath'=$website.Name;
                          'Username'=$website.PublishingUsername;
                          'Password'=$website.PublishingPassword}
  
  Write-Output "Stopping web app..."
  Stop-AzureWebsite -Name $websiteName
  
  Write-Output "Publishing web app..."
  $publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"
  
  Write-Output "Starting web app..."
  Start-AzureWebsite -Name $websiteName
  
  . $publishScript -publishProperties $publishProperties  -packOutput $packOutput
  </code></pre>
  
  <p><strong>How can I delete all the existing files before the publish?</strong></p>
  
  <p>Note that we cannot use slots because this requires Standard instances, which are too expensive for our CI environment.</p>