Get Compiler Version & Build Config for use in a PostCompile Build action


#1

The following .cmd (.bat) file looks at the TASKLIST and gets the WindowTitle and parses that

@for /F "skip=9 tokens=2,3 delims=[]" %%I in ('tasklist /FI "IMAGENAME eq CLARION.EXE" -v /FO LIST') do @SET CompilerVer=%%I & SET BuildConfig=%%J
@SET  CompilerVer=%CompilerVer:~8,8%
@ECHO CompilerVer=%CompilerVer%
@ECHO BuildConfig=%BuildConfig%

Limitation: assumes that there is exactly one copy of the IDE running.


#2

I wonder if there is a way to make use of the string parser like you can for snippets in the code editor. Or perhaps msbuild macros that can be passed on the command line. Interesting. What is the issue you want to solve by getting the version and build config?


#3

The BuildConfig is an easy one to get, just use the MSBuild Macro:

$(Configuration)

There are a whole bunch of others but I can’t figure out how to get a proper list.

e.g. try this in the post-build event

ECHO "$(SharpDevelopBinPath)" && ECHO "$(Configuration)" && ECHO "$(MSBuildProjectFile)" && ECHO "$(Platform)" && ECHO $(ProjectGuid) && ECHO "$(DefineConstants)" && ECHO "$(ClarionBinPath)" && ECHO Version="$(clarion_version)" && ECHO Model="$(Model)" && ECHO Vid="$(vid)" && ECHO Warnings="$(warnings)"  && ECHO CPU="$(cpu)" && ECHO LineNumbers="$(line_numbers)" && ECHO MapFile="$(GenerateMap)" && ECHO CheckStack="$(check_stack)" && ECHO CheckIndex="$(check_index)" && ECHO StackSize="$(stack_size)" && ECHO Defines="$(DefineConstants)" && ECHO Includes="@(Include)" && ECHO References="@(Reference);@(ProjectReference)" && ECHO Sections="$(Configuration)" && ECHO Sources="@(Compile)" && ECHO Libraries="@(Library)" && ECHO FileDrivers="@(FileDriver)" && ECHO Icon="$(ApplicationIcon)" && ECHO TargetName="$(OutputName)" && ECHO TargetDir="$(OutputPath)" && ECHO TargetType="$(OutputType)" && ECHO RedirectionFile="$(RedFile)" && ECHO CopyCoreFiles="$(CopyCore)" && ECHO CopyableFiles="@(None)" && ECHO ConfigDir="$(ConfigDir)" && ECHO ProjectName="$(MSBuildProjectFile)" && ECHO NoDependency="$(NoDependency)" && ECHO Signal="$(Signal)"

Which will get you something like this:

"C:\Dev\Clarion\C9\bin" 
"Release" 
"ClaEvaluate.cwproj" 
"Win32" 
{DFDAFF8A-8D4A-420A-A28C-D2EAD50BA43F} 
"_ABCDllMode_=>0;_ABCLinkMode_=>2" 
"C:\Dev\Clarion\C9\bin" 
Version="" 
Model="Dll" 
Vid="off" 
Warnings="on"  
CPU="" 
LineNumbers="False" 
MapFile="True" 
CheckStack="False" 
CheckIndex="False" 
StackSize="16384" 
Defines="_ABCDllMode_=>0;_ABCLinkMode_=>2" 
Includes="" 
References=";" 
Sections="Release" 
Sources="ClaEvaluate.clw" 
Libraries="" 
FileDrivers="" 
Icon="appicon.ico" 
TargetName="ClaEvaluate" 
TargetDir="" 
TargetType="WinExe" 
RedirectionFile="" 
CopyCoreFiles="True" 
CopyableFiles="ClaEvaluate.exp" 
ConfigDir="" 
ProjectName="ClaEvaluate.cwproj" 
NoDependency="" 
Signal="ClarionSemc25b4aba-a436-4ff8-9b54-38397785cef4"

I think that pretty much anything in your *.cwproj is available. It looks like there is a “clarion_version” that gets set somewhere but for whatever reason it is not coming out in the post build. same for “Version” which is a bit of a pain.


