TemporaryGeneratedFile_ [guid] in / obj / debug break build

I have 3 temporary files created in obj / debug:

eg.

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

(Guides do not seem to change even after cleaning the solution)

My build does not work because:

SA1633: the file does not have a header, the Xml header is not valid, or the header is not at the top of the file.

I do not want to disable the StyleCop rule. How to find out what creates 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 link that do not numerically match the three files.

Any pointers?

Edit: If I change the framework from 4.5 to 4, these files will disappear and the build will succeed.

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

+45
stylecop asp.net-mvc
Sep 13 '12 at 11:51 on
source share
5 answers

In the parser block of the StyleCop.Settings file, add an entry for these files: The value is a regular expression, so you can use a harder one to match the guid, but it suits my need now.

<Parsers> <Parser ParserId="Microsoft.StyleCop.CSharp.CsParser"> <ParserSettings> <BooleanProperty Name="AnalyzeDesignerFiles">False</BooleanProperty> <CollectionProperty Name="GeneratedFileFilters"> <Value>\.g\.cs$</Value> <Value>\.generated\.cs$</Value> <Value>\.g\.i\.cs$</Value> <Value>TemporaryGeneratedFile_.*\.cs$</Value> </CollectionProperty> </ParserSettings> </Parser> </Parsers> 
+34
Sep 14 '12 at 9:17
source share

I solved this problem by going to the solution of the project (whose assembly) gave this error.

  • right click on the project and upload the project.
  • Then right-click the project and edit the .csproj file.
  • Look for these temporary (problematic) generated files. (see code example)
  • remove links to this file from the .csproj file.
  • Right-click the project and load the project.
  • Recover the solution.
  • 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" /> 
+31
Sep 24 '12 at 14:37
source share

3 files with the "TemporaryGeneratedFile_" prefix are automatically generated by the Microsoft.WorkflowBuildExtensions.targets file, which is most likely imported through the chain:

  • *. csproj →
  • Microsoft.CSharp.targets →
  • Microsoft.Common.targets →
  • Microsoft.WorkflowBuildExtensions.targets

They are generated in the intermediate output path specified by the $(IntermediateOutputPath) property of MSBuild, usually something like obj\debug . One way to deal with StyleCop warnings / errors about these automatically generated files is to tell StyleCop to skip any * .cs files in $(IntermediateOutputPath) . For example, include the following element in the project:

 <ItemGroup> <ExcludeFromStyleCop Include="$(IntermediateOutputPath)\**\*.cs" /> </ItemGroup> 

ExcludeFromStyleCop is the name of the element recognized by the StyleCop.targets file to exclude files from analysis during assembly (at least for StyleCop 4.7). The double asterisk ** is the MSBuild syntax for searching recursively in a folder.

The new item may appear in Solution Explorer in Visual Studio. If this is not desired, it can be hidden using the Visible metadata:

 <ItemGroup> <ExcludeFromStyleCop Include="$(IntermediateOutputPath)\**\*.cs" > <Visible>False</Visible> </ExcludeFromStyleCop> </ItemGroup> 

A similar approach can be used to exclude other files, if necessary. Hope this helps.

+14
Feb 23 '13 at 9:23
source share

I helped a colleague who added a new project to our main VS solution and received the same 3 errors. I reviewed the steps suggested above with him, but did not have time to fix it. After that, I found that he skipped one of the steps that we take when adding a new project to our solution that uses Code Analysis and StyleCop. He forgot to add the Settings.StyleCop file to his project :)

0
Mar 09 '17 at 16:27
source share

I recently ran into this problem from nowhere.

For me, I managed to overcome this by opening .csproj files for each project, and then delete the following line:

 <Import Project="$(SolutionDir)\CodeAnalize\Microsoft.StyleCop.targets" /> 

After reopening the solution, he was able to build everything without errors.

0
May 09 '17 at a.m.
source share



All Articles