I have a .Net Core 3.1 DLL project that all of a sudden didn't build anymore with the following error message:
CSC : error CS2012: Cannot open 'some.dll' for writing -- 'Access to the path 'some.dll' is denied.'
This project is not under any kind of source control. It's not on a build server (what most questions on Stack Overflow is about). It's a project on my local machine. Now, to rule out Visual Studio I've tried to build it from the command line with dotnet. Same thing unfortunately. Things I've tried:
- Close Visual Studio, delete obj folder + bin folder
- Delete the entire project and made a new one with the same name
- Removed project reference to other project (to rule out: dotnet core build in parallel or simultaneously)
- The suggestions here error CS2012: Cannot open <executable path> access to <executable path denied>
This all didn't help. Then I had success for 1 build with:
- Changing the target framework from 3.1 to 3.0
- Changing the name of the project
This built the project once, because the filepath changes really, but then I got the same error the 2nd built.
Then I've had a few days success by:
- Moving the entire solution to a new folder without the problematic project. Then adding a brand new project and adding the code to this complete new project.
But unfortunately after a few days I got the exact same problem. I have no idea what changed. It's always this project (which is a unittest project) and not the other project that it references (also a DLL project). I am out of ideas. Anybody have any suggestions for me to try?
Thanks in advance for helping.
Update My project's name = "TheGenesysProject.Engine.Test" and it was indeed quarantined by my company's security software as Pavel said in the comments. So I changed it to "JustSomeLib" and the security software didn't quarantine it anymore! Why this is, I have no clue whatsoever...
Update 2 it must be something in the project itself and not the name of the dll. I restored JustSomeLib so it had the same NuGet packages (xunit + xunit.runner.visualstudio) plus .cs files (just 3 files with some unittests in them nothing fancy) as TheGenesysProject.Engine.Test and it all build and worked once! Then I coded some more stuff. Added an unittest to test my new code and... Bam! In quarantine again. What the heck?! I am just logging this for if people have the same problem as I do.
Update 3 Just to conclude this story. The folder with sourcecode is now excluded from the malware scan and the dll's are not put in quarantine. This solved this problem. Thank you Pavel.