为什么Visual Studio会在temp文件夹中生成如下文件.NETFramework,Version=v4.5.AssemblyAttributes.cs [英] Why does Visual Studio generates the following file .NETFramework,Version=v4.5.AssemblyAttributes.cs in the temp folder

查看:133
本文介绍了为什么Visual Studio会在temp文件夹中生成如下文件.NETFramework,Version=v4.5.AssemblyAttributes.cs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 Visual Studio 会在临时文件夹 C:\Users\[USERNAME]\AppData\Local\ 中生成以下文件 .NETFramework,Version=v4.5.AssemblyAttributes.cs构建解决方案时当前用户的临时?

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?

文件内容如下:

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

这个问题出现在我的脑海中,因为我在重新启动 PC 时遇到了这个文件丢失的问题,请参阅 Visual Studio Rebuilds unmodified有时在 PC 重新启动后进行项目.

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.

推荐答案

为什么Visual Studio会在temp文件夹中生成如下文件.NETFramework,Version=v4.5.AssemblyAttributes.cs

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:由于生成的 AssemblyAttributes.cs 导致不必要的重建

Kirill Osenkov 在那篇文章中使用了一个例子来解释为什么在临时文件夹中生成文件.

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.

因此,将以下行添加到您的 csproj 文件中:

So add the following lines to your csproj file:

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

希望这会有所帮助.

这篇关于为什么Visual Studio会在temp文件夹中生成如下文件.NETFramework,Version=v4.5.AssemblyAttributes.cs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