Skip to content
  • Brad King's avatar
    VS10: Fix working directory of consecutive custom commands (#11938) · 06fcbc47
    Brad King authored
    The VS 10 msbuild tool uses a single command shell to invoke all the
    custom command scripts in a project.  Isolate the environment and
    working directory of custom commands using setlocal/endlocal.  The
    form of each command is
    
      set errlev=
      setlocal
      cd c:\work\dir
      if %errorlevel% neq 0 goto :cmEnd
      c:
      if %errorlevel% neq 0 goto :cmEnd
      command1 ...
      if %errorlevel% neq 0 goto :cmEnd
      ...
      commandN ...
      if %errorlevel% neq 0 goto :cmEnd
      :cmEnd
      endlocal & set errlev=%errorlevel%
      if %errlev% neq 0 goto :VCEnd
    
    so that all changes to the environment and working directory are
    isolated within the script and the return code is preserved.
    06fcbc47