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

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

我想实现这样的目标

..........................
// 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))]

最佳答案

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

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

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

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

关于c# - CodeGo.net>如何动态更新Assemblyinfo.cs中的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14254554/

10-12 12:49