Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio error: The "GenerateResource" task failed unexpectedly ... The file exists

I am trying to build a solution with many projects, and I'm getting this error for a Windows Service project:

The "GenerateResource" task failed unexpectedly.
System.Runtime.InteropServices.COMException (0x80070050): The file exists. (Exception from HRESULT: 0x80070050)
   at Microsoft.Build.Shared.NativeMethodsShared.InprocTracking.WriteContextTLogs(String intermediateDirectory, String tlogRootName)
   at Microsoft.Build.Utilities.FileTracker.WriteContextTLogs(String intermediateDirectory, String taskName)
   at Microsoft.Build.Tasks.GenerateResource.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)   ImportProcessorWindowsService

As suggested in another similar question, I tried deleting my .suo file, but that did not help.

I have been able to build this solution in the recent past. How do I fix this?

like image 923
Seibar Avatar asked Oct 17 '11 15:10

Seibar


4 Answers

I figured this out. It seems to have been caused by some files being marked Read Only in the obj/x86 folder.

Lovely how TFS likes to mark files as Read Only.

I deleted the contents of obj/x86 and the error went away.

like image 51
Seibar Avatar answered Nov 20 '22 00:11

Seibar


I checked out (VSS) the obj folder in Solution Explorer and I got a dialog stating that a couple of files and or folders were missing and did I want to create them. I clicked OK and then rebuilt the project without errors.

like image 31
Dave Avatar answered Nov 20 '22 00:11

Dave


I had a .resx file that became corrupted. I undid the change & pulled it from source control again to get the original copy restored. That worked for me.

like image 2
James Burnett Avatar answered Nov 20 '22 01:11

James Burnett


In the more recent versions of Visual Studio it's quick and simple to use the clean and rebuild solution options available on the build toolbox

like image 1
Arazio Avatar answered Nov 19 '22 23:11

Arazio