Skip to content

Publish Cargo outputs through MSBuild - #676

Open
David Federman (dfederm) wants to merge 2 commits into
mainfrom
dfederm/fix-msbuild-cargo-artifacts-output-layout
Open

Publish Cargo outputs through MSBuild#676
David Federman (dfederm) wants to merge 2 commits into
mainfrom
dfederm/fix-msbuild-cargo-artifacts-output-layout

Conversation

@dfederm

@dfederm David Federman (dfederm) commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

This updates the Cargo SDK so generated primary outputs are published through the evaluated MSBuild OutputPath instead of staying only in Cargo’s target tree. That lets dependent projects consume Rust-produced artifacts through normal MSBuild project-reference contracts while keeping Cargo intermediates out of the public output directory.

The SDK still honors CargoOutputDir overrides and ordinary local Cargo builds. The new contract also supports explicit output declarations and automatic discovery for the common cases the SDK can safely publish.

Why this is safe

  • Cargo’s full target/intermediate tree still stays under the Cargo output directory; only selected primary outputs are staged for MSBuild consumption.
  • Explicit output items override discovery, so unusual or renamed outputs can be declared without changing the default behavior.
  • The publication point is integrated so outputs exist before project completion and are visible to downstream project-reference consumers.
  • Package/native consumer behavior was verified, including a real VC++ project-reference scenario using a staged import library.

Validation

Test / build Result
src/Cargo/Microsoft.Build.Cargo.csproj Release build pass
Cargo unit test matrix 280/280 passed
Packaged fake-Cargo integration pass
Real VC++ project-reference consumer pass
High-volume stream + process-tree timeout coverage pass
Incremental + clean validation pass

Out of scope

  • This does not move the full Cargo target tree into OutputPath.
  • This does not change downstream sample/workaround projects beyond the SDK contract itself.

@dfederm
David Federman (dfederm) enabled auto-merge (squash) August 11, 2026 00:03
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.

1 participant