Web Deploy cannot modify the file 'xxx.exe' on the destination because it is locked by an external process

1.5k Views Asked by At

I have created a new ASP.NET Core Web Application (.Net Framework) in Visual Studio. I'm using .NET Framework 4.5.2. I right click on the project and select publish, to publish the project to Azure with Web Deploy. First attempt fails "Missing root element" or something like that. Second attempt succeeds. But every time I try to publish the project to the App Site in Azure after that I get the Error:

Web Deploy cannot modify the file 'xxx.exe' on the destination because it is locked by an external process.

Why is this?

I can't find a solution to this... Is it not possible to publish ASP.NET Core Web Application (.Net Framework) to Azure in the simpliest possible/normal publish ways?

My project.json looks like this:

    {
  "dependencies": {
    "AutoMapper": "3.2.1",
    "Dropbox.Api": "3.4.0",
    "EnterpriseLibrary.TransientFaultHandling": "6.0.1304",
    "EntityFramework": "6.1.3",
    "Klarna.Net.Api": "4.0.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.Azure.DocumentDB": "1.10.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "PDFsharp": "1.32.3057",
    "RavenDB.Client": "2.5.2910",
    "SaasKit.Multitenancy": "1.1.4",
    "Stripe.net": "6.0.1",
    "IdentityServer4.AccessTokenValidation": "1.0.1-rc5",
    "Newtonsoft.Json": "9.0.1",
    "Microsoft.AspNetCore.Cors": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Swashbuckle": "6.0.0-beta902"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
    }
  },

  "frameworks": {
    "net452": {
      "dependencies": {
        "Adocka.Common": {
          "target": "project"
        },
        "Adocka.Core": {
          "target": "project"
        },
        "Adocka.Core.Dto": {
          "target": "project"
        },
        "Adocka.Dal": {
          "target": "project"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "xmlDoc": true
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
1

There are 1 best solutions below

1
On

This usually happens if your already published your app and it is running, hence the error message you're getting.

When doing deployment first stop your web app (from Azure portal select your web app and press Stop button) , do the deployment and start it again. You can automate the process with powershell script too.