Skip to content

Commit 3605c8b

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
move CFS check ahead of installing tree-sitter
1 parent ba97e27 commit 3605c8b

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

build.ps1

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,39 @@ if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore
171171
if ($null -ne $packageType) {
172172
$SkipBuild = $true
173173
} else {
174+
if ($UseCFS -or $UseCFSAuth -or $usingADO) {
175+
Write-Host "Using CFS for cargo source replacement"
176+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
177+
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
178+
179+
if ($UseCFSAuth) {
180+
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
181+
throw "Azure CLI not found"
182+
}
183+
184+
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
185+
Write-Host "Getting token"
186+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
187+
if ($LASTEXITCODE -ne 0) {
188+
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
189+
} else {
190+
$header = "Bearer $accessToken"
191+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
192+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
193+
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
194+
}
195+
}
196+
else {
197+
Write-Warning "Azure CLI not found, proceeding with anonymous access."
198+
}
199+
}
200+
} else {
201+
# this will override the config.toml
202+
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
203+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
204+
$env:CARGO_REGISTRIES_CRATESIO_INDEX = 'sparse+https://index.crates.io/'
205+
}
206+
174207
## Test if Rust is installed
175208
if (!$usingADO -and !(Get-Command 'cargo' -ErrorAction Ignore)) {
176209
Write-Verbose -Verbose "Rust not found, installing..."
@@ -290,39 +323,6 @@ if (!$SkipBuild) {
290323
}
291324
New-Item -ItemType Directory $target -ErrorAction Ignore > $null
292325

293-
if ($UseCFS -or $UseCFSAuth -or $usingADO) {
294-
Write-Host "Using CFS for cargo source replacement"
295-
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
296-
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
297-
298-
if ($UseCFSAuth) {
299-
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
300-
throw "Azure CLI not found"
301-
}
302-
303-
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
304-
Write-Host "Getting token"
305-
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
306-
if ($LASTEXITCODE -ne 0) {
307-
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
308-
} else {
309-
$header = "Bearer $accessToken"
310-
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
311-
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
312-
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
313-
}
314-
}
315-
else {
316-
Write-Warning "Azure CLI not found, proceeding with anonymous access."
317-
}
318-
}
319-
} else {
320-
# this will override the config.toml
321-
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
322-
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
323-
$env:CARGO_REGISTRIES_CRATESIO_INDEX = 'sparse+https://index.crates.io/'
324-
}
325-
326326
# make sure dependencies are built first so clippy runs correctly
327327
$windows_projects = @("pal", "registry_lib", "registry", "reboot_pending", "wmi-adapter", "configurations/windows", 'extensions/appx')
328328
$macOS_projects = @("resources/brew")

0 commit comments

Comments
 (0)