문제

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?

도움이 되었습니까?

해결책

This should do it:

FOR /F "tokens=3 delims=." %%F in ('$(SolutionDir)Tools\FileVer.exe /A /B /D !DESTINATION!\MyApplication.exe') DO SET VERSION=%%F.%%G.%%H
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top