如何动态更新Assemblyinfo.cs中的值 [英] How to update the Value in Assemblyinfo.cs dynamically

查看:464
本文介绍了如何动态更新Assemblyinfo.cs中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个程序,该程序从SVN信息库获取值。现在我要使用该值更新AssemblyFileversion。



由于我无法在Assemblyinfo.cs内编写任何代码,因此如何更新AssemblyFileVersion的值。 / p>

我想实现这样的目标

  ... ..................... 
//程序集的版本信息由以下四个值组成:
//
/ /主要版本
//次要版本
//内部版本号
//修订版
//
//您可以指定所有值,也可以默认构建修订号
//通过使用'*',如下所示:
// [assembly:AssemblyVersion( 1.0。*)]

SvnInfoEventArgs info;
Uri repoURI = new Uri( ServerAddress);
svnClient.GetInfo(repoURI,out info);


[assembly:AssemblyVersion( 1.0.0.0)]
[assembly:AssemblyFileVersion(String.Format( {0}。{1}。{2}。 {3},
主要,次要,内部版本,信息。修订版))]


解决方案

我假设您正在尝试生成一些构建系统-因此,从本质上讲,您需要使用svn编号修改AssemblyInfo.cs文件。



您可以为其创建MS Build任务:请参见 http://florent.clairambault.fr/insert-svn-version-and-build-number-in-your-c-assemblyinfo-file



有命令行实用程序(SubWCRev)也可用于基于关键字的替换($ WCREV $用于修订)-请参见此处的示例:< a href = http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev-example.html rel = nofollow> http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev- example.html



最后,您可以推出自己的自定义代码(执行正则表达式搜索/替换)以完成某些(包括我)的操作完成-在此处查看这样的示例: http:/ /www.codeproject.com/Articles/168528/Automatically-keep-Assembly-rev isions-in-sync-with


I have writen a program which gets the value from SVN repository . Now I want to update the AssemblyFileversion with that value.

As I am not able to write any code inside Assemblyinfo.cs , how will I update the value of AssemblyFileVersion.

I want to achieve something like this

..........................
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

 SvnInfoEventArgs info;
                    Uri repoURI = new Uri("ServerAddress");
                    svnClient.GetInfo(repoURI, out info);


[assembly: AssemblyVersion("1.0.0.0")]
    [assembly: AssemblyFileVersion(String.Format("{0}.{1}.{2}. {3}",
                                          major,minor,build,info.Revision))]

解决方案

I am assuming that you are trying to generate some build system here - so essentially, you need to modify AssemblyInfo.cs file with svn number.

You can create MS Build task for the same: see http://florent.clairambault.fr/insert-svn-version-and-build-number-in-your-c-assemblyinfo-file

There is command line utility (SubWCRev) that can also be used for keyword based replacement ($WCREV$ for revision) - see the example here: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev-example.html

Finally, you can probably roll out your custom code (doing regex search/replace) to do the same which some (including me) has done - see one such example here: http://www.codeproject.com/Articles/168528/Automatically-keep-Assembly-revisions-in-sync-with.

这篇关于如何动态更新Assemblyinfo.cs中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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