Visual Studio - The “Copy” task failed unexpectedl

2019-09-10 03:27发布

问题:

Using Visual Studio 2013, I have suddenly started getting this error when I build the solution:

The "Copy" task failed unexpectedly.
System.Runtime.InteropServices.COMException (0x800710FE): This file is currently not available for use on this computer. (Exception from HRESULT: 0x800710FE)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32 errorCode)
   at Microsoft.Build.Tasks.FileState.EnsurePopulated()
   at Microsoft.Build.Tasks.FileState.get_FileExists()
   at Microsoft.Build.Tasks.Copy.IsMatchingSizeAndTimeStamp(FileState sourceFile, FileState destinationFile)
   at Microsoft.Build.Tasks.Copy.DoCopyIfNecessary(FileState sourceFileState, FileState destinationFileState, CopyFileWithState copyFile)
   at Microsoft.Build.Tasks.Copy.Execute(CopyFileWithState copyFile)
   at Microsoft.Build.Tasks.Copy.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() ScottProj

I have not changed anything regarding build tasks or project / solution configuration that should cause this. I was making code changes, and then this appeared. I rolled back the particular changes that I made before this occurred, but that did not resolve it. There are no custom build events, just a simple Build -> Build Solution. I have tried these things:

Cleaned and rebuilt the solution. Created another build configuration. Closed VS 2013. Rebooted. Deleted the obj folder.

My next action is to delete the project and get it again from source control.

Any ideas to what may have caused this or prevent it in the future?

EDIT: I was able to manually copy the files into another directory and rebuild that way, excluding the "bin" and "obj" folders.

回答1:

The problem was that, in our environment, the "My Documents" folder, where I had been storing the VS project, was auto-synced to a network share. But sometimes, a syncing problem would occur and the DLLs would become locked forever. (The DLLs from this issue, which I posted a few months ago, are still locked.)

My solution was to move the solution to a folder that was not synced to a network share. These files are kept in source control, so I didn't need them to be backed up.



回答2:

TFS or your source control is preventing the build from editing Resource.Designer.cs file. Check Resource.Designer.cs out for edit and you should be good.



回答3:

I found this problem in visual studio 2017.

Just remove the Read-Only check mark in Properties dialog box of the Resource.Designer.cs file from Windows File Explorer.