Skip to content

fix(pipeline): inline cargo config to avoid git dependency in windows_build_container - #53

Merged
msftsiwei merged 4 commits into
mainfrom
fix/pipeline-partial-clone-cargo-config
Apr 19, 2026
Merged

fix(pipeline): inline cargo config to avoid git dependency in windows_build_container#53
msftsiwei merged 4 commits into
mainfrom
fix/pipeline-partial-clone-cargo-config

Conversation

@msftsiwei

@msftsiwei msftsiwei commented Apr 19, 2026

Copy link
Copy Markdown
Member

Problem

The OneBranch windows_build_container strips .git and uses partial clone (--filter=blob:none), so:

  • C:\__w\1\s is NOT a git repo
  • git show HEAD:.github/workflows/ado-cargo-config.toml fails with "fatal: not a git repository"
  • File blobs are not on disk (partial clone)

Solution

Write the cargo config inline via PowerShell + .NET WriteAllText with UTF8Encoding($false) (no BOM) instead of relying on git or file presence.

Also removes the now-unreferenced .github/workflows/ado-cargo-config.toml.

Notes

  • [System.IO.File]::WriteAllText with new UTF8Encoding($false) produces UTF-8 without BOM, matching the prior on-disk format
  • ADO pipelines run in PowerShell FullLanguage mode, so .NET methods are available
  • The $lines block is intentionally duplicated in both x64 and arm64 jobs — ADO YAML does not support YAML anchors/aliases, so de-duplication is not possible without a shared template

…_build_container

OneBranch windows_build_container strips .git and uses partial clone
(--filter=blob:none), so git commands fail. Write config inline via
PowerShell Set-Content instead of relying on git show or file presence.
Copilot AI review requested due to automatic review settings April 19, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the OneBranch sign-and-release workflow to make the ADO Cargo configuration independent of git metadata and local blob availability, which is necessary in windows_build_container (no .git, partial clone with missing blobs).

Changes:

  • Replace git show-based materialization of .cargo/config.toml with an inline PowerShell Set-Content write.
  • Apply the same inline config generation in both Windows x64 and Windows arm64 signing jobs.
  • Update step naming/commentary to reflect the new approach.
Show a summary per file
File Description
.github/workflows/sign-and-release.yml Writes ADO-specific Cargo config inline to avoid reliance on .git/blob presence in OneBranch Windows build containers.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (2)

.github/workflows/sign-and-release.yml:159

  • Set-Content -Encoding UTF8 in Windows PowerShell 5.1 writes a UTF-8 BOM. Previously this step wrote UTF-8 without BOM (via UTF8Encoding($false)), and some TOML consumers can choke on a BOM at the beginning of the file. Consider writing the file with an explicit no-BOM UTF8 encoding (e.g., keep using [System.IO.File]::WriteAllText/WriteAllLines with UTF8Encoding($false)), while still inlining the content.
                  $lines = @(
                    '[registries.devdiv-deepprompt]',
                    'index = "sparse+https://pkgs.dev.azure.com/devdiv/_packaging/DeepPrompt/Cargo/index/"',
                    '',
                    '[source.crates-io]',
                    'replace-with = "devdiv-deepprompt"',
                    '',
                    '[source.devdiv-deepprompt]',
                    'registry = "sparse+https://pkgs.dev.azure.com/devdiv/_packaging/DeepPrompt/Cargo/index/"',
                    '',
                    '[target.x86_64-pc-windows-msvc]',
                    'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]',
                    '',
                    '[target.aarch64-pc-windows-msvc]',
                    'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"]'
                  )
                  $lines | Set-Content -Path "$dstDir\config.toml" -Encoding UTF8 -Force
                  Write-Host "Written: $dstDir\config.toml"

.github/workflows/sign-and-release.yml:157

  • The same TOML payload is duplicated in both Windows jobs. This creates a maintenance risk if the registry URL or rustflags need to change (the two blocks can silently diverge). Consider factoring this into a single reusable YAML anchor/variable, or generating it from a shared PowerShell here-string/function reused by both jobs.
                  $lines = @(
                    '[registries.devdiv-deepprompt]',
                    'index = "sparse+https://pkgs.dev.azure.com/devdiv/_packaging/DeepPrompt/Cargo/index/"',
                    '',
                    '[source.crates-io]',
                    'replace-with = "devdiv-deepprompt"',
                    '',
                    '[source.devdiv-deepprompt]',
                    'registry = "sparse+https://pkgs.dev.azure.com/devdiv/_packaging/DeepPrompt/Cargo/index/"',
                    '',
                    '[target.x86_64-pc-windows-msvc]',
                    'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]',
                    '',
                    '[target.aarch64-pc-windows-msvc]',
                    'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"]'
                  )
  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread .github/workflows/sign-and-release.yml Outdated
# OneBranch uses windows_build_container which strips .git and
# uses partial clone (--filter=blob:none), so file blobs are not
# on disk and git commands fail. We write the config inline here.
# Content mirrors .pipelines/.cargo/config.toml in the repo.

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the inline content mirrors .pipelines/.cargo/config.toml, but this repo doesn’t appear to have a .pipelines directory. It looks like the source-of-truth is .github/workflows/ado-cargo-config.toml (the file that used to be git show’d). Update the comment (and consider removing/relocating the now-unreferenced TOML file to avoid future drift).

