Skip to content

Commit fb8a06b

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
Change build to have -UseCFS switch otherwise uses crates-io
1 parent 1b7ea41 commit fb8a06b

File tree

3 files changed

+24
-34
lines changed

3 files changed

+24
-34
lines changed

.cargo/config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ registry-auth = true
44

55
[registries]
66
powershell = { index = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/" }
7+
cratesio = { index = "sparse+https://index.crates.io/"}
8+
9+
[registry]
10+
global-credential-providers = ["cargo:token"]
711

812
# Enable Control Flow Guard (needed for OneBranch's post-build analysis).
913
[target.x86_64-pc-windows-msvc]
1014
rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]
1115

1216
[target.aarch64-windows-msvc]
1317
rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"]
18+
19+
# The following is only needed for release builds
20+
[source.crates-io]
21+
replace-with = "powershell"

.pipelines/DSC-Official.yml

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,7 @@ extends:
141141
ob_restore_phase: true
142142
- pwsh: |
143143
Set-Location "$(Build.SourcesDirectory)/DSC"
144-
Write-Host "Use 'powershell' CFS"
145-
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
146-
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
147-
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
148-
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'
149-
150-
./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck
144+
./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck -UseCFS
151145
displayName: 'Build $(buildName)'
152146
env:
153147
ob_restore_phase: true
@@ -279,13 +273,7 @@ extends:
279273
env:
280274
ob_restore_phase: true
281275
- pwsh: |
282-
Write-Host "Use 'powershell' CFS"
283-
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
284-
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
285-
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
286-
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'
287-
288-
./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu
276+
./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu -UseCFS
289277
./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-gnu -Release
290278
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
291279
displayName: 'Build x86_64-unknown-linux-gnu'
@@ -325,13 +313,7 @@ extends:
325313
env:
326314
ob_restore_phase: true
327315
- pwsh: |
328-
Write-Host "Use 'powershell' CFS"
329-
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
330-
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
331-
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
332-
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'
333-
334-
./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu
316+
./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu -UseCFS
335317
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-gnu -Release
336318
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
337319
displayName: 'Build aarch64-unknown-linux-gnu'
@@ -379,18 +361,7 @@ extends:
379361
env:
380362
ob_restore_phase: true
381363
- pwsh: |
382-
Write-Host "Use 'powershell' CFS"
383-
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
384-
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
385-
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
386-
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'
387-
388-
$c = get-content "./.cargo/config.toml" | Out-String
389-
Write-Host $c
390-
391-
$env:CARGO_HTTP_DEBUG=true
392-
$env:CARGO_LOG='network=trace'
393-
./build.ps1 -Release -Architecture $(buildName)
364+
./build.ps1 -Release -Architecture $(buildName) -UseCFS
394365
./build.ps1 -PackageType tgz -Architecture $(buildName) -Release
395366
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
396367
Write-Host "##vso[artifact.upload containerfolder=release;artifactname=release]$(ob_outputDirectory)/DSC-$(PackageVersion)-$(buildName).tar.gz"

build.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ param(
1212
[switch]$Test,
1313
[switch]$GetPackageVersion,
1414
[switch]$SkipLinkCheck,
15-
[switch]$UseX64MakeAppx
15+
[switch]$UseX64MakeAppx,
16+
[switch]$UseCFS
1617
)
1718

1819
if ($GetPackageVersion) {
@@ -171,6 +172,15 @@ if (!$SkipBuild) {
171172
}
172173
New-Item -ItemType Directory $target -ErrorAction Ignore > $null
173174

175+
if (!$UseCFS) {
176+
# this will override the config.toml
177+
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
178+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'cratesio'
179+
} else {
180+
Write-Host "Using CFS for cargo source replacement"
181+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
182+
}
183+
174184
# make sure dependencies are built first so clippy runs correctly
175185
$windows_projects = @("pal", "registry", "reboot_pending", "wmi-adapter")
176186

@@ -240,6 +250,7 @@ if (!$SkipBuild) {
240250

241251
if ($LASTEXITCODE -ne 0) {
242252
$failed = $true
253+
break
243254
}
244255

245256
$binary = Split-Path $project -Leaf

0 commit comments

Comments
 (0)