Fix Rust SDK NuGet source configuration - #1049
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Someone is attempting to deploy a commit to the MSFT-AIP Team on Vercel. A member of the Team first needs to authorize it. |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 2
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
sdk_v2/rust/build.rs — This guard checks the shared output directory rather than what the current archive extracted. When… |
|
sdk_v2/rust/build_support.rs — URL schemes are case-insensitive, and feed validation accepts mixed-case HTTPS, but this scanner… |
What changed in this PR
Adds configurable native NuGet acquisition for the Rust SDK, including authenticated tooling-based restores.
Changes:
- Adds HTTP,
dotnet, andnugetacquisition modes. - Adds URL redaction and version-marker cache handling.
- Documents and tests the new configuration.
| File | Description |
|---|---|
sdk_v2/rust/build.rs |
Integrates restore modes, staging, and caching. |
sdk_v2/rust/build_support.rs |
Adds shared configuration and restore helpers. |
sdk_v2/rust/tests/build_support_test.rs |
Tests configuration, arguments, redaction, and caching. |
sdk_v2/rust/README.md |
Documents acquisition modes and variables. |
sdk_v2/rust/Cargo.toml |
Includes build support in published crates. |
Suppressed comments (1)
sdk_v2/rust/build.rs:362
- The destination may already contain this filename with a mismatched/absent marker. If the restored package contains other native files but not its expected binary, this check sees the stale destination, writes the requested version marker, and permanently treats the old binary as current. Verify that
filesitself containspkg.expected_filebefore staging and recording the marker.
if out_dir.join(&pkg.expected_file).exists() {
build_support::record_package_version(out_dir, &pkg.expected_file, &pkg.version)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
sdk_v2/rust/build.rs — Each feed attempt still extracts every matching native library directly into the shared output… |
Issues resolved since last review (2)
| Severity | Finding |
|---|---|
sdk_v2/rust/build_support.rs — URL schemes are case-insensitive, and feed validation accepts mixed-case HTTPS, but this scanner… View resolved comment |
|
sdk_v2/rust/build.rs — This guard checks the shared output directory rather than what the current archive extracted. When… View resolved comment |
Suppressed comments (1)
sdk_v2/rust/build.rs:361
- A package can stage more than its sentinel file (the Runtime package optionally includes
Microsoft.Windows.AI.MachineLearning.dll), but upgrading it removes onlyexpected_file. If the newer package omits or renames a companion, the old executable remains in the shared output directory; on Windowspreload_dependencieswill still load that stale WinML DLL. Track the files staged by each package/version and remove the previous package's full file set before copying the replacement (the HTTP path needs the same cleanup).
build_support::invalidate_package(out_dir, &pkg.expected_file)?;
for file in files {
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
sdk_v2/rust/build.rs — The cache markers survive the higher-priority local-binary path. For example, after a NuGet build… |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
sdk_v2/rust/build.rs — Each feed attempt still extracts every matching native library directly into the shared output… View resolved comment |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
sdk_v2/rust/build.rs — The cache markers survive the higher-priority local-binary path. For example, after a NuGet build… View resolved comment |
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
sdk_v2/rust/build.rs:563
- The configured
NuGet.Configitself is not registered as a Cargo input. If a restore fails and the user fixes that file (for example, updates a mirror or credentials) without changing the environment variable, Cargo considers this successful build script fresh and does not retry acquisition. Emitcargo:rerun-if-changedforconfig.config_fileafter parsing it.
let config = build_support::read_config()
.unwrap_or_else(|error| panic!("invalid NuGet configuration: {error}"));
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Scott McKay (@skottmckay) Baiju Meswani (@baijumeswani), could one of you please review this? It updates Rust NuGet acquisition and aligns it with the configurable/authenticated feed support from #945. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
Logan Rosen (@loganrosen) could you merge main into your branch and push again? A recent fix in main is needed to get the pipelines green. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Baiju Meswani (@baijumeswani) Done. Merged |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
a1fc3c3
into
microsoft:main

Why
The Rust SDK build script downloaded native packages directly from hard-coded public NuGet feeds. That prevented developers behind authenticated feeds, mirrors, or enterprise proxies from using their existing
NuGet.Configand credential-provider setup.What changed
This PR brings Rust native-package acquisition in line with the JavaScript SDK while keeping direct HTTPS downloads as the default.
httpdotnetdotnet restore, honoringNuGet.Configand standard authentication.nugetNuGet.Configand standard authentication.The build script now supports feed, config-file, and executable overrides; redacts sensitive URLs; prevents HTTPS downgrade redirects; and preserves the existing warning-plus-runtime-fallback behavior when acquisition fails. Native packages are staged through isolated temporary directories, and version/source transitions invalidate stale cache state before reuse. Cargo also watches the configured
NuGet.Config, so editing a failed feed or credential configuration triggers another acquisition attempt.Validation
dotnetandnugetrestores through the machine proxy-only NuGet configurationFollow-up
#1050 tracks independent SHA-512 pins for additional HTTP-mode package-integrity hardening.
Closes #1033