我正在开发一个通过运行dotnet new angular(Clear blog explanation of usage)开始生活的Web应用程序。

为了扩展默认代码的功能,我开始开发Web API。我添加了3个新的.Net Core库项目,分别为SharedSchedulingScheduling_Tests

Scheduling中定义了一些域模型类,在Shared中定义了一些基类,最后在ShedulingTests中定义了一些NUnit测试。

构建解决方案时,Web应用程序项目中将出现2个新文件夹:SharedScheduling。我还收到类似以下的生成错误:

Error   CS0579  Duplicate 'System.Reflection.AssemblyCompanyAttribute'

我不确定该如何处理,任何建议都将受到欢迎。

最佳答案

发生这种情况是因为新的.NET工具会自动创建属性并将其添加到程序集中,因此它们现在在构建中出现两次。

有两种解决方法:

  • 删除AssemblyInfo.cs
  • 保留AssemblyInfo.cs,但将标签添加到CSProj文件中以隐藏AssemblyInfo中的属性。

  • 例如:



    (感谢https://johnkoerner.com/csharp/dealing-with-duplicate-attribute-errors-in-net-core/)

    关于visual-studio-2017 - VS 2017构建错误-AssemblyInfo.cs中的属性重复,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45349981/

    10-13 07:39