I would like to add the version of the compiler to an auto-generated release notes file.
Currently, this is what I have:
echo "compiler version:" >>Release_Note.txt
MSBuild.exe -version >>Release_Note.txt
"echo "END." >>Release_Note.txt
When launching this post-build event, it fails with error 9009, most probably because the file MSBuild.exe is not found.
When taking a look at the possible macros, the only "programming environment" related one is DevEnvDir, which equals C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\ on my computer.
A quick search tells me that I have two files MSBuild.exe on my PC, located in these directories:
- C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin
- C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64
Both directories are not child folders of the mentioned DevEnvDir macro, so I'm hesitant to use them.
Is there a $Compiler.exe post-build event macro, which I can use for launching the MSBuild.exe -version command?
MsBuild --versionreturns the version of MsBuild, which is (more or less) related to the Visual Studio version. This is not the version of the dotnet (C#) compiler used. To get the .NET version that was used during build usedotnet --versioninstead (which will in turn report the version that was specified in yourglobal.json, if it exists).To call
dotnetyou don't have to search in magical paths, because that is available in the default path.