Dot-Net

使用程序集屬性的最佳實踐是什麼?

  • September 15, 2008

我有一個包含多個項目的解決方案。我正在嘗試通過連結一個解決方案範圍的程序集資訊文件來優化 AssemblyInfo.cs 文件。這樣做的最佳做法是什麼?哪些屬性應該在解決方案範圍的文件中,哪些是項目/程序集特定的?


編輯:如果您有興趣,有一個後續問題AssemblyVersion、AssemblyFileVersion 和 AssemblyInformationalVersion 之間有什麼區別?

我們正在使用一個名為 GlobalAssemblyInfo.cs 的全域文件和一個名為 AssemblyInfo.cs 的本地文件。全域文件包含以下屬性:

[assembly: AssemblyProduct("Your Product Name")]

[assembly: AssemblyCompany("Your Company")]
[assembly: AssemblyCopyright("Copyright © 2008 ...")]
[assembly: AssemblyTrademark("Your Trademark - if applicable")]

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

[assembly: AssemblyVersion("This is set by build process")]
[assembly: AssemblyFileVersion("This is set by build process")]

本地 AssemblyInfo.cs 包含以下屬性:

[assembly: AssemblyTitle("Your assembly title")]
[assembly: AssemblyDescription("Your assembly description")]
[assembly: AssemblyCulture("The culture - if not neutral")]

[assembly: ComVisible(true/false)]

// unique id per assembly
[assembly: Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]

您可以使用以下過程添加 GlobalAssemblyInfo.cs:

  • 在項目的上下文菜單中選擇Add/Existing Item…
  • 選擇 GlobalAssemblyInfo.cs
  • 通過點擊右側的那個小向下箭頭來展開添加按鈕
  • 在按鈕下拉列表中選擇“添加為連結”

引用自:https://stackoverflow.com/questions/62353