如何动态更新Assemblyinfo.cs中的值

Sim*_*ons 6 c# wpf assemblies .net-4.0 assemblyinfo

我编写了一个从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))]
Run Code Online (Sandbox Code Playgroud)

Vin*_*ayC 4

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

您可以为此创建 MS 构建任务:请参阅http://florent.clairambault.fr/insert-svn-version-and-build-number-in-your-c-assembleinfo-file

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

最后,您可能可以推出自定义代码(执行正则表达式搜索/替换)来执行某些人(包括我)所做的相同操作 - 请参阅此处的一个这样的示例: http: //www.codeproject.com/Articles/168528/自动保持程序集修订同步