Pre-build event - Kill Process Before Build
#4

https://docs.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=vs-2019 covers the list you’re looking for.

In case that page goes stale:

|Macro|Description|
|---|---|
|$(Configuration)|The name of the current project configuration, for example, "Debug".|
|$(DevEnvDir)|The installation directory of Visual Studio (defined as drive + path); includes the trailing backslash '\'.|
|$(FrameworkDir)|The directory into which the .NET Framework was installed.|
|$(FrameworkSDKDir)|The directory into which you installed the .NET Framework. The .NET Framework could have been installed as part of Visual Studio or separately.|
|$(FrameworkVersion)|The version of the .NET Framework used by Visual Studio. Combined with $(FrameworkDir), the full path to the version of the .NET Framework use by Visual Studio.|
|$(FxCopDir)|The path to the fxcop.cmd file. The fxcop.cmd file is not installed with all Visual Studio editions.|
|$(IntDir)|Path to the directory specified for intermediate files. If this is a relative path, intermediate files go to this path appended to the project directory. This path should have a trailing slash. This resolves to the value for the Intermediate Directory property. Do not use $(OutDir) to define this property.|
|$(OutDir)|Path to the output file directory. If this is a relative path, output files go to this path appended to the project directory. This path should have a trailing slash. This resolves to the value for the Output Directory property. Do not use $(IntDir) to define this property.|
|$(Platform)|The name of current project platform, for example, "Win32".|
|$(PlatformShortName)|The short name of current architecture, for example, "x86" or "x64".|
|$(ProjectDir)|The directory of the project (defined as drive + path); includes the trailing backslash '\'.|
|$(ProjectExt)|The file extension of the project. It includes the '.' before the file extension.|
|$(ProjectFileName)|The file name of the project (defined as base name + file extension).|
|$(ProjectName)|The base name of the project.|
|$(ProjectPath)|The absolute path name of the project (defined as drive + path + base name + file extension).|
|$(RemoteMachine)|Set to the value of the Remote Machine property on the Debug property page. See Changing Project Settings for a C/C++ Debug Configuration for more information.|
|$(RootNameSpace)|The namespace, if any, containing the application.|
|$(SolutionDir)|The directory of the solution (defined as drive + path); includes the trailing backslash '\'. Defined only when building a solution in the IDE.|
|$(SolutionExt)|The file extension of the solution. It includes the '.' before the file extension. Defined only when building a solution in the IDE.|
|$(SolutionFileName)|The file name of the solution (defined as base name + file extension). Defined only when building a solution in the IDE.|
|$(SolutionName)|The base name of the solution. Defined only when building a solution in the IDE.|
|$(SolutionPath)|The absolute path name of the solution (defined as drive + path + base name + file extension). Defined only when building a solution in the IDE.|
|$(TargetDir)|The directory of the primary output file for the build (defined as drive + path); includes the trailing backslash '\'.|
|$(TargetExt)|The file extension of the primary output file for the build. It includes the '.' before the file extension.|
|$(TargetFileName)|The file name of the primary output file for the build (defined as base name + file extension).|
|$(TargetName)|The base name of the primary output file for the build.|
|$(TargetPath)|The absolute path name of the primary output file for the build (defined as drive + path + base name + file extension).|
|$(VCInstallDir)|The directory that contains the C++ content of your Visual Studio installation. This property contains the version of the targeted Microsoft C++ (MSVC) toolset, which might be different that the host Visual Studio. For example, when building with $(PlatformToolset) = v140, $(VCInstallDir) contains the path to the Visual Studio 2015 installation.|
|$(VSInstallDir)|The directory into which you installed Visual Studio. This property contains the version of the targeted Visual Studio toolset, which might be different that the host Visual Studio. For example, when building with $(PlatformToolset) = v110, $(VSInstallDir) contains the path to the Visual Studio 2012 installation.|
|$(WebDeployPath)|The relative path from the web deployment root to where the project outputs belong. Returns the same value as RelativePath.|
|$(WebDeployRoot)|The absolute path to the location of <localhost>. For example, c:\inetpub\wwwroot.|