Reputation: 141
I just upgraded to "Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.1.2" and while I try to compile the.Net core 6 web Application, it gets this error:
Severity Code Description Project File Line Suppression State Error MSB3027 Could not copy "obj\Debug\net6.0\CMA.dll" to "bin\Debug\net6.0\CMA.dll". Exceeded retry count of 10. Failed. The file is locked by: "Microsoft Visual Studio 2022 (8816)" CMA C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 4631
When I double click the error message it opens the file Microsoft.Common.CurrentVersion.targets and highlights the part below:
<!-- Copy the build product (.dll or .exe). -->
<Copy
SourceFiles="@(IntermediateAssembly)"
DestinationFolder="$(OutDir)"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)"
Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'"
>
<Output TaskParameter="DestinationFiles" ItemName="MainAssembly"/>
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
Any Idea what to do?
Upvotes: 7
Views: 5890
Reputation: 11
This happens to me every now and then. Sometimes, waiting and trying again solves it. Doesn't seem like simply closing and reopening the solution solves it for me. If it's stuck for several minutes, there is no other solution than restarting Visual Studio. The issue with this is that I lose my undo history every time I close the solution or close Visual Studio. This can be bad at times, if I'm in the middle of an edit I'm not sure whether will work or not. I really hoped there would be a solution that doesn't involve restarting Visual Studio or rebooting. Clearly, I'm not the only one experiencing this, so I hope they fix it soon.
I've checked that there are no left over processes from my program running (although I expect that Visual Studio wouldn't show it as stopped if I started it with Visual Studio to begin with, if it wasn't actually closed, but in any case, no project.vshost.exe processes running and no project.anything else either) I'm using .NET 6.0 as well, so wondering if this is just an issue with that particular version. Though, .NET 6.0 is still under Long Term Support, and this post is one and a half years old, they ought to have fixed this by now.
Upvotes: 1