@@ -96,10 +96,7 @@ function Exec-Process([string]$command, [string]$commandArgs) {
9696 }
9797}
9898
99- # createSdkLocationFile parameter enables a file being generated under the toolset directory
100- # which writes the sdk's location into. This is only necessary for cmd --> powershell invocations
101- # as dot sourcing isn't possible.
102- function InitializeDotNetCli ([bool ]$install , [bool ]$createSdkLocationFile ) {
99+ function InitializeDotNetCli ([bool ]$install ) {
103100 if (Test-Path variable:global:_DotNetInstallDir) {
104101 return $global :_DotNetInstallDir
105102 }
@@ -149,24 +146,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
149146 $env: DOTNET_INSTALL_DIR = $dotnetRoot
150147 }
151148
152- # Creates a temporary file under the toolset dir.
153- # The following code block is protecting against concurrent access so that this function can
154- # be called in parallel.
155- if ($createSdkLocationFile ) {
156- do {
157- $sdkCacheFileTemp = Join-Path $ToolsetDir $ ([System.IO.Path ]::GetRandomFileName())
158- }
159- until (! (Test-Path $sdkCacheFileTemp ))
160- Set-Content - Path $sdkCacheFileTemp - Value $dotnetRoot
161-
162- try {
163- Rename-Item - Force - Path $sdkCacheFileTemp ' sdk.txt'
164- } catch {
165- # Somebody beat us
166- Remove-Item - Path $sdkCacheFileTemp
167- }
168- }
169-
170149 # Add dotnet to PATH. This prevents any bare invocation of dotnet in custom
171150 # build steps from using anything other than what we've downloaded.
172151 # It also ensures that VS msbuild will use the downloaded sdk targets.
@@ -205,7 +184,14 @@ function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $arc
205184 InstallDotNet $dotnetRoot $version $architecture
206185}
207186
208- function InstallDotNet ([string ] $dotnetRoot , [string ] $version , [string ] $architecture = " " , [string ] $runtime = " " , [bool ] $skipNonVersionedFiles = $false ) {
187+ function InstallDotNet ([string ] $dotnetRoot ,
188+ [string ] $version ,
189+ [string ] $architecture = " " ,
190+ [string ] $runtime = " " ,
191+ [bool ] $skipNonVersionedFiles = $false ,
192+ [string ] $runtimeSourceFeed = " " ,
193+ [string ] $runtimeSourceFeedKey = " " ) {
194+
209195 $installScript = GetDotNetInstallScript $dotnetRoot
210196 $installParameters = @ {
211197 Version = $version
@@ -220,7 +206,7 @@ function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $archit
220206 & $installScript @installParameters
221207 }
222208 catch {
223- Write-PipelineTelemetryError - Category ' InitializeToolset' - Message " Failed to install dotnet runtime '$runtime ' from public location."
209+ Write-PipelineTelemetryError - Category " InitializeToolset" - Message " Failed to install dotnet runtime '$runtime ' from public location."
224210
225211 # Only the runtime can be installed from a custom [private] location.
226212 if ($runtime -and ($runtimeSourceFeed -or $runtimeSourceFeedKey )) {
@@ -236,7 +222,7 @@ function InstallDotNet([string] $dotnetRoot, [string] $version, [string] $archit
236222 & $installScript @installParameters
237223 }
238224 catch {
239- Write-PipelineTelemetryError - Category ' InitializeToolset' - Message " Failed to install dotnet runtime '$runtime ' from custom location '$runtimeSourceFeed '."
225+ Write-PipelineTelemetryError - Category " InitializeToolset" - Message " Failed to install dotnet runtime '$runtime ' from custom location '$runtimeSourceFeed '."
240226 ExitWithExitCode 1
241227 }
242228 } else {
@@ -298,11 +284,8 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
298284 $vsMajorVersion = $vsMinVersion.Major
299285 $xcopyMSBuildVersion = " $vsMajorVersion .$ ( $vsMinVersion.Minor ) .0-alpha"
300286 }
301-
302- $vsInstallDir = $null
303- if ($xcopyMSBuildVersion.Trim () -ine " none" ) {
304- $vsInstallDir = InitializeXCopyMSBuild $xcopyMSBuildVersion $install
305- }
287+
288+ $vsInstallDir = InitializeXCopyMSBuild $xcopyMSBuildVersion $install
306289 if ($vsInstallDir -eq $null ) {
307290 throw " Unable to find Visual Studio that has required version and components installed"
308291 }
0 commit comments