我有一个项目,在编译时产生以下错误:
重复'AssemblyVersion'属性
我检查了文件AssemblyInfo.cs,看起来没有重复。
我在MSDN上找到了这篇文章,它解决了一个类似的问题,并按照这篇文章中的建议解决了这个问题。
有人能告诉我这是怎么回事吗?这种情况是否只发生在有两个或多个类名称相似的项目的情况下?还是其他原因?
我有一个项目,在编译时产生以下错误:
重复'AssemblyVersion'属性
我检查了文件AssemblyInfo.cs,看起来没有重复。
我在MSDN上找到了这篇文章,它解决了一个类似的问题,并按照这篇文章中的建议解决了这个问题。
有人能告诉我这是怎么回事吗?这种情况是否只发生在有两个或多个类名称相似的项目的情况下?还是其他原因?
当前回答
我在。net框架上的项目中也有同样的错误,通过删除项目文件夹中的packages/GitVersion*解决了这个问题
其他回答
我在。net框架上的项目中也有同样的错误,通过删除项目文件夹中的packages/GitVersion*解决了这个问题
我刚刚帮助一个团队成员通过重命名回购文件夹重新克隆回购解决了这个问题。这只是一个开发人员的问题,因为团队中的其他人都能够在构建master时不碰到这个错误,所以我们知道这个问题不是源代码的问题。
我们确实尝试删除bin和obj文件夹,并执行git clean -xfd,但这些都没有解决这个问题。在这种情况下,用一个干净的回购副本重新开始是有效的。
我也有同样的错误,它在程序集版本和程序集文件版本下划线,所以阅读Luqi答案,我只是把它们作为注释添加了进去,错误就解决了
// AssemblyVersion is the CLR version. Change this only when making breaking changes
//[assembly: AssemblyVersion("3.1.*")]
// AssemblyFileVersion should ideally be changed with each build, and should help identify the origin of a build
//[assembly: AssemblyFileVersion("3.1.0.0")]
obj\Debug\netstandard2.0\PacktLibrary.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [c:\Users\John_Tosh1\Documents\C#8.0and.NetCore3.0\Code\Chapter05\PacktLibrary\PacktLibrary.csproj]
obj\Debug\netstandard2.0\PacktLibrary.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [c:\Users\John_Tosh1\Documents\C#8.0and.NetCore3.0\Code\Chapter05\PacktLibrary\PacktLibrary.csproj]
obj\Debug\netstandard2.0\PacktLibrary.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [c:\Users\John_Tosh1\Documents\C#8.0and.NetCore3.0\Code\Chapter05\PacktLibrary\PacktLibrary.csproj]
obj\Debug\netstandard2.0\PacktLibrary.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [c:\Users\John_Tosh1\Documents\C#8.0and.NetCore3.0\Code\Chapter05\PacktLibrary\PacktLibrary.csproj]
obj\Debug\netstandard2.0\PacktLibrary.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [c:\Users\John_Tosh1\Documents\C#8.0and.NetCore3.0\Code\Chapter05\PacktLibrary\PacktLibrary.csproj]
obj\Debug\netstandard2.0\PacktLibrary.AssemblyInfo.cs(20,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [c:\Users\John_Tosh1\Documents\C#8.0and.NetCore3.0\Code\Chapter05\PacktLibrary\PacktLibrary.csproj]
我相信我的库文件夹是由于无意中创建了另一个类库而损坏的。我删除了所有相关文件库,但问题仍然存在。我通过删除目录中的所有bin和obj文件夹找到了一个解决方案。之前的构建是正常的,但是发现了一个具有相同的assemblyinfo.cs文件的子文件夹。
当将core升级到VS2017时,另一个解决方案是在属性\assemblyinfo.cs文件中删除它们。
因为它们现在存储在项目中。