Include version number in exe file name in C# Visual Studio desktop application

我们两清 提交于 2020-01-06 19:27:47

问题


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

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

EDIT

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


回答1:


I made it !

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` 


来源:https://stackoverflow.com/questions/39857934/include-version-number-in-exe-file-name-in-c-sharp-visual-studio-desktop-applica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!