CS8019临时文件MSBuild Server上的Assemblyinfo出现错误 [英] CS8019 Error on Assemblyinfo on temp file MSBuild Server

查看:213
本文介绍了CS8019临时文件MSBuild Server上的Assemblyinfo出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的构建服务器上出现代码分析错误,错误是

I am getting a code analysis error on my build server the error is

... NETFramework,Version = v4.6.AssemblyAttributes.cs(3,1):错误CS8019:不必要的使用指令.

...NETFramework,Version=v4.6.AssemblyAttributes.cs(3,1): error CS8019:Unnecessary using directive.

这在Visual Studio创建的Temp文件中.

This is in a Temp file which Visual Studio creates.

在我的项目中,我有"禁止从生成的代码(仅受管理)"打勾.我本以为就足够了.

In my project I have "Suppress results from generated code (managed only)" ticked. I would have thought that would be enough.

但是我仍然在服务器上收到错误,而在本地我什么也没有.

But I still get the error on the server and locally i get none.

有什么想法吗?

推荐答案

搜索 CS8019 AssemblyAttributes 会产生许多有趣的文章,例如

Googling for CS8019 AssemblyAttributes yielded many interesting articles, such as this blog post. Quoting:

对我们来说幸运的是,MSBuild足够灵活,因此我们可以解决它.好的设计是将此文件生成到Intermediate目录(通常称为obj)中,因为在构建过程中所有临时文件和临时文件都应存放在该目录中.我们可以在项目文件中设置此属性:

Fortunately for us, MSBuild is flexible enough so we can work around it. The good design is to generate this file into the Intermediate directory (usually called obj), because this is where all transient and temporary files should go during a build process. We can either set this property in our project file:

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

或者,如果您的构建使用通用的.props文件,请在此处设置此属性.这将确保您的构建不依赖于TEMP目录,并且更加独立,可重复和增量.

Or if your build uses a common .props file, set this property there. This will ensure that your build doesn’t depend on the TEMP directory and is more isolated, repeatable and incremental.

这篇关于CS8019临时文件MSBuild Server上的Assemblyinfo出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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