注射程序集的版本号在构建时 [英] Injecting assembly version numbers at build time

查看:112
本文介绍了注射程序集的版本号在构建时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过把它当作MSBuild的命令行上的属性来改变C#项目在构建时的程序集版本号。

I want to change the assembly version number of a C# project at build time by passing it as a property on the MSBuild command line.

集信息工作将在编译之前修改里面的AssemblyInfo.cs的程序集版本。这几乎是我想要的。问题是我不希望因为源代码控制问题的AssemblyInfo.cs改变。我不希望所有这些AssemplyInfo.cs文件显示为被修改,并需要在每一个我们做一个生成时进行检查。

AssemblyInfo Task will modify the assembly version inside a AssemblyInfo.cs before compiling. This is nearly what I want. The problem is I don't want AssemblyInfo.cs to be changed because of source control issues. I don't want all these AssemplyInfo.cs files to show as being modified and needing to be checked in every time we do a build.

我想是一个东西,改变的程序集版本号编译之后 - 也许使用后生成的编织任务。请问这样的东西存在的地方无论是作为开源或零售产品?如果没有,可以有人点我的文档编写后生成韦弗任务?

What I would like is a "thing" that changes the assembly version number after compilation - perhaps using a post build weaving task. Does such a "thing" already exist somewhere either as open source or a retail product? If not, can someone point me to documentation for writing a post build weaver task?

推荐答案

由于的AssemblyVersion 不会弄熟到您的装配在编译时,在 AssemblyInfo.cs中文件与当前版本号不属于源头控制。

Since the AssemblyVersion does get cooked into your assembly at compile time, the AssemblyInfo.cs file with the current build number does belong in source control.

如果您的问题与源代码控制存储,这是因为你不想万吨需要被更新的文件,试试这个。

If your issue with storing this in source control is because you don't want tons of files that need to be updated, try this.

您可以在您的解决方案建立联系,使所有项目指向一个单一的文件,例如: SharedAssemblyInfo.cs 。下面是一个页面描述了这个过程:

You can establish links in your solution so that all projects point to a single file, e.g. SharedAssemblyInfo.cs. Here is a page describing this process:

<一个href="http://blogs.msdn.com/b/jjameson/archive/2009/04/03/shared-assembly-info-in-visual-studio-projects.aspx">http://blogs.msdn.com/b/jjameson/archive/2009/04/03/shared-assembly-info-in-visual-studio-projects.aspx

您可以使用集信息任务使用 SharedAssemblyInfo.cs 文件你知道已经,这将是一个需要重新检入源控制的唯一文件。

You can use the SharedAssemblyInfo.cs file using the AssemblyInfo task that you know about already, and this will be the only file that needs to be checked back into source control.

这篇关于注射程序集的版本号在构建时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