@@ -162,12 +162,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
162162 $env: DOTNET_CLI_TELEMETRY_OPTOUT = 1
163163 }
164164
165- # Keep repo builds isolated from machine-installed SDK state and workload advertising.
166- # This avoids preview SDK builds picking up mismatched workloads on CI images.
167- $env: DOTNET_MULTILEVEL_LOOKUP = ' 0'
168- $env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE = ' 1'
169- $env: DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE = ' 1'
170-
171165 # Find the first path on %PATH% that contains the dotnet.exe
172166 if ($useInstalledDotNetCli -and (-not $globalJsonHasRuntimes ) -and ($env: DOTNET_INSTALL_DIR -eq $null )) {
173167 $dotnetExecutable = GetExecutableFileName ' dotnet'
@@ -230,9 +224,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
230224 Write-PipelinePrependPath - Path $dotnetRoot
231225
232226 Write-PipelineSetVariable - Name ' DOTNET_NOLOGO' - Value ' 1'
233- Write-PipelineSetVariable - Name ' DOTNET_MULTILEVEL_LOOKUP' - Value ' 0'
234- Write-PipelineSetVariable - Name ' DOTNET_SKIP_FIRST_TIME_EXPERIENCE' - Value ' 1'
235- Write-PipelineSetVariable - Name ' DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE' - Value ' 1'
236227
237228 return $global :_DotNetInstallDir = $dotnetRoot
238229}
@@ -599,16 +590,16 @@ function GetDefaultMSBuildEngine() {
599590 ExitWithExitCode 1
600591}
601592
602- function GetNuGetPackageCachePath () {
593+ function InitializeNuGetPackageCachePath () {
603594 if ($env: NUGET_PACKAGES -eq $null ) {
604595 # Use local cache on CI to ensure deterministic build.
605- # Avoid using the http cache as workaround for https://github.com/NuGet/Home/issues/3116
606596 # use global cache in dev builds to avoid cost of downloading packages.
607597 # For directory normalization, see also: https://github.com/NuGet/Home/issues/7968
608598 if ($useGlobalNuGetCache ) {
609- $env: NUGET_PACKAGES = Join-Path $env: UserProfile ' .nuget\packages\'
599+ $userProfile = if (IsWindowsPlatform) { $env: UserProfile } else { $env: HOME }
600+ $env: NUGET_PACKAGES = [IO.Path ]::Combine($userProfile , ' .nuget' , ' packages' ) + [IO.Path ]::DirectorySeparatorChar
610601 } else {
611- $env: NUGET_PACKAGES = Join- Path $RepoRoot ' .packages\ '
602+ $env: NUGET_PACKAGES = [ IO. Path]::Combine( $RepoRoot , ' .packages' ) + [ IO.Path ]::DirectorySeparatorChar
612603 }
613604 }
614605
@@ -657,8 +648,6 @@ function InitializeToolset() {
657648 return $global :_InitializeToolset
658649 }
659650
660- $nugetCache = GetNuGetPackageCachePath
661-
662651 $toolsetVersion = Read-ArcadeSdkVersion
663652 $toolsetToolsDir = Join-Path $ToolsetDir $toolsetVersion
664653
@@ -679,7 +668,7 @@ function InitializeToolset() {
679668 ExitWithExitCode 1
680669 }
681670
682- $downloadArgs = @ (" package" , " download" , " Microsoft.DotNet.Arcade.Sdk@$toolsetVersion " , " --verbosity" , " minimal" , " --prerelease" , " --output" , " $nugetCache " )
671+ $downloadArgs = @ (" package" , " download" , " Microsoft.DotNet.Arcade.Sdk@$toolsetVersion " , " --verbosity" , " minimal" , " --prerelease" , " --output" , " $nugetPackageCachePath " )
683672 $nugetConfig = $env: NUGET_CONFIG
684673 if (-not $nugetConfig ) {
685674 # Search for any variation of nuget.config in the RepoRoot
@@ -696,7 +685,7 @@ function InitializeToolset() {
696685 }
697686 DotNet @downloadArgs
698687
699- $packageDir = Join-Path $nugetCache (Join-Path ' microsoft.dotnet.arcade.sdk' $toolsetVersion )
688+ $packageDir = Join-Path $nugetPackageCachePath (Join-Path ' microsoft.dotnet.arcade.sdk' $toolsetVersion )
700689 $packageToolsetDir = Join-Path $packageDir ' toolset'
701690
702691 if (! (Test-Path $packageToolsetDir )) {
@@ -747,58 +736,6 @@ function Stop-Processes() {
747736# Terminates the script if the build fails.
748737#
749738function MSBuild () {
750- if ($ci ) {
751- $env: NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS = 20
752- $env: NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS = 20
753- Write-PipelineSetVariable - Name ' NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS' - Value ' 20'
754- Write-PipelineSetVariable - Name ' NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS' - Value ' 20'
755-
756- Enable-Nuget - EnhancedRetry
757- }
758-
759- MSBuild- Core @args
760- }
761-
762- #
763- # Executes a dotnet command with arguments passed to the function.
764- # Terminates the script if the command fails.
765- #
766- function DotNet () {
767- $dotnetRoot = InitializeDotNetCli - install:$restore
768- $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName ' dotnet' )
769-
770- $cmdArgs = " "
771- foreach ($arg in $args ) {
772- if ($null -ne $arg -and $arg.Trim () -ne " " ) {
773- if ($arg.EndsWith (' \' )) {
774- $arg = $arg + " \"
775- }
776- $cmdArgs += " `" $arg `" "
777- }
778- }
779-
780- $env: ARCADE_BUILD_TOOL_COMMAND = " `" $dotnetPath `" $cmdArgs "
781-
782- $exitCode = Exec- Process $dotnetPath $cmdArgs
783-
784- if ($exitCode -ne 0 ) {
785- Write-Host " dotnet command failed with exit code $exitCode . Check errors above." - ForegroundColor Red
786-
787- if ($ci -and $env: SYSTEM_TEAMPROJECT -ne $null -and ! $fromVMR ) {
788- Write-PipelineSetResult - Result " Failed" - Message " dotnet command execution failed."
789- ExitWithExitCode 0
790- } else {
791- ExitWithExitCode $exitCode
792- }
793- }
794- }
795-
796- #
797- # Executes msbuild (or 'dotnet msbuild') with arguments passed to the function.
798- # The arguments are automatically quoted.
799- # Terminates the script if the build fails.
800- #
801- function MSBuild-Core () {
802739 if ($ci ) {
803740 if (! $binaryLog -and ! $excludeCIBinarylog ) {
804741 Write-PipelineTelemetryError - Category ' Build' - Message ' Binary log must be enabled in CI build, or explicitly opted-out from with the -excludeCIBinarylog switch.'
@@ -811,16 +748,10 @@ function MSBuild-Core() {
811748 }
812749 }
813750
814- Enable-Nuget - EnhancedRetry
815-
816751 $buildTool = InitializeBuildTool
817752
818753 $cmdArgs = " $ ( $buildTool.Command ) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci "
819754
820- if ($ci -and $buildTool.Tool -eq ' dotnet' ) {
821- $cmdArgs += ' /p:MSBuildEnableWorkloadResolver=false'
822- }
823-
824755 # Add -mt flag for MSBuild multithreaded mode if enabled via environment variable
825756 if ($env: MSBUILD_MT_ENABLED -eq " 1" ) {
826757 $cmdArgs += ' -mt'
@@ -874,6 +805,40 @@ function MSBuild-Core() {
874805 }
875806}
876807
808+ #
809+ # Executes a dotnet command with arguments passed to the function.
810+ # Terminates the script if the command fails.
811+ #
812+ function DotNet () {
813+ $dotnetRoot = InitializeDotNetCli - install:$restore
814+ $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName ' dotnet' )
815+
816+ $cmdArgs = " "
817+ foreach ($arg in $args ) {
818+ if ($null -ne $arg -and $arg.Trim () -ne " " ) {
819+ if ($arg.EndsWith (' \' )) {
820+ $arg = $arg + " \"
821+ }
822+ $cmdArgs += " `" $arg `" "
823+ }
824+ }
825+
826+ $env: ARCADE_BUILD_TOOL_COMMAND = " `" $dotnetPath `" $cmdArgs "
827+
828+ $exitCode = Exec- Process $dotnetPath $cmdArgs
829+
830+ if ($exitCode -ne 0 ) {
831+ Write-Host " dotnet command failed with exit code $exitCode . Check errors above." - ForegroundColor Red
832+
833+ if ($ci -and $env: SYSTEM_TEAMPROJECT -ne $null -and ! $fromVMR ) {
834+ Write-PipelineSetResult - Result " Failed" - Message " dotnet command execution failed."
835+ ExitWithExitCode 0
836+ } else {
837+ ExitWithExitCode $exitCode
838+ }
839+ }
840+ }
841+
877842function GetMSBuildBinaryLogCommandLineArgument ($arguments ) {
878843 foreach ($argument in $arguments ) {
879844 if ($argument -ne $null ) {
@@ -958,19 +923,5 @@ if (!$disableConfigureToolsetImport) {
958923 }
959924}
960925
961- #
962- # If $ci flag is set, turn on (and log that we did) special environment variables for improved Nuget client retry logic.
963- #
964- function Enable-Nuget-EnhancedRetry () {
965- if ($ci ) {
966- Write-Host " Setting NUGET enhanced retry environment variables"
967- $env: NUGET_ENABLE_ENHANCED_HTTP_RETRY = ' true'
968- $env: NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT = 6
969- $env: NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS = 1000
970- $env: NUGET_RETRY_HTTP_429 = ' true'
971- Write-PipelineSetVariable - Name ' NUGET_ENABLE_ENHANCED_HTTP_RETRY' - Value ' true'
972- Write-PipelineSetVariable - Name ' NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT' - Value ' 6'
973- Write-PipelineSetVariable - Name ' NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS' - Value ' 1000'
974- Write-PipelineSetVariable - Name ' NUGET_RETRY_HTTP_429' - Value ' true'
975- }
976- }
926+ # Initialize the nuget package cache vars
927+ $nugetPackageCachePath = InitializeNuGetPackageCachePath
0 commit comments