From 6ad848e15893aae881840caad503c1eef7f08cc2 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 23 Nov 2021 06:35:21 -0600 Subject: [PATCH] Prefer Preview VS builds always; use any existing msbuild if it's on the path (#11803) If msbuild is already on the path, we don't need to look for it. Also, > I know what I did. I installed VS 2022, which is a prerelease VS install. `tools\razzle` prefers the stable builds. I think I'm gonna remove that. * [x] Closes #1313 * [x] Closes #11446 --- tools/razzle.cmd | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/razzle.cmd b/tools/razzle.cmd index b0d4373b0..456e271d1 100644 --- a/tools/razzle.cmd +++ b/tools/razzle.cmd @@ -23,6 +23,16 @@ set PATH=%PATH%%OPENCON%\dep\nuget; rem Run nuget restore so you can use vswhere nuget restore %OPENCON%\OpenConsole.sln -Verbosity quiet +:FIND_MSBUILD +set MSBUILD= + +rem GH#1313: If msbuild is already on the path, we don't need to look for it. +for %%X in (msbuild.exe) do (set MSBUILD=%%~$PATH:X) +if defined MSBUILD ( + echo Using MsBuild at %MSBUILD% which was already on the path. + goto :FOUND_MSBUILD +) + rem Find vswhere rem from https://github.com/microsoft/vs-setup-samples/blob/master/tools/vswhere.cmd for /f "usebackq delims=" %%I in (`dir /b /aD /o-N /s "%~dp0..\packages\vswhere*" 2^>nul`) do ( @@ -37,22 +47,23 @@ if not defined VSWHERE ( ) rem Add path to MSBuild Binaries -for /f "usebackq tokens=*" %%B in (`%VSWHERE% -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe 2^>nul`) do ( +rem +rem We're going to always prefer prerelease version of VS. This lets people who +rem are using VS 2022 use that from the commandline over the 2019 version. This +rem will use whatever the newest version of VS is, regardless if it's stable or +rem not. +rem +for /f "usebackq tokens=*" %%B in (`%VSWHERE% -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe 2^>nul`) do ( set MSBUILD=%%B ) -rem Try to find MSBuild in prerelease versions of MSVS -if not defined MSBUILD ( - for /f "usebackq tokens=*" %%B in (`%VSWHERE% -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe 2^>nul`) do ( - set MSBUILD=%%B - ) -) - if not defined MSBUILD ( echo Could not find MsBuild on your machine. Please set the MSBUILD variable to the location of MSBuild.exe and run razzle again. goto :EXIT ) +:FOUND_MSBUILD + set PATH=%PATH%%MSBUILD%\..; if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (