如何协调许多 C# 项目树中的程序集版本信息?
您采取了哪些方法来协调程序集组的版本和版权更改?
我有一棵由许多 csprojs 组成的树,每个 csprojs 都有自己的 AssemblyInfo 文件。作为构建过程的一部分,我想设置版权年份和版本。看起来以下选项可用,但文件修改是迄今为止我见过的唯一选项:
- 通过脚本修改所有文件
- 包含带日期的资源(宏,带有公共静态变量的单例类)
- 在命令行上覆盖 AssemblyVersion ( -DAssemblyVersion="1.0.0.1" ?)
- 参考环境变量 (
[assemble: AssemblyFileVersion("${ENV.VERSION")]
)
我习惯于保持源树干净,不生成生成的文件通过命令行参数使用 Java/C++ 编写文件,定义所有版本规范并将其集中在一个文件中。
您使用什么方法来保持版本同步且易于管理?
谢谢
彼得
What approaches have you taken to coordinating changes to version and Copyright for groups of assemblies?
I have a tree of many csprojs each with its own AssemblyInfo file. As part of my build process I want to set copyright year and version. It looks like the following options be be available but file modification is the only one I've seen thus far:
- Modify all files via script
- Include resource with date (a macro, a singleton class with public static variables)
- Override AssemblyVersion on command line ( -DAssemblyVersion="1.0.0.1" ?)
- Reference Environment variable (
[assembly: AssemblyFileVersion("${ENV.VERSION")]
)
I'm used to keeping the source tree clean of generated files in Java/C++ via command line params, defines and centralizing all version specification in a single file.
What approach to do you use to keep the versions in sync and manageable?
Thanks
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在顶部文件夹中,我放置了一个 CommonAssemblyInfo.cs,其中包含...常见内容,例如版权和 FileVersion。该文件仅包含一些默认属性,并由构建服务器(在我的例子中为 Hudson)上的脚本(一个简单的 .bat 文件)重新生成。在每个项目 AssemblyInfo.cs 中删除这些公共属性。
在解决方案的每个项目中,我添加此文件。但使用“添加为链接” - 添加现有文件时,可在“添加”按钮的下拉菜单中使用。即所有项目都只包含对同一文件的引用,因此只有一个文件需要更新。
In the top folder, I place a CommonAssemblyInfo.cs that contains the ... common stuff, such as copyright and FileVersion. This file is just contains some default attributes and is regenerated by a script(a simple .bat file) on the build server, Hudson in my case. Remove these common attributes in each of the projects AssemblyInfo.cs.
In each project in the solution, I add this file. but use "Add as link" - available in the drop down of the "Add" button when you add an existing file. i.e. all projects just contains a reference to the same file, so there's only one file to update.
无论您采用哪种方式实际更新版本号,都可以使用单独的 AssemblyInfo.cs 文件来指定共享版本。
在结构方面高于其他项目的某个级别创建文件,然后将其添加到所有项目(从 Visual Studio 中),但执行此操作时请务必选择“添加为链接”。
我也使用 MSBuild 任务来处理更新,我只是想不起来 - 你使用哪个构建引擎?
Regardless of which route you take to actually update the version number, you can use an individual AssemblyInfo.cs file to specify a shared version.
Create the file at some level above the other projects, in terms of structure, then add it to all projects (from within Visual Studio), but when doing so be sure to select 'Add as link'.
I've used an MSBuild task to handle the updating, too, I just can't think of it - which build engine do you use?
理论上您可以拥有一个汇编文件。只需链接所有其他项目中的文件:添加现有文件>>链接文件而不是添加(按钮下拉列表)
You can theoretically have one single assembly file. Just link the file in all other projects: Add existing file >> link file instead of adding (button dropdown)