如何在 Devenv 中指定发布版本?
我是通过脚本构建 Visual Studio 项目的新手,所以如果您认为我对该过程的理解不正确,请随时纠正我。
我有一个 Visual Studio 解决方案,其中包含一个 Wpf.exe 项目和一些类库项目。
目前我正在使用下面的脚本成功构建 .sln
文件
"%VS_IDE_DIR%devenv.com" "...Solution-File-Path.sln" /rebuild Release /useenv
目前,Wpf.exe
文件获取文件版本
和产品版本
1.0.0.0
这是在中指定的默认值发布 -> Wpf 项目的发布版本
属性。
我想以某种方式设置文件版本
和产品版本< /code> 通过我的脚本。我怎样才能做到这一点?
我有一个环境变量
,其中包含产品版本
和文件版本
,基本上我想将产品版本和文件版本的值设置为等于我的环境变量。
I am totally new in building Visual Studio Project through a script, so feel free to correct me if you feel that my understanding about the process is incorrect.
I have a visual studio solution which consists of a Wpf.exe project and few class library projects.
Currently I am successfully building .sln
file using script below
"%VS_IDE_DIR%devenv.com" "...Solution-File-Path.sln" /rebuild Release /useenv
Currently the Wpf.exe
file gets the File Version
and Product Version
1.0.0.0
which is the default specified in Publish -> Publish Version
Property of Wpf project.
I want to somehow set the File Version
and Product Version
through my script. How can I achieve that?
I have an environment variable
which contains the Product Version
and File Version
, Basically I want to set value of Product Version and File Version equal to my environment variable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个简单的方法可以做到这一点。在 WPF 项目中,打开“属性”节点并双击 AssemblyInfo.cs。 [程序集:AssemblyFileVersion] 属性设置文件版本号。添加此项以设置产品版本号:
从命令行执行此操作仅在技术上可行。您必须创建本机文件版本资源并使用 rc.exe 对其进行编译。并使用 Project + Properties、Resource file 选项告诉编译器使用 rc.exe 生成的自定义 .res 文件。您需要编写脚本来更新版本资源。鉴于通过编辑 AssemblyInfo.cs 来完成此操作是多么容易,我建议您不要费心。
There's a simple way to do this. In the WPF project, open the Properties node and double-click AssemblyInfo.cs. The [assembly: AssemblyFileVersion] attribute sets the File Version number. Add this to set the Product Version number:
Doing this from the command line is only technically possible. You'd have to create the native file version resource and compile it with rc.exe. And use Project + Properties, Resource file option to tell the compiler to use the custom .res file produced by rc.exe. You'd need scripting to get the version resource updated. Given how easy it is to do this by editing AssemblyInfo.cs, I'd recommend you don't bother.
您可以在运行 ms build 命令时添加
/p:ApplicationVersion=1.0.0.1
。指定的版本号将是项目在编译 exe 时将使用的版本号。更新:
我已将项目标记内的以下 xml 代码添加到我的解决方案的项目文件中。
You can add
/p:ApplicationVersion=1.0.0.1
while running the ms build command. The version number specified will be the version number the project will use while compiling the exe.Update:
I have added the following xml code inside the project tag to the project file of my solution.