C# – Visual Studio Unable to Copy File …Access to the Path is Denied

cvisual studio

I am unable to build my project when the Solution Configurations dropdown is set to 'Test'. Multiple errors appear, most of which read 'Unable to copy file [File location] to [copy file location] Access to the path [copy file location] is denied.
I have already checked or attempted the following, and the issue is still unresolved:

  • The latest version of Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package is installed
  • The solution has been restarted
  • Clean and Rebuild has been attempted
  • This only occurs with the Solution Configuration is set to the Configuration 'TEST', so this should not be an issue with anti-virus software
  • I have updated to the latest version of Visual Studio as of 8/24/2018
  • I have unchecked the read only attribute on the folder (it resets to read only each time)
  • This does not occur when I change the Solution Configuration to Release or Debug
  • Deleting the files in the bin/Test folder
  • taskkill /F /IM VBCSCompiler.exe /T
  • I have tried running Visual Studio as an Admin
  • I have reproduced this error on a second machine using the same code from the same TFS repository

Best Answer

I clicked properties, added Full Control and Modify permissions for users, and then did a clean and rebuild on my project. I did this at the folder level, and parent folder levels before the issue was resolved.