This issue also appears in the following locations of the same file:

  • line 142
  • line 142
Suggested change
# Content mirrors .pipelines/.cargo/config.toml in the repo.
# Content mirrors .github/workflows/ado-cargo-config.toml in the repo.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: updated the comment to remove the stale .pipelines reference, and deleted .github/workflows/ado-cargo-config.toml from this branch since it is no longer referenced.

Copilot AI review requested due to automatic review settings April 19, 2026 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

.github/workflows/sign-and-release.yml:297

  • Same as the x64 job: Set-Content -Encoding UTF8 on Windows PowerShell 5.1 writes UTF-8 with BOM, whereas the previous implementation wrote UTF-8 without BOM. Consider writing the joined $lines with UTF8Encoding($false) to keep the file format stable across agents.
                    '[target.aarch64-pc-windows-msvc]',
                    'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"]'
                  )
                  $lines | Set-Content -Path "$dstDir\config.toml" -Encoding UTF8 -Force
                  Write-Host "Written: $dstDir\config.toml"
  • Files reviewed: 2/2 changed files
  • Comments generated: 4

Comment thread .github/workflows/sign-and-release.yml Outdated
Comment on lines 159 to 160
$lines | Set-Content -Path "$dstDir\config.toml" -Encoding UTF8 -Force
Write-Host "Written: $dstDir\config.toml"

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switches the config write from an explicit UTF-8 without BOM (previous UTF8Encoding($false)) to Set-Content -Encoding UTF8, which in Windows PowerShell 5.1 writes UTF-8 with BOM. To preserve the prior on-disk format (and avoid any BOM-sensitive TOML consumers), write via .NET with new UTF8Encoding($false) (or equivalent) using the $lines array content.

This issue also appears on line 293 of the same file.

Suggested change
$lines | Set-Content -Path "$dstDir\config.toml" -Encoding UTF8 -Force
Write-Host "Written: $dstDir\config.toml"
$configPath = "$dstDir\config.toml"
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
$content = [string]::Join([Environment]::NewLine, $lines)
[System.IO.File]::WriteAllText($configPath, $content, $utf8NoBom)
Write-Host "Written: $configPath"

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: switched to [System.IO.File]::WriteAllText($configPath, $content, $utf8NoBom) with New-Object System.Text.UTF8Encoding($false) to produce UTF-8 without BOM. ADO pipelines run in FullLanguage mode so .NET methods are available.

Comment on lines +136 to +138
# on disk and git commands fail. We write the config inline here.
# (ado-cargo-config.toml in this directory was the former source
# of truth; it has been removed since it is no longer referenced.)

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-of-file "How it works" section still states that .github/workflows/ado-cargo-config.toml is copied into .cargo/config.toml, but this PR removes that file and writes the config inline. Please update that header documentation to match the new behavior so future pipeline debugging isn't misled.

Suggested change
# on disk and git commands fail. We write the config inline here.
# (ado-cargo-config.toml in this directory was the former source
# of truth; it has been removed since it is no longer referenced.)
# on disk and git commands fail. This workflow defines the cargo
# config inline in this step and writes it to .cargo/config.toml.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the comment now reads "We write the config inline here. (ado-cargo-config.toml in this directory was the former source of truth; it has been removed since it is no longer referenced.)"

Comment on lines +133 to +138
# Step 4: Write ADO-specific .cargo/config.toml.
# OneBranch uses windows_build_container which strips .git and
# uses partial clone (--filter=blob:none), so file blobs are not
# on disk and git commands fail. We write the config inline here.
# (ado-cargo-config.toml in this directory was the former source
# of truth; it has been removed since it is no longer referenced.)

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions mirroring .pipelines/.cargo/config.toml, but this repo doesn't appear to have a .pipelines directory and the prior source of truth was .github/workflows/ado-cargo-config.toml. Please correct the description (or add the referenced file) to avoid confusion about where the canonical config lives.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: updated the PR description to correctly reference .github/workflows/ado-cargo-config.toml as the former source of truth.

Comment on lines +143 to +158
$lines = @(
'[registries.devdiv-deepprompt]',
'index = "sparse+https://pkgs.dev.azure.com/devdiv/_packaging/DeepPrompt/Cargo/index/"',
'',
'[source.crates-io]',
'replace-with = "devdiv-deepprompt"',
'',
'[source.devdiv-deepprompt]',
'registry = "sparse+https://pkgs.dev.azure.com/devdiv/_packaging/DeepPrompt/Cargo/index/"',
'',
'[target.x86_64-pc-windows-msvc]',
'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]',
'',
'[target.aarch64-pc-windows-msvc]',
'rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"]'
)

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline $lines = @(... ) config block is duplicated in both jobs. Since this is now the only source of truth, consider de-duplicating via a YAML anchor/alias or a shared template variable to prevent the two copies drifting over time.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADO YAML (used by OneBranch) does not support YAML anchors/aliases, so the $lines block cannot be de-duplicated via YAML. A shared template step would require a separate template file and extends: syntax, which is a larger refactor outside the scope of this fix. The duplication is intentional and documented.

@msftsiwei
msftsiwei enabled auto-merge April 19, 2026 06:22
@msftsiwei
msftsiwei merged commit c924add into main Apr 19, 2026
9 of 10 checks passed
@msftsiwei
msftsiwei deleted the fix/pipeline-partial-clone-cargo-config branch April 19, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants