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
This commit is contained in:
Mike Griese 2021-11-23 06:35:21 -06:00 committed by GitHub
parent ea456cf121
commit 6ad848e158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 8 deletions

View File

@ -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" (