none
Unable to remove directory because file 'db.lock' is being used by another process.

    Question

  • I just "upgraded" from Visual Studio Ultimate 2013 to Visual Studio Enterprise 2017.  I have 2 solutions that I use for automated testing.  Both solutions clean and build successfully in 2013, but only one will clean and build successfully in 2017.  The other solution generates the error Unable to remove directory 'C:\Source\...\...\...\.vs.' The process cannot access the file 'db.lock' because it is being used by another process.

    When I attempted to delete the db.lock file manually, it says the action cannot be completed because the file is open in ServiceHub.Host.CLR.x86.  

    I've looked at the on-line solutions, and the predominate choices are to uncheck Enable CodeLens, uncheck Enable full solution analysis, or add some if exist "$(TargetPath).locked" del "$(TargetPath).locked"... code into the Pre-Build Event block.  I've tried all of these, but none solved the issue.

    I noticed that in 2017, all 5 projects in the affected solution include Analyzers in the References.  None of the references in 2013 include Analyzers.  I've considered deleting these references, but the same situation applies to the solution that works, as well.  Since it's not a problem with one solution, why would it be a problem with the other solution?  

    If anyone has something else to try, I sure would appreciate suggestions.


    Kevin

    Wednesday, January 03, 2018 6:14 PM

All replies

  • Hi,

    Welcome to MSDN forum.

    >>I just "upgraded" from Visual Studio Ultimate 2013 to Visual Studio Enterprise 2017.  I have 2 solutions that I use for automated testing

    What's the type of these project, WPF or something else?

    If you enable Lightweight Solution Load, please try to disable it from Tools->options->project and solutons.

    >>Unable to remove directory 'C:\Source\...\...\...\.vs.' The process cannot access the file 'db.lock' because it is being used by another process.

    Please have a look at the thread:

    Try to add the .vs folder in the .gitignore.

    You could use this one: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

    If you have any trouble adding the .gitignore, you could follow this article: https://elanderson.net/2016/09/add-git-ignore-to-existing-visual-studio-project/

    Best regards,

    Joyce


    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, January 04, 2018 8:30 AM
  • Hi Joyce.

    First, the projects in my solutions aren't WPF apps.  They're all .NET Framework 4.5.1 Class Libraries.

    I went through the links you provided, but we're not using GIT.  The only settings I have in Team Explorer are the Team Project and Team Project Collection options.

    Thanks for the input, though.  I appreciate it.

    One other thing I've noticed that's different between opening the project in 2013 and opening the project in 2017...  As I mentioned above, 2017 includes the Analyzers reference in each project, whereas 2013 does not.  Just out of curiosity, I right-clicked on it to see if I could remove the reference, but there is no option for removing it.  The only choices are Add Analyzer, Open Active Rule Set, or New Solution Explorer View.  When I opened the rule set, I can see the categories Managed Binary Analysis, Microsoft.CodeAnalysis.CSharp, etc... but there's also a message that says This is a Microsoft rule set and cannot be modified. Any changes will be saved to a copy of the file.  Since the "analysis" seems to be the problem, is there any way to shut it off besides the methods I've already tried (above)?


    Kevin

    Thursday, January 04, 2018 5:20 PM
  • Hi Kevin,

    Thank you for the update.

    Please close all instance of visual studio and go to the project location to delete or rename db.lock, then open the project in visual studio 2017 to build.

    Try to create a new project with the same project type in visual studio 2013 and build it in visual studio 2017 to check it if the issue persists. 

    >>One other thing I've noticed that's different between opening the project in 2013 and opening the project in 2017...  As I mentioned above, 2017 includes the Analyzers reference in each project,

    Analyzers are used to add custom error messages and warnings that appear live as you're typing, along with automatic code fixes to help you clean them up. It is one of the best and helpful key new features of Visual Studio 2015 and visual studio 2017.

    Best regards,

    Joyce


    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, January 05, 2018 9:40 AM