Skip to content

Commit

Permalink
Example scripts to locate and run msbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
heaths committed Nov 8, 2017
1 parent 23e71b3 commit 80426ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="vswhere" version="2.2.11" />
</packages>
22 changes: 22 additions & 0 deletions tools/msbuild.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@REM Copyright (C) Microsoft Corporation. All rights reserved.
@REM Licensed under the MIT license. See LICENSE.txt in the project root for license information.

@if not defined _echo echo off
setlocal enabledelayedexpansion

@REM Determine if MSBuild is already in the PATH
for /f "usebackq delims=" %%I in (`where msbuild.exe 2^>nul`) do (
"%%I" %*
exit /b !ERRORLEVEL!
)

@REM Find the latest MSBuild that supports our projects
for /f "usebackq delims=" %%I in (`call "%~dp0vswhere.cmd" -version "[15.0,)" -latest -prerelease -products * -requires Microsoft.Component.MSBuild Microsoft.VisualStudio.Component.Roslyn.Compiler Microsoft.VisualStudio.Component.VC.140 -property InstallationPath`) do (
for /f "usebackq delims=" %%J in (`where /r "%%I\MSBuild" msbuild.exe 2^>nul ^| sort /r`) do (
"%%J" %*
exit /b !ERRORLEVEL!
)
)

echo Could not find msbuild.exe 1>&2
exit /b 2
12 changes: 12 additions & 0 deletions tools/vswhere.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@REM Copyright (C) Microsoft Corporation. All rights reserved.
@REM Licensed under the MIT license. See LICENSE.txt in the project root for license information.

@if not defined _echo echo off
setlocal enabledelayedexpansion

for /f "usebackq delims=" %%I in (`dir /b /aD /o-N /s "%~dp0..\packages\vswhere*"`) do (
for /f "usebackq delims=" %%J in (`where /r "%%I" vswhere.exe 2^>nul`) do (
"%%J" %*
exit /b !ERRORLEVEL!
)
)

0 comments on commit 80426ad

Please sign in to comment.