VS10: Fix working directory of consecutive custom commands (#11938)

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.
This commit is contained in:
Brad King
2011-04-08 10:40:57 -04:00
parent a961ecdad0
commit 06fcbc4757
4 changed files with 35 additions and 22 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ public:
const char* path);
protected:
virtual std::string CheckForErrorLine();
virtual const char* ReportErrorLabel() const;
private:
};