Error the process cannot access the file because it is being used by another process while building project by CLI on .NET Core

后端 未结 8 1243
一个人的身影
一个人的身影 2021-01-11 23:56

I got following error while running dotnet build command on my .NET Core project.

C:\\Program Files\\dotnet\\sdk\\2.1.2\\Microsoft.Common.Curre         


        
相关标签:
8条回答
  • 2021-01-12 00:24

    The solution for me is to stop the IIS Express processes by right-clicking on the taskbar icon.

    Or you can make a command line in "Pre-Build Event":

    $(Solution)taskkill /FI "IMAGENAME eq iisexpress.exe" /F

    Add this command in the "Properties" of your projet > "Build Events"

    We don't have time to see if the command has been executed properly in "Ouput" view into "Build" section. Add this command line in "Pre-Build Event" to see the results:

    cmd /c pause

    You can remove this line after check...

    0 讨论(0)
  • 2021-01-12 00:27

    If your web server is IIS you can put an empty file named app_offline.htm in the project root, which will gracefully shut down the app.

    I have it scripted like so:

    1. Add app_offline.htm to project root hosted by IIS
    2. dotnet build
    3. Remove app_offline.htm
    0 讨论(0)
  • 2021-01-12 00:28

    For those like me who have this issue on a shared host with no access to anything whatsoever, don't try to copy your dll directly via panel or FTP, zip it then upload it then extract it this way it works in Plesk panel.

    0 讨论(0)
  • 2021-01-12 00:32

    Most likely an open .Net core process running and blocking, if on windows, just kill it through the task manager.

    0 讨论(0)
  • 2021-01-12 00:33

    I have experienced the same issue when adding a new migration class. My Visual Studio (2017) instance was constantly freezing and when I restarted Visual Studio I started getting similar messages. What helped me was to kill the dotnet.exe process via Windows Task Manager.

    0 讨论(0)
  • 2021-01-12 00:40

    Your ASP.Net application is running from the same directory, that is why you couldn't build your code. You have following options:

    1. Terminate the running ASP.Net application;
    2. Copy your code to another directory and build it from there; or
    3. Restart your computer and try building it again.

    I would go with first option, but if you have difficulty finding out how to do it, last option is the easiest. In any case if for any reason you couldn't restart your computer, second one will surely work.

    0 讨论(0)
提交回复
热议问题