我有一个项目,在编译时产生以下错误:
重复'AssemblyVersion'属性
我检查了文件AssemblyInfo.cs,看起来没有重复。
我在MSDN上找到了这篇文章,它解决了一个类似的问题,并按照这篇文章中的建议解决了这个问题。
有人能告诉我这是怎么回事吗?这种情况是否只发生在有两个或多个类名称相似的项目的情况下?还是其他原因?
我有一个项目,在编译时产生以下错误:
重复'AssemblyVersion'属性
我检查了文件AssemblyInfo.cs,看起来没有重复。
我在MSDN上找到了这篇文章,它解决了一个类似的问题,并按照这篇文章中的建议解决了这个问题。
有人能告诉我这是怎么回事吗?这种情况是否只发生在有两个或多个类名称相似的项目的情况下?还是其他原因?
当前回答
我得到这些错误,因为我试图临时重命名obj文件夹为obj_,然后它自动包含在项目中。然后其中的assembly.cs开始与后来生成的obj文件夹中的正确的程序发生冲突。
其他回答
我在过去也遇到过这个问题,所以我假定构建过程在提供版本控制时分别提供程序集信息。这将导致重复,因为您的项目在AssemblyInfo.cs文件中也有该信息。所以删除文件,我认为它应该工作。
编辑AssemblyInfo.cs和#if !NETCOREAPP3_0…# endif
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
#if !NETCOREAPP3_0
[assembly: AssemblyTitle(".Net Core Testing")]
[assembly: AssemblyDescription(".Net Core")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct(".Net Core")]
[assembly: AssemblyCopyright("Copyright ©")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("000b119c-2445-4977-8604-d7a736003d34")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
#endif
对我来说,AssembyInfo.cs和SolutionInfo.cs有不同的值。所以也检查一下这些文件。我只是把其中一个版本删除了。
我在msdn上找到了这个答案,这解释了将文件标记为内容,然后复制到输出= If更新。请看下面的文章:
https://social.msdn.microsoft.com/Forums/en-US/8671bdff-9b16-4b49-ba9e-227cc4df31b2/compile-error-cs0579-duplicate-assemblyversion-attribute?forum=vsgatk
GH
当我把两个项目放在同一个目录中时,我得到了这个错误。如果我有一个解决方案的目录,我把一个单独的Web和数据目录放在它编译正确。