Skip to content

Commit a37b87a

Browse files
committed
Update check for VS
1 parent eb64949 commit a37b87a

1 file changed

Lines changed: 5 additions & 40 deletions

File tree

build.cmd

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir bin
66

77
:Build
88

9-
REM Require VS2019 (v16.0) on the system. Use `vswhere` for the search because it can find all VS installations.
9+
REM Require Visual Studio on the system. Use `vswhere` for the search because it can find all VS installations.
1010
set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
1111
if not exist %vswhere% (
1212
set vswhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
@@ -23,54 +23,19 @@ if not exist %vswhere% (
2323
)
2424

2525
set InstallDir=
26-
for /f "usebackq tokens=*" %%i in (`%vswhere% -version 16 -latest -prerelease -products * ^
27-
-requires Microsoft.Net.Component.4.5.TargetingPack ^
28-
-requires Microsoft.Net.Component.4.5.2.TargetingPack ^
29-
-requires Microsoft.Net.Component.4.6.2.TargetingPack ^
26+
for /f "usebackq tokens=*" %%i in (`%vswhere% -latest -prerelease -products * ^
3027
-property installationPath`) do (
3128
set "InstallDir=%%i"
3229
)
3330

3431
if not DEFINED InstallDir (
35-
echo "Could not find a VS2019 installation with the necessary components (targeting packs for v4.5, v4.5.2, and v4.6.2)."
36-
echo Please install VS2019 or the missing components.
32+
echo "Could not find a Visual Studio installation."
33+
echo Please install Visual Studio or the missing components.
3734
goto BuildFail
3835
)
3936

40-
REM Find a 64bit MSBuild and add it to path. Require v17.4 or later due to our .NET SDK choice.
41-
REM Check for VS2022 first.
42-
set InstallDir=
43-
for /f "usebackq tokens=*" %%i in (`%vswhere% -version 17.4 -latest -prerelease -products * ^
44-
-requires Microsoft.Component.MSBuild ^
45-
-property installationPath`) do (
46-
set "InstallDir=%%i"
47-
)
48-
49-
if DEFINED InstallDir (
50-
REM Add MSBuild to the path.
51-
set "PATH=%InstallDir%\MSBuild\Current\Bin;%PATH%"
52-
goto FoundMSBuild
53-
)
54-
55-
REM Otherwise find or install an xcopy-able MSBuild.
56-
echo "Could not find a VS2022 installation with the necessary components (MSBuild). Falling back..."
57-
58-
set "MSBuildVersion=17.4.1"
59-
set "Command=[System.Threading.Thread]::CurrentThread.CurrentCulture = ''"
60-
set "Command=%Command%; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''"
61-
set "Command=%Command%; try { & '%~dp0eng\GetXCopyMSBuild.ps1' %MSBuildVersion%; exit $LASTEXITCODE }"
62-
set "Command=%Command% catch { write-host $_; exit 1 }"
63-
PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "%Command%"
64-
if %ERRORLEVEL% neq 0 goto BuildFail
65-
6637
REM Add MSBuild to the path.
67-
set "PATH=%~dp0.msbuild\%MSBuildVersion%\tools\MSBuild\Current\Bin;%PATH%"
68-
69-
:FoundMSBuild
70-
REM Configure NuGet operations to work w/in this repo i.e. do not pollute system packages folder.
71-
REM Note this causes two copies of packages restored using packages.config to land in this folder e.g.
72-
REM StyleCpy.5.0.0/ and stylecop/5.0.0/.
73-
set "NUGET_PACKAGES=%~dp0packages"
38+
set "PATH=%InstallDir%\MSBuild\Current\Bin;%PATH%"
7439

7540
REM Are we running in a local dev environment (not on CI)?
7641
if DEFINED CI (set Desktop=false) else if DEFINED TEAMCITY_VERSION (set Desktop=false) else (set Desktop=true)

0 commit comments

Comments
 (0)