|
15 | 15 | [switch]$UseX64MakeAppx, |
16 | 16 | [switch]$UseCratesIO, |
17 | 17 | [switch]$UpdateLockFile, |
18 | | - [switch]$Audit |
| 18 | + [switch]$Audit, |
| 19 | + [switch]$UseCFSAuth |
19 | 20 | ) |
20 | 21 |
|
21 | 22 | if ($GetPackageVersion) { |
@@ -191,25 +192,26 @@ if (!$SkipBuild) { |
191 | 192 | ${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null |
192 | 193 | $env:CARGO_REGISTRIES_CRATESIO_INDEX = $null |
193 | 194 |
|
194 | | - if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) { |
195 | | - throw "Azure CLI not found" |
196 | | - } |
| 195 | + if ($UseCFSAuth -or $null -ne $env:TF_BUILD) { |
| 196 | + if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) { |
| 197 | + throw "Azure CLI not found" |
| 198 | + } |
197 | 199 |
|
198 | | - if ($null -ne (Get-Command az -ErrorAction Ignore)) { |
199 | | - Write-Host "Getting token" |
200 | | - $accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv |
201 | | - if ($LASTEXITCODE -ne 0) { |
202 | | - Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access." |
203 | | - $env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/" |
204 | | - } else { |
205 | | - $header = "Bearer $accessToken" |
206 | | - $env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header |
207 | | - $env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token' |
| 200 | + if ($null -ne (Get-Command az -ErrorAction Ignore)) { |
| 201 | + Write-Host "Getting token" |
| 202 | + $accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv |
| 203 | + if ($LASTEXITCODE -ne 0) { |
| 204 | + Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access." |
| 205 | + } else { |
| 206 | + $header = "Bearer $accessToken" |
| 207 | + $env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/" |
| 208 | + $env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header |
| 209 | + $env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token' |
| 210 | + } |
| 211 | + } |
| 212 | + else { |
| 213 | + Write-Warning "Azure CLI not found, proceeding with anonymous access." |
208 | 214 | } |
209 | | - } |
210 | | - else { |
211 | | - Write-Warning "Azure CLI not found, proceeding with anonymous access." |
212 | | - $env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/" |
213 | 215 | } |
214 | 216 | } |
215 | 217 |
|
|
0 commit comments