Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2011 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1193602 to your computer and use it in GitHub Desktop.
Save anonymous/1193602 to your computer and use it in GitHub Desktop.
diff --git a/vcbuild.bat b/vcbuild.bat
index 654421b..90e89d9 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -53,8 +53,19 @@ echo Project files generated.
@rem Skip project generation if requested.
if defined nobuild goto run
-if not defined VCINSTALLDIR echo Build skipped. To build, this file needs to run from VS cmd prompt.& goto run
-
+@rem Bail out early if not running in VS build env.
+if defined VCINSTALLDIR goto msbuild-found
+if not defined VS100COMNTOOLS goto msbuild-not-found
+if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
+call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
+if not defined VCINSTALLDIR goto msbuild-not-found
+goto msbuild-found
+
+:msbuild-not-found
+echo Build skipped. To build, this file needs to run from VS cmd prompt.
+goto run
+
+:msbuild-found
@rem Build the sln with msbuild.
msbuild node.sln /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment