Skip to content

respect central package management when adding aspire integration to AppHost#14875

Open
Muckenbatscher wants to merge 4 commits intodotnet:release/13.2from
Muckenbatscher:add-integration-cpm
Open

respect central package management when adding aspire integration to AppHost#14875
Muckenbatscher wants to merge 4 commits intodotnet:release/13.2from
Muckenbatscher:add-integration-cpm

Conversation

@Muckenbatscher
Copy link

@Muckenbatscher Muckenbatscher commented Mar 3, 2026

Description

Previously when running aspire add [integration-name] the PackageReference element with a Version attribute would be added to the AppHost.csproj directly.
When Central Package Management is in place this will lead to a build error NU1008.

The PackageReference is added to the AppHost.csproj directly because the --no-restore flag is passed to the dotnet CLI when no source is explicitly specified for aspire add. This effectively tells the dotnet CLI to skip the validation that is required for adding the PackageVersion to the Directory.Packages.props.

So if no source is explicitly specified to the aspire add command pass the one, where the integration NuGet package was found in (for most cases this will be the nuget.org source).

Fixes #13241

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14875

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14875"

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 3, 2026
@davidfowl
Copy link
Member

@Muckenbatscher can you open ths against the release/13.2 branch?

@Muckenbatscher Muckenbatscher changed the base branch from main to release/13.2 March 3, 2026 08:50
@Muckenbatscher
Copy link
Author

@dotnet-policy-service agree

@maddymontaquila
Copy link
Member

THANK you - this is a great contrib!! @mitchdenny lets get this reviewed + merged for 13.2!

…AppHost

* pass the source of the selected package if no source is explicitly passed as argument
* so that the --no-restore flag is not appended to the dotnet CLI arguments. This flag effectively bypasses the CPM and adds the PackageReference with Version attribute directly to the AppHost.csproj instead of the Directory.Packages.props file.
instead provide an explicit parameter to toggle the restore validation performed by the dotnet CLI
@Muckenbatscher
Copy link
Author

Muckenbatscher commented Mar 4, 2026

The first approach was flawed.
Providing the --source argument made the dotnet CLI use only that source for restoring all packages.

This would fail for packages that have (transitive) dependencies on other packages that are only available in a different source.

for combining --source and --no-restore options independently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aspire cli aspire add does not support Central Package Management (13.0.0)

3 participants