我可以在 Visual Studio 中為解決方案設置通用的 major.minor.release (Can I set a general major.minor.release for a solution in Visual Studio)


問題描述

我可以在 Visual Studio 中為解決方案設置通用的 major.minor.release (Can I set a general major.minor.release for a solution in Visual Studio)

我知道我可以在 VS 中為我的解決方案中的每個項目設置一個主要和次要版本號。我可以為我的解決方案中的所有項目設置一個通用的major.minor 編號,它們都具有相同的格式,例如2.3.3?


參考解法

方法 1:

I recommend that you have a common file called GlobalAssemblyInfo.cs that contains the assembly information that applies across your entire solution. It would probably include the following attributes:

[assembly: AssemblyProduct("Your Product Name")]
[assembly: AssemblyCompany("Your Company")]
[assembly: AssemblyCopyright("Copyright © 2010 Your Company")]
[assembly: AssemblyTrademark("Your Trademark (if applicable)")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Then, each project should have a local file called AssemblyInfo.cs that contains the specific information applying only to that project. This will include the information you might want to supply on a per‑assembly basis:

[assembly: AssemblyTitle("Your Assembly Title")]
[assembly: AssemblyDescription("Your Assembly Description")]
[assembly: AssemblyCulture("Assembly Culture (if not neutral)")]

[assembly: ComVisible(true/false)]
[assembly: Guid("xxxxxxxx‑xxxx‑xxxx‑xxxx‑xxxxxxxxxxxx")]

Finally, follow these steps to share the GlobalAssemblyInfo.cs file between multiple projects:

  1. Right‑click on your project in the Solution Explorer, point to "Add", and click "Existing Item."
  2. Navigate to your global assembly file and select it.
  3. Click the drop‑down arrow on the "Add" button, and click "Add As Link" in the menu.

方法 2:

Yes. You only need to reference (add file as link to your project) in all your projects to a common file e.g. Version.cs which contains the AssemblyVersion and AssemblyFileVersion common for all your projects.

Yours, Alois Kraus

方法 3:

Ok if I do it like the propose of Alois I have an other problem. For every project I need to set the AssemblyProduct Property. If I have one AsssemblyInfo.cs file for all projects, I can just set one AssemblyProduct for all? Is there a possibility to set this property more flexible?

(by holzleubeCody GrayAlois Krausholzleube)

參考文件

  1. Can I set a general major.minor.release for a solution in Visual Studio (CC BY‑SA 3.0/4.0)

#visual-studio #versioning






相關問題

如何在 C# 中使用帶有動態參數的 INSERT INTO SQL 查詢? (How to use a INSERT INTO SQL Query with Dynamic parameters in C#?)

擴展 SSRS 中的圖表功能 (Extending chart functionality in SSRS)

如何將 MVC 5 項目模板添加到 VS 2012? (How can I add the MVC 5 project template to VS 2012?)

Visual Studio - 將按鈕/複選框添加到工具欄以切換只讀文件屬性, (Visual Studio - Add a button/checkbox to a toolbar to switch the readonly file property,)

在 Javascript/Jquery Ajax 調用中使用 WCF 服務 (Consuming WCF service in Javascript/Jquery Ajax call)

Visual Basic 2013 - 控制台輸入令牌? (Visual Basic 2013 - Console Input Tokens?)

您是否知道用於編輯/翻譯資源(.rc)文件的好的程序? (Do you know of a good program for editing/translating resource (.rc) files?)

ADODB.Recordset 數據無法綁定到 datagridview (ADODB.Recordset data cannot bind into datagridview)

Reporting Services - 對數據源視圖 (DSV) 的報表模型 (SDML) 引用 (Reporting Services - Report Model (SDML) reference to Data Source View (DSV))

從 Visual Studio 2005 遷移到 2008 時要注意什麼? (What to look out for when moving from Visual Studio 2005 to 2008?)

動態改變另一個類的標籤值 (Dynamically changing the value of a label from another class)

在同一文件夾中為 .NET 5 和 .NET 6 Preview 3 構建 WebAssembly 項目 (Building WebAssembly project for both .NET 5 and .NET 6 Preview 3 in same folder)







留言討論