none
Visual Studio cannot build because dotnet.exe is locking files RRS feed

  • Question

  • After I run my solution, especially when debugging it, then stop the execution, several DLLs get locked by the dotnet.exe process, causing subsequent build to fail (because solution cannot be cleaned).

    Also, locked DLLs cannot be deleted manually, and dotnet.exe process cannot be killed (access denied error even with admin rights). This condition persist even after a log off. Restarting the machine solves the issue only temporarily.

    Extra info: I'm using Windows 7 Professional 64-bit, Visual Studio Enterprise 2017, .NetCore 2.1.

    --------------

    Microsoft Visual Studio Enterprise 2017 
    Version 15.7.5
    VisualStudio.15.Release/15.7.5+27703.2042
    Microsoft .NET Framework
    Version 4.7.02558

    Installed Version: Enterprise

    ASP.NET and Web Tools 2017   15.0.40625.0
    ASP.NET and Web Tools 2017

    ASP.NET Core Razor Language Services   15.7.31476
    Provides languages services for ASP.NET Core Razor.

    ASP.NET Web Frameworks and Tools 2017   5.2.60618.0
    For additional information, visit https://www.asp.net/

    Azure App Service Tools v3.0.0   15.0.40608.0
    Azure App Service Tools v3.0.0

    C# Tools   2.8.3-beta6-63029-08. Commit Hash: e9a3a6c0ba5b1fde8b1fff964bdfb3fb768ee2eb
    C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Common Azure Tools   1.10
    Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

    GhostDoc   5.9.18070.0
    Generate XML Comments from your code, maintain clean and up-to-date documentation, produce help documentation in multiple formats, use intelligent source code Spell Checker in Visual Studio.

    GitHub.VisualStudio   2.5.4.3349
    A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

    JavaScript Language Service   2.0
    JavaScript Language Service

    JetBrains ReSharper Ultimate 2017.2.2    Build 109.0.20171006.122324
    JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2018 JetBrains, Inc.

    Markdown Editor   1.12.233
    A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

    Microsoft Azure Tools   2.9
    Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10420.2

    Microsoft Continuous Delivery Tools for Visual Studio   0.3
    Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

    Microsoft JVM Debugger   1.0
    Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

    Microsoft MI-Based Debugger   1.0
    Provides support for connecting Visual Studio to MI compatible debuggers

    Microsoft Visual Studio Tools for Containers   1.1
    Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

    NuGet Package Manager   4.6.0
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

    ProjectServicesPackage Extension   1.0
    ProjectServicesPackage Visual Studio Extension Detailed Info

    ResourcePackage Extension   1.0
    ResourcePackage Visual Studio Extension Detailed Info

    SQL Server Data Tools   15.1.61804.210
    Microsoft SQL Server Data Tools

    TypeScript Tools   15.7.20419.2003
    TypeScript Tools for Microsoft Visual Studio

    Visual Basic Tools   2.8.3-beta6-63029-08. Commit Hash: e9a3a6c0ba5b1fde8b1fff964bdfb3fb768ee2eb
    Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Visual Studio Code Debug Adapter Host Package   1.0
    Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

    • Edited by Oscar GC Wednesday, August 1, 2018 10:23 PM Added versions numbers and screenshot.
    Tuesday, July 31, 2018 8:49 PM

All replies

  • Hi,

     

    Welcome to the MSDN forum.

     

    Can you help us confirm that this issue only occurs on your current project or on all .net core projects?

    Can you create a single .net core console project, check if this issue still occurs?

     

    When debug ending, dotnet.exe will exits automatically with some info in Output window as below.

    Can you check if dotnet.exe exits successfully after debug ending on your project?

    Are there some other error messages?

     

    If this issue only occurs on your current project, maybe you can try the following workaround to solve your issue:

    Please try to kill dotnet.exe process via running the command: taskkill /IM dotnet.exe /F /T as administrator.

    Or you can try to add Pre-build event command line for your project:

    ·         Right click on project

    ·         Choose Properties

    ·         Build Events

    ·         Pre-build event command line, add the following commands:

    taskkill /IM dotnet.exe /F /T 2>nul 1>nul

    Exit 0

    ·         Save and build

     

    Best regards,

    Xiu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 2, 2018 10:20 AM
    Moderator
  • Do you have any updates? If your issue still persists, please feel free to let us know.

    If it is solved, we are welcome you share the solution in here or mark the helpful reply as answer, that will help other community members, then we can also close this thread for you.

     

    Best regards,

    Xiu

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 10, 2018 9:03 AM
    Moderator
  • Hi Xiu,

    I've tested the proposed solutions, but those did not worked. The process cannot be killed by using that command (or any other command I tested with), also I tried kill it with the task managet, but the error I get is an "Access denied" [This makes no sense because I am using an admin account, and also the process was under my name].

    The only solution I've found is to restart the machine.

    Any idea?

    • Edited by Oscar GC Friday, August 10, 2018 3:35 PM
    Friday, August 10, 2018 1:37 PM
  • Just kill the dotnet.exe process, Powershell CMD Below:

    "stop-process -name "dotnet", Done

    Wednesday, June 12, 2019 4:33 PM
  • OK, Powershell one worked! Thanks.

    This is still happening in Visual Studio Community 2019!

    The error that was causing it was:

    Unhandled Exception: System.DivideByZeroException: Attempted to divide by zero.
       at Mod3_Lab2.Program.Divide(Int32 first, Int32 second) in C:\Chris\Introduction to C#\Mod3_Lab2\Mod3_Lab2\Mod3_Lab2\Program.cs:line 44
       at Mod3_Lab2.Program.Main(String[] args) in C:\Chris\Introduction to C#\Mod3_Lab2\Mod3_Lab2\Mod3_Lab2\Program.cs:line 9

    C:\Program Files\dotnet\dotnet.exe (process 196) exited with code -1073741676.
    Press any key to close this window . . .


    After that you change the code and recompile.

    • Edited by Chrispy555 Sunday, August 25, 2019 3:37 PM
    Friday, August 23, 2019 5:48 PM