使用 MSBuild 更新版本信息(二进制文件编译后)
我想在我的 MSBuild 脚本中创建一个目标:
- 从源文件夹中获取 SVN 修订版/日期时间(“svn info”命令)
- 从“build”目标生成的 .EXE 和 .DLL 更新 VERSIONINFO 资源
有准备好完成此任务吗?我在重新发明另一个轮子之前问...
I want to make a target in my MSBuild script that:
- Fetch SVN revision/datetime from sources folder ('svn info' command)
- Update VERSIONINFO resource from .EXEs and .DLLs generated by 'build' target
There is something ready to accomplish this? I'm asking just before reinvent another wheel...
I'm giving a look into http://msbuildextensionpack.codeplex.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MSBuild 社区任务项目 是您的朋友。检查他们的“SvnInfo”任务。
另外,Daniel Doubrovkine 的 ResourceLib 是一项出色的工作,可以避免您在尝试解决问题时遇到很多麻烦。 VERSIONINFO 创建混乱(去过那里,做过那件事......)
MSBuild Community Tasks Project is your friend. Check their "SvnInfo" task.
Also, Daniel Doubrovkine's ResourceLib is an excellent piece of work and can avoid you lots of headaches when trying to untangle the VERSIONINFO creation mess (been there, done that...)
通过编写项目中包含的 AssemblyInfo 文件(或任何具有程序集属性的文件),在编译之前可以更轻松地完成此操作。
在 powershell 中编写此示例的示例如下: https:/ /github.com/craigbeck/rhino-esb/blob/master/psake_ext.ps1#L7-46
一个警告 - .net 中的版本不仅仅是任何字符串,而是
ushort
这意味着它们的最大值为 65535(请参阅文档此处)。如果您使用 svn 修订版(正如我们在某一时刻所做的那样),一旦超过该幻数,您的构建就会中断。为什么编译后要尝试这样做?
Much easier to do this before compilation by writing an AssemblyInfo file (or any file with assembly attributes) thats included in your projects.
Example of writing this in powershell found here: https://github.com/craigbeck/rhino-esb/blob/master/psake_ext.ps1#L7-46
One caveat -- the versions in .net are not just any string but
ushort
s which means they have a max of 65535 (see docs here). If you use the svn revision (as we did at one point) your build will break once it exceeds that magic number.Why would you be trying to do this after compilation?