hsnslh
hsnslh

Reputation: 65

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

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

Upvotes: 0

Views: 2671

Answers (1)

hsnslh
hsnslh

Reputation: 65

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` 

Upvotes: 1

Related Questions