C
C#2y ago
Foxtrek_64

❔ Cannot open output file for writing

Hi all, trying to build my project with Visual Studio. Whenever I do I get an error from CSC stating the following:
Cannot open 'D:\Projects\apps\LuzFaltex\Selkhound\Selkhound\src\Selkhound.API.Abstractions\obj\Debug\Selkhound.API.Abstractions.dll' for writing -- 'The process cannot access the file 'D:\Projects\apps\LuzFaltex\Selkhound\Selkhound\src\Selkhound.API.Abstractions\obj\Debug\Selkhound.API.Abstractions.dll' because it is being used by another process.'
Cannot open 'D:\Projects\apps\LuzFaltex\Selkhound\Selkhound\src\Selkhound.API.Abstractions\obj\Debug\Selkhound.API.Abstractions.dll' for writing -- 'The process cannot access the file 'D:\Projects\apps\LuzFaltex\Selkhound\Selkhound\src\Selkhound.API.Abstractions\obj\Debug\Selkhound.API.Abstractions.dll' because it is being used by another process.'
To fix this, I have tried closing out of Visual Studio and deleting both the Selkhound/output and Selkhound/Selkhound.API.Abstractions/obj directory, but the next time it builds I just get the same exception on build again. I also get this exception for the Selkhound.Client.dll file. Building using Visual Studio, with or without cleaning the solution, or using dotnet build on the command line has the same results. The build log suggests that the projects are being built multiple times in parallel, though I'm not sure if that's a contributing factor here. Any thoughts of what I might do to fix this?
8 Replies
Foxtrek_64
Foxtrek_642y ago
I also occasionally get errors about it not being able to resolve the Microsoft.iOS or Microsoft.MacCatalyst libraries, but I think that these are just consequences of failing to build the Selkhound.Client project which is a Net7 Maui project. So after cleaning and rebuilding a few times, the "cannot access file because it's being used by another process" error is exclusive to the Selkhound.Client project. I'm not getting it on the abstractions library anymore. Apparently the answer was to do exactly the same thing I was doing, just about 6 more times. Cleaning solution and then building the solution, and skipping any manual deletions, and I finally got it to work No clue what happened differently
Scratch
Scratch2y ago
@Saoirse (formerly Kanara) see this thread for a good explanation https://stackoverflow.com/a/3919906 I think you're seeing the same issue from here.
Stack Overflow
msbuild.exe staying open, locking files
I use TeamCity which in turn invokes msbuild (.NET 4). I have a strange issue in that after a build is complete (and it doesn't seem to matter if it was a successful build or not), msbuild.exe stay...
Scratch
Scratch2y ago
I don't know if there's a way to specify it in the csproj, the common solution is to just the env var MSBUILDDISABLENODEREUSE=1
Foxtrek_64
Foxtrek_642y ago
I saw that, but in my case there is only one msbuild process and it closes when build is complete, so there's nothing remaining open to lock the files. I could try the command line though
Scratch
Scratch2y ago
I'd just set the env var, reboot, and see if that helps your symptoms match that issue to a T any luck with testing that out?
Foxtrek_64
Foxtrek_642y ago
I'll test this out today. Was focusing on getting my home lab set up
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.