@@ -375,12 +375,11 @@ function InstallDotNet([string] $dotnetRoot,
375375#
376376# 1. MSBuild from an active VS command prompt
377377# 2. MSBuild from a compatible VS installation
378- # 3. MSBuild from the xcopy tool package
379378#
380379# Returns full path to msbuild.exe.
381380# Throws on failure.
382381#
383- function InitializeVisualStudioMSBuild ([bool ] $install , [ object ]$vsRequirements = $null ) {
382+ function InitializeVisualStudioMSBuild ([object ]$vsRequirements = $null ) {
384383 if (-not (IsWindowsPlatform)) {
385384 throw " Cannot initialize Visual Studio on non-Windows"
386385 }
@@ -390,13 +389,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
390389 }
391390
392391 # Minimum VS version to require.
393- $vsMinVersionReqdStr = ' 17.7'
394- $vsMinVersionReqd = [Version ]::new($vsMinVersionReqdStr )
395-
396- # If the version of msbuild is going to be xcopied,
397- # use this version. Version matches a package here:
398- # https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/Microsoft.DotNet.Arcade.MSBuild.Xcopy/versions/18.0.0
399- $defaultXCopyMSBuildVersion = ' 18.0.0'
392+ $vsMinVersionReqdStr = ' 18.0'
400393
401394 if (! $vsRequirements ) {
402395 if (Get-Member - InputObject $GlobalJson.tools - Name ' vs' ) {
@@ -426,46 +419,16 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
426419 }
427420 }
428421
429- # Locate Visual Studio installation or download x-copy msbuild .
422+ # Locate Visual Studio installation.
430423 $vsInfo = LocateVisualStudio $vsRequirements
431- if ($vsInfo -ne $null -and $ env: ForceUseXCopyMSBuild -eq $null ) {
424+ if ($vsInfo -ne $null ) {
432425 # Ensure vsInstallDir has a trailing slash
433426 $vsInstallDir = Join-Path $vsInfo.installationPath " \"
434427 $vsMajorVersion = $vsInfo.installationVersion.Split (' .' )[0 ]
435428
436429 InitializeVisualStudioEnvironmentVariables $vsInstallDir $vsMajorVersion
437430 } else {
438- if (Get-Member - InputObject $GlobalJson.tools - Name ' xcopy-msbuild' ) {
439- $xcopyMSBuildVersion = $GlobalJson.tools .' xcopy-msbuild'
440- $vsMajorVersion = $xcopyMSBuildVersion.Split (' .' )[0 ]
441- } else {
442- # if vs version provided in global.json is incompatible (too low) then use the default version for xcopy msbuild download
443- if ($vsMinVersion -lt $vsMinVersionReqd ){
444- Write-Host " Using xcopy-msbuild version of $defaultXCopyMSBuildVersion since VS version $vsMinVersionStr provided in global.json is not compatible"
445- $xcopyMSBuildVersion = $defaultXCopyMSBuildVersion
446- $vsMajorVersion = $xcopyMSBuildVersion.Split (' .' )[0 ]
447- }
448- else {
449- # If the VS version IS compatible, look for an xcopy msbuild package
450- # with a version matching VS.
451- # Note: If this version does not exist, then an explicit version of xcopy msbuild
452- # can be specified in global.json. This will be required for pre-release versions of msbuild.
453- $vsMajorVersion = $vsMinVersion.Major
454- $vsMinorVersion = $vsMinVersion.Minor
455- $xcopyMSBuildVersion = " $vsMajorVersion .$vsMinorVersion .0"
456- }
457- }
458-
459- $vsInstallDir = $null
460- if ($xcopyMSBuildVersion.Trim () -ine " none" ) {
461- $vsInstallDir = InitializeXCopyMSBuild $xcopyMSBuildVersion $install
462- if ($vsInstallDir -eq $null ) {
463- throw " Could not xcopy msbuild. Please check that package 'Microsoft.DotNet.Arcade.MSBuild.Xcopy @ $xcopyMSBuildVersion ' exists on feed 'dotnet-eng'."
464- }
465- }
466- if ($vsInstallDir -eq $null ) {
467- throw ' Unable to find Visual Studio that has required version and components installed'
468- }
431+ throw ' Unable to find Visual Studio that has required version and components installed'
469432 }
470433
471434 $msbuildVersionDir = if ([int ]$vsMajorVersion -lt 16 ) { " $vsMajorVersion .0" } else { " Current" }
@@ -492,38 +455,6 @@ function InitializeVisualStudioEnvironmentVariables([string] $vsInstallDir, [str
492455 }
493456}
494457
495- function InstallXCopyMSBuild ([string ]$packageVersion ) {
496- return InitializeXCopyMSBuild $packageVersion - install $true
497- }
498-
499- function InitializeXCopyMSBuild ([string ]$packageVersion , [bool ]$install ) {
500- $packageName = ' Microsoft.DotNet.Arcade.MSBuild.Xcopy'
501- $packageDir = Join-Path $ToolsDir " msbuild\$packageVersion "
502- $packagePath = Join-Path $packageDir " $packageName .$packageVersion .nupkg"
503-
504- if (! (Test-Path $packageDir )) {
505- if (! $install ) {
506- return $null
507- }
508-
509- Create- Directory $packageDir
510-
511- Write-Host " Downloading $packageName $packageVersion "
512- $ProgressPreference = ' SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit
513- Retry({
514- Invoke-WebRequest " https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName /$packageVersion /$packageName .$packageVersion .nupkg" - UseBasicParsing - OutFile $packagePath
515- })
516-
517- if (! (Test-Path $packagePath )) {
518- Write-PipelineTelemetryError - Category ' InitializeToolset' - Message " See https://dev.azure.com/dnceng/internal/_wiki/wikis/DNCEng%20Services%20Wiki/1074/Updating-Microsoft.DotNet.Arcade.MSBuild.Xcopy-WAS-RoslynTools.MSBuild-(xcopy-msbuild)-generation?anchor=troubleshooting for help troubleshooting issues with XCopy MSBuild"
519- throw
520- }
521- Unzip $packagePath $packageDir
522- }
523-
524- return Join-Path $packageDir ' tools'
525- }
526-
527458#
528459# Locates Visual Studio instance that meets the minimal requirements specified by tools.vs object in global.json.
529460#
@@ -633,7 +564,7 @@ function InitializeBuildTool() {
633564 $buildTool = @ { Path = $dotnetPath ; Command = ' msbuild' ; Tool = ' dotnet' ; Framework = ' net' }
634565 } elseif ($msbuildEngine -eq " vs" ) {
635566 try {
636- $msbuildPath = InitializeVisualStudioMSBuild - install: $restore
567+ $msbuildPath = InitializeVisualStudioMSBuild
637568 } catch {
638569 Write-PipelineTelemetryError - Category ' InitializeToolset' - Message $_
639570 ExitWithExitCode 1
0 commit comments