@@ -287,6 +287,25 @@ function InstallDotNet([string] $dotnetRoot,
287
287
[string ] $runtimeSourceFeedKey = ' ' ,
288
288
[switch ] $noPath ) {
289
289
290
+ $dotnetVersionLabel = " 'sdk v$version '"
291
+
292
+ if ($runtime -ne ' ' -and $runtime -ne ' sdk' ) {
293
+ $runtimePath = $dotnetRoot
294
+ $runtimePath = $runtimePath + " \shared"
295
+ if ($runtime -eq " dotnet" ) { $runtimePath = $runtimePath + " \Microsoft.NETCore.App" }
296
+ if ($runtime -eq " aspnetcore" ) { $runtimePath = $runtimePath + " \Microsoft.AspNetCore.App" }
297
+ if ($runtime -eq " windowsdesktop" ) { $runtimePath = $runtimePath + " \Microsoft.WindowsDesktop.App" }
298
+ $runtimePath = $runtimePath + " \" + $version
299
+
300
+ $dotnetVersionLabel = " runtime toolset '$runtime /$architecture v$version '"
301
+
302
+ if (Test-Path $runtimePath ) {
303
+ Write-Host " Runtime toolset '$runtime /$architecture v$version ' already installed."
304
+ $installSuccess = $true
305
+ Exit
306
+ }
307
+ }
308
+
290
309
$installScript = GetDotNetInstallScript $dotnetRoot
291
310
$installParameters = @ {
292
311
Version = $version
@@ -323,18 +342,18 @@ function InstallDotNet([string] $dotnetRoot,
323
342
} else {
324
343
$location = " public location" ;
325
344
}
326
- Write-Host " Attempting to install dotnet from $location ."
345
+ Write-Host " Attempting to install $dotnetVersionLabel from $location ."
327
346
try {
328
347
& $installScript @variation
329
348
$installSuccess = $true
330
349
break
331
350
}
332
351
catch {
333
- Write-Host " Failed to install dotnet from $location ."
352
+ Write-Host " Failed to install $dotnetVersionLabel from $location ."
334
353
}
335
354
}
336
355
if (-not $installSuccess ) {
337
- Write-PipelineTelemetryError - Category ' InitializeToolset' - Message " Failed to install dotnet from any of the specified locations."
356
+ Write-PipelineTelemetryError - Category ' InitializeToolset' - Message " Failed to install $dotnetVersionLabel from any of the specified locations."
338
357
ExitWithExitCode 1
339
358
}
340
359
}
@@ -360,15 +379,22 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
360
379
}
361
380
362
381
# Minimum VS version to require.
363
- $vsMinVersionReqdStr = ' 16.8 '
382
+ $vsMinVersionReqdStr = ' 17.6 '
364
383
$vsMinVersionReqd = [Version ]::new($vsMinVersionReqdStr )
365
384
366
385
# If the version of msbuild is going to be xcopied,
367
386
# use this version. Version matches a package here:
368
- # https://dev.azure.com/dnceng/public/_packaging?_a=package& feed= dotnet-eng&package= RoslynTools.MSBuild&protocolType=NuGet&version=16.10 .0-preview2&view=overview
369
- $defaultXCopyMSBuildVersion = ' 16.10 .0-preview2 '
387
+ # https://dev.azure.com/dnceng/public/_artifacts/ feed/ dotnet-eng/NuGet/ RoslynTools.MSBuild/versions/17.6 .0-2
388
+ $defaultXCopyMSBuildVersion = ' 17.6 .0-2 '
370
389
371
- if (! $vsRequirements ) { $vsRequirements = $GlobalJson.tools.vs }
390
+ if (! $vsRequirements ) {
391
+ if (Get-Member - InputObject $GlobalJson.tools - Name ' vs' ) {
392
+ $vsRequirements = $GlobalJson.tools.vs
393
+ }
394
+ else {
395
+ $vsRequirements = New-Object PSObject - Property @ { version = $vsMinVersionReqdStr }
396
+ }
397
+ }
372
398
$vsMinVersionStr = if ($vsRequirements.version ) { $vsRequirements.version } else { $vsMinVersionReqdStr }
373
399
$vsMinVersion = [Version ]::new($vsMinVersionStr )
374
400
@@ -392,7 +418,8 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
392
418
# Locate Visual Studio installation or download x-copy msbuild.
393
419
$vsInfo = LocateVisualStudio $vsRequirements
394
420
if ($vsInfo -ne $null ) {
395
- $vsInstallDir = $vsInfo.installationPath
421
+ # Ensure vsInstallDir has a trailing slash
422
+ $vsInstallDir = Join-Path $vsInfo.installationPath " \"
396
423
$vsMajorVersion = $vsInfo.installationVersion.Split (' .' )[0 ]
397
424
398
425
InitializeVisualStudioEnvironmentVariables $vsInstallDir $vsMajorVersion
@@ -406,6 +433,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
406
433
if ($vsMinVersion -lt $vsMinVersionReqd ){
407
434
Write-Host " Using xcopy-msbuild version of $defaultXCopyMSBuildVersion since VS version $vsMinVersionStr provided in global.json is not compatible"
408
435
$xcopyMSBuildVersion = $defaultXCopyMSBuildVersion
436
+ $vsMajorVersion = $xcopyMSBuildVersion.Split (' .' )[0 ]
409
437
}
410
438
else {
411
439
# If the VS version IS compatible, look for an xcopy msbuild package
@@ -573,7 +601,7 @@ function InitializeBuildTool() {
573
601
ExitWithExitCode 1
574
602
}
575
603
$dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName ' dotnet' )
576
- $buildTool = @ { Path = $dotnetPath ; Command = ' msbuild' ; Tool = ' dotnet' ; Framework = ' netcoreapp3.1 ' }
604
+ $buildTool = @ { Path = $dotnetPath ; Command = ' msbuild' ; Tool = ' dotnet' ; Framework = ' net8.0 ' }
577
605
} elseif ($msbuildEngine -eq " vs" ) {
578
606
try {
579
607
$msbuildPath = InitializeVisualStudioMSBuild - install:$restore
@@ -635,18 +663,26 @@ function InitializeNativeTools() {
635
663
InstallDirectory = " $ToolsDir "
636
664
}
637
665
}
666
+ if ($env: NativeToolsOnMachine ) {
667
+ Write-Host " Variable NativeToolsOnMachine detected, enabling native tool path promotion..."
668
+ $nativeArgs += @ { PathPromotion = $true }
669
+ }
638
670
& " $PSScriptRoot /init-tools-native.ps1" @nativeArgs
639
671
}
640
672
}
641
673
674
+ function Read-ArcadeSdkVersion () {
675
+ return $GlobalJson .' msbuild-sdks' .' Microsoft.DotNet.Arcade.Sdk'
676
+ }
677
+
642
678
function InitializeToolset () {
643
679
if (Test-Path variable:global:_ToolsetBuildProj) {
644
680
return $global :_ToolsetBuildProj
645
681
}
646
682
647
683
$nugetCache = GetNuGetPackageCachePath
648
684
649
- $toolsetVersion = $GlobalJson . ' msbuild-sdks ' . ' Microsoft.DotNet.Arcade.Sdk '
685
+ $toolsetVersion = Read-ArcadeSdkVersion
650
686
$toolsetLocationFile = Join-Path $ToolsetDir " $toolsetVersion .txt"
651
687
652
688
if (Test-Path $toolsetLocationFile ) {
@@ -731,6 +767,8 @@ function MSBuild() {
731
767
(Join-Path $basePath (Join-Path netcoreapp2.1 ' Microsoft.DotNet.Arcade.Sdk.dll' ))
732
768
(Join-Path $basePath (Join-Path netcoreapp3.1 ' Microsoft.DotNet.ArcadeLogging.dll' )),
733
769
(Join-Path $basePath (Join-Path netcoreapp3.1 ' Microsoft.DotNet.Arcade.Sdk.dll' ))
770
+ (Join-Path $basePath (Join-Path net7.0 ' Microsoft.DotNet.ArcadeLogging.dll' )),
771
+ (Join-Path $basePath (Join-Path net7.0 ' Microsoft.DotNet.Arcade.Sdk.dll' ))
734
772
)
735
773
$selectedPath = $null
736
774
foreach ($path in $possiblePaths ) {
@@ -803,7 +841,8 @@ function MSBuild-Core() {
803
841
Write-Host " See log: $buildLog " - ForegroundColor DarkGray
804
842
}
805
843
806
- if ($ci ) {
844
+ # When running on Azure Pipelines, override the returned exit code to avoid double logging.
845
+ if ($ci -and $env: SYSTEM_TEAMPROJECT -ne $null ) {
807
846
Write-PipelineSetResult - Result " Failed" - Message " msbuild execution failed."
808
847
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
809
848
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
@@ -898,11 +937,13 @@ if (!$disableConfigureToolsetImport) {
898
937
function Enable-Nuget-EnhancedRetry () {
899
938
if ($ci ) {
900
939
Write-Host " Setting NUGET enhanced retry environment variables"
901
- $env: NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY = ' true'
902
- $env: NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT = 6
903
- $env: NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS = 1000
904
- Write-PipelineSetVariable - Name ' NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY' - Value ' true'
905
- Write-PipelineSetVariable - Name ' NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT' - Value ' 6'
906
- Write-PipelineSetVariable - Name ' NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS' - Value ' 1000'
940
+ $env: NUGET_ENABLE_ENHANCED_HTTP_RETRY = ' true'
941
+ $env: NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT = 6
942
+ $env: NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS = 1000
943
+ $env: NUGET_RETRY_HTTP_429 = ' true'
944
+ Write-PipelineSetVariable - Name ' NUGET_ENABLE_ENHANCED_HTTP_RETRY' - Value ' true'
945
+ Write-PipelineSetVariable - Name ' NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT' - Value ' 6'
946
+ Write-PipelineSetVariable - Name ' NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS' - Value ' 1000'
947
+ Write-PipelineSetVariable - Name ' NUGET_RETRY_HTTP_429' - Value ' true'
907
948
}
908
949
}
0 commit comments