Wollmich
Wollmich

Reputation: 1646

Why does Visual Studio generates the following file .NETFramework,Version=v4.5.AssemblyAttributes.cs in the temp folder

Why does Visual Studio generates the following file .NETFramework,Version=v4.5.AssemblyAttributes.cs in the temp folder C:\Users\[USERNAME]\AppData\Local\Temp of the current user when building a solution?

The content of the file looks like that:

// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]

This question came into my mind because I've a problem when restarting my PC that this file is missing, see Visual Studio Rebuilds unmodified projects sometimes after a PC reboot.

Upvotes: 7

Views: 5155

Answers (2)

hallokatten
hallokatten

Reputation: 11

The solution might be excluding "bin" folder from project.

Upvotes: 0

Leo Liu
Leo Liu

Reputation: 76910

Why does Visual Studio generates the following file .NETFramework,Version=v4.5.AssemblyAttributes.cs in the temp folder

Since you are interested in the reasons for generating this file, I suggest that you can check this document:

MSBuild: unnecessary rebuilds because of generated AssemblyAttributes.cs

Kirill Osenkov used an example in that article to explain why the file was generated in the temp folder.

Similarly, we could to know the reason for those unnecessary rebuilds after this file generated in that article and how to resolve this issue.

So add the following lines to your csproj file:

  <PropertyGroup>
    <TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
  </PropertyGroup>

Hope this helps.

Upvotes: 9

Related Questions