setLocal

Dear team,

I find myself once again spending an afternoon trying to decypher the setlocal build error.

I would kindly request that this post-build script needs a rewrite to handle and print intelligible error report at the point where the error occurs rather than dumping the whole script as error message. Reporting the whole script as MSB3073 and generic C0000005 (-1,073,741,819) is really unhelpful.

I understand there are many threads on this topic and a dedicated article in the docs. But none of that covers even a proportion of ways things can go wrong in this script.

Here is the offending script. All I’m asking is to put our “coding standards” lens and look at this:

setlocal
"C:\Program Files\CMake\bin\cmake.exe" -E copy C:/apps/VST_SDK/vst3sdk/cmake/modules/../templates/VST_Logo_Steinberg.ico C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/PlugIn.ico
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E copy C:/apps/VST_SDK/vst3sdk/cmake/modules/../templates/desktop.ini.in C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/desktop.ini
if %errorlevel% neq 0 goto :cmEnd
attrib +s C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/desktop.ini
if %errorlevel% neq 0 goto :cmEnd
attrib +s C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/PlugIn.ico
if %errorlevel% neq 0 goto :cmEnd
attrib +s C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
cd C:\Users\user\Documents\vst\pluginName\build\bin
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd
C:\Users\user\Documents\vst\pluginName\build\bin\Debug\moduleinfotool.exe -create -version 1.0.0.1 -path C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3 -output C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/Contents/Resources/moduleinfo.json
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
cd C:\Users\user\Documents\vst\pluginName\build\bin
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E echo [SMTG] Validator started...
if %errorlevel% neq 0 goto :cmEnd
C:\Users\user\Documents\vst\pluginName\build\bin\Debug\validator.exe C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/Contents/x86_64-win/pluginName.vst3
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E echo [SMTG] Validator finished.
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd

Simply, when something goes wrong it’s impossible to tell which command failed or why.

Many thanks in advance

1 Like

It seems that your plugin crash during validation. In order to get a better debugging you could add in the Project Properties=>Debugging => Command : the path to the validator.exe and in the Command Arguments the path to your plugin.vst3

Start the debugger (F5) to fix your plugin check.
Maybe you have to disable the Post-Build Event