简体   繁体   中英

Visual Studio Post-Build Events and Batch Commands

I didn't find any built-in alternative, so I'm using the following post-build command in my project to obtain the resulting assembly version:

FOR /F "tokens=4" %%F in ('$(SolutionDir)Tools\FileVer.exe /A /B /D !DESTINATION!\MyApplication.exe') DO SET VERSION=%%F
SET VERSION=!VERSION:~0,5!

FileVer is a free tool that can be downloaded from this page . Now... I need to retrieve all the version components except Revision. That's why I'm using that command to get a substring of the command result. The problem is that it works like a charm only if every version component is only one number long. So, for example, if I have:

1.0.0.0

It will properly retrieve:

1.0.0

But if I have:

1.12.0.0

I'll obtain a wrong result:

1.12.

Is there a better way to obtain the resulting assembly version without the Revision part and without using an external tool?

应该这样做:

FOR /F "tokens=3 delims=." %%F in ('$(SolutionDir)Tools\FileVer.exe /A /B /D !DESTINATION!\MyApplication.exe') DO SET VERSION=%%F.%%G.%%H

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM