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

查看:320
本文介绍了在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

推荐答案

我做到了!

感谢 Stinky Towel 提供了有用的评论. 我必须修改脚本以使其在我的配置下运行,并且如您所见,我使用的是wmic而不是Windows 10上找不到的filever. 这是我的脚本,效果很好:

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天全站免登陆