問題描述
我可以在 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:
- Right‑click on your project in the Solution Explorer, point to "Add", and click "Existing Item."
- Navigate to your global assembly file and select it.
- 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 holzleube、Cody Gray、Alois Kraus、holzleube)