TemporaryGeneratedFile_[guid] in /obj/debug breaking build

NikolaiDante picture NikolaiDante · Sep 13, 2012 · Viewed 24.3k times · Source

I have 3 temporary files being created in obj/debug:

E.g.

  • TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
  • TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
  • TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

(The guids don't seem to change even after a solution clean)

My build is failing because:

SA1633: The file has no header, the header Xml is invalid, or the header is not located at the top of the file.

I don't want to turn the StyleCop rule off. How do I find out what is creating these temporary files?

The site is an asp.net MVC 4 site, with 5 models, 4 controllers, 2 classes, 2 aspx web pages and 1 service reference, which numerically don't seem to tally with the 3 files.

Any pointers?

Edit: If I change framework from 4.5 back to 4 these files go away and the build is successful.

My version of StyleCop is 4.4, I'm more than open to finding a way to get it to ignore obj/debug

Answer

Rajesh picture Rajesh · Sep 24, 2012

I solved this issue by going to the project solution (whose build) was giving this error.

  1. right click on the project and unload the project.
  2. Then right click on the project and edit the .csproj file.
  3. Look for these temp (problematic) generated files. (see example code)
  4. remove this file references from the .csproj file.
  5. Right click on project and load back the project.
  6. Rebuild the solution.
  7. Its good to go now...

they look like this in the csproj file:

<Compile Include="src\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs" />
<Compile Include="src\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs" />
<Compile Include="src\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs" />