在 C# Visual Studio 桌面应用程序的 exe 文件名中包含版本号 [英] Include version number in exe file name in C# Visual Studio desktop application

查看:45
本文介绍了在 C# Visual Studio 桌面应用程序的 exe 文件名中包含版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处寻找解决方案,但我认为这是不可能的!

I looked everywhere for a solution, and I think that it's impossible to do that !

我可以在 .exe 文件名中包含版本号(在 AssemblyInfo.cs 中)吗?所以我不必再在每个发布版本中重命名输出 exe 文件了.

Can I include the version number (that is in AssemblyInfo.cs) into the .exe filename ? So I don't have anymore to rename the output exe file every release build.

我刚刚发布了这个问题,以确保事实上,这是不可能的.否则,如果有人有一个可行的解决方案,我会很高兴知道.谢谢

I just posted this question to be sure that in fact, it is impossible to do that. Otherwise, if someone has a working solution I'll be happy to know it. Thank you

编辑

我不是在寻找如何获取我可以找到的程序集版本,而是在寻找如何将该版本自动包含到我的 .exe 输出文件名中

I'm not searching how to get the assembly version, which I can find, but I'm looking for how to include that version automatically into my .exe output file name

推荐答案

我做到了!

感谢臭毛巾的有用评论.我不得不修改脚本以使其在我的配置下运行,正如您所看到的,我使用 wmic 而不是 filever,而我在 Windows 10 上找不到.这是我运行良好的脚本:

Thanks to Stinky Towel for that helpful comment. I had to modify the script to make it run under my configuration, and as you can see I worked with wmic instead of filever which I couldn't find on Windows 10. Here is my script that worked fine:

`@echo off
set filepath=%1
set filename=%2
set dblslash=%filepath:=\%

FOR /F "tokens=2 delims==" %%I IN (
  'wmic datafile where "name='%dblslash%'" get version /format:list'
) DO SET "AssemblyVersion=%%I"
ECHO %AssemblyVersion%
move /Y %filepath% %filename%_%AssemblyVersion%.exe` 

这篇关于在 C# Visual Studio 桌面应用程序的 exe 文件名中包含版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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