I have a problem with my post-build event using robocopy. The code used to work a couple of days ago and now it is not working in any of my projects. Below, the code I use for my post-built events for creating plugins for different builds of the same app.
Edited as per Squashman and Mofi recommendations:
echo Configuration: $(Configuration)
set "Dir2018=C:\Program Files\Rune\Altem 2018\Plugins\"
set "Dir2019=C:\Program Files\Rune\Altem 2019\Plugins\"
set "Dir2020=C:\Program Files\Rune\Altem 2020\Plugins\"
if $(Configuration) == Debug2018 goto 2018
if $(Configuration) == Debug2019 goto 2019
if $(Configuration) == Debug2020 goto 2020
:2018
echo Copying results to 2018
if not exist "%Dir2018%$(ProjectName)" mkdir "%Dir2018%$(ProjectName)"
robocopy $(TargetDir) "%Dir2018%$(ProjectName)" /XF "*.pdb" /E
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
goto exit
:2019
echo Copying results to 2019
if not exist "%Dir2019%$(ProjectName)" mkdir "%Dir2019%$(ProjectName)"
robocopy "$(TargetDir)" "%Dir2019%$(ProjectName)" /XF "*.pdb" /E
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
goto exit
:2020
echo Copying results to 2020
if not exist "%Dir2020%$(ProjectName)" mkdir "%Dir2020%$(ProjectName)"
robocopy $(TargetDir) "%Dir2020%$(ProjectName)" /XF "*.pdb" /E
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
goto exit
:exit
The errors are shown in the visual studio:
Severity Code Description Project File Line Suppression State
Error The command "echo Configuration: Debug2019
set "Dir2018=C:\Program Files\Rune\Altem 2018\Plugins\"
set "Dir2019=C:\Program Files\Rune\Altem 2019\Plugins\"
set "Dir2020=C:\Program Files\Rune\Altem 2020\Plugins\"
if Debug2019 == Debug2018 goto 2018
if Debug2019 == Debug2019 goto 2019
if Debug2019 == Debug2020 goto 2020
:2018
echo Copying results to 2018
if not exist "%Dir2018%SnoopTool" mkdir "%Dir2018%SnoopTool"
robocopy C:\Users\username\OneDrive\_WORK FILES\_REPOS\nw_issuecreator\nw_issuecreator\SnoopTool\bin\Debug2019\ "%Dir2018%SnoopTool" /XF "*.pdb" /E
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
goto exit
:2019
echo Copying results to 2019
if not exist "%Dir2019%SnoopTool" mkdir "%Dir2019%SnoopTool"
robocopy "C:\Users\username\OneDrive\_WORK FILES\_REPOS\nw_issuecreator\nw_issuecreator\SnoopTool\bin\Debug2019\" "%Dir2019%SnoopTool" /XF "*.pdb" /E
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
goto exit
:2020
echo Copying results to 2020
if not exist "%Dir2020%SnoopTool" mkdir "%Dir2020%SnoopTool"
robocopy C:\Users\username\OneDrive\_WORK FILES\_REPOS\nw_issuecreator\nw_issuecreator\SnoopTool\bin\Debug2019\ "%Dir2020%SnoopTool" /XF "*.pdb" /E
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
goto exit
:exit" exited with code 16. SnoopTool
Invalid Parameter #3 : "C:\Program Files\Rune\Altem 2019\Plugins\SnoopTool"
The line if not exist %Dir2019%$(ProjectName) mkdir %Dir2019%$(ProjectName)
gets successfully executed. it creates the directory if it doesn't exist. However, I believe the problem is with the next line robocopy $(TargetDir) %Dir2019%$(ProjectName) /XF "*.pdb" /E
. I haven't changed anything in the apps, and this is happening in all my projects. Could has it been an update on how robocopy works? I am not sure. Completely puzzled here.
EDIT:
I updated my code to follow the recommendations from Squashman and Mofi, but the error persisted. I proceeded to delete most of the post-event code to narrow down the error:
echo Configuration: $(Configuration)
echo Copying results to 2019
robocopy $(TargetDir) "C:\Users\username\Documents\New folder (2)"
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
:exit
Even with the clearly explicit path, the error is still popping up:
Invalid Parameter #3 : "C:\Users\oscarramirez\Documents\New folder (2)"
Thanks for any help. And in case it is not obvious, I'm an amateur when it comes to code. I am not a developer by any mean, so be gentle if my error is a massive rookie mistake.