コンパイル時に次のエラーを生成するプロジェクトがあります。
エラー CS0579: 'AssemblyVersion' 属性が重複しています
ファイルを確認しましたAssemblyInfo.cs
が、重複はないようです。
同様の問題に対処するこの記事をMSDNで見つけ、この記事の提案に従って問題も修正します。
ここで何が起こっているのか誰か教えてもらえますか? 同じような名前のクラスを持つプロジェクトが 2 つ以上ある場合にのみ発生しますか? それとも別のものですか?
コンパイル時に次のエラーを生成するプロジェクトがあります。
エラー CS0579: 'AssemblyVersion' 属性が重複しています
ファイルを確認しましたAssemblyInfo.cs
が、重複はないようです。
同様の問題に対処するこの記事をMSDNで見つけ、この記事の提案に従って問題も修正します。
ここで何が起こっているのか誰か教えてもらえますか? 同じような名前のクラスを持つプロジェクトが 2 つ以上ある場合にのみ発生しますか? それとも別のものですか?
私も過去にこの問題に遭遇したことがあるので、ビルドプロセスがバージョン管理の提供とは別にアセンブリ情報を提供すると仮定します。プロジェクトにもその情報がAssemblyInfo.cs
ファイルに含まれているため、重複が発生します。したがって、ファイルを削除すると、機能するはずです。
同じエラーが発生し、アセンブリ Vesrion とアセンブリ ファイル バージョンに下線が引かれていたので、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")]
私にとっては、AssembyInfo.cs と SolutionInfo.cs の値が異なることでした。したがって、これらのファイルも確認してください。そのうちの1つからバージョンを削除しました。
私のエラーは、どういうわけか、コントローラーフォルダー内に作成された obj フォルダーがあったために発生しました。アプリケーションで Assemblyinfo.cs 内の行を検索するだけです。どこかに重複があるかもしれません。
これは通常、Visual Studio 2017 でプロジェクトをコンパイルしてから、コマンド ライン コマンド "dotnet run" を使用して .NET Core でプロジェクトを再構築して実行しようとすると発生します。
すべての「bin」および「obj」フォルダー (「ClientApp」内とプロジェクト フォルダー内の両方) を削除するだけで、.NET Core コマンド「dotnet run」を再構築して正常に実行できました。
binとobjファイルを削除し、プロジェクトのキャッシュをクリアできます。私の問題はそれから修正されました。
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
メイン プロジェクトがソリューションと同じフォルダーにあり、サブ フォルダーにある同じソリューションに別のプロジェクトがあり、その別のプロジェクトがメイン プロジェクトを参照として使用したときに、この問題が発生しました。これにより、メイン プロジェクトは、重複した参照を作成するサブ フォルダー bin および obj フォルダーを検出しました。