-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for batch "Add a reference to a project file" invocation #12629
Comments
Hi @YuliiaKovalova, may I know which API you're using right now in post-action? Do you mean adding package reference or project reference? Thanks! |
Hi @heng-liu , I mean adding package reference to project file :) |
@YuliiaKovalova Is this ask related to a Visual Studio API such as |
I don't think so. |
If it's not VS, I'm not really sure I understand what the ask is here. I'm not really sure what Add Reference functionality on NuGet end you're referring to. In add package we use MSBuild APIs to write references, and that's it. |
This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment. |
@nkolev92 this is coming from the Template Engine, which has two hosts - the dotnet CLI, and the VS New Project Dialog. Specifically, we'd like to have some kind of batch/multi-package-add capability in the NuGet CLI so that we can make project templates more correct for a larger portion of our user base. Let me walk through the problem end to end. Currently, many project templates (MS and 3rd party) hard code PackageReference items in generated project files, but they'll often have a variable for the 'version' of that PackageReference. This is bad for a few reasons (versions getting out of date, hard to maintain) but for this conversation we mostly find it bad because hard-coding If we look at what the actual need of the template author is, they want to ensure that a generated project gets a PackageReference to a certain package with a certain version. Turns out that we already have that capability in the CLI via Which brings us to this issue. If we do this, then if a template author adds let's say 5 packages to a project that project will be evaluated at least 5 times - once for each invocation of So that's the request. It would be awesome to have an ability or syntax like |
Thanks for clarifying it @baronfel! As an immediate minor improvement you can make use of the --no-restore feature to add references multiple times so you at least avoid multiple restores. |
NuGet Product(s) Involved
NuGet SDK
The Elevator Pitch
Hi Nuget Team,
Template Engine crew sees increased demand for Cental Package Management Support:
dotnet/templating#6187
dotnet/aspnetcore#48569
Currently, it is possible to resolve the version correctly through post-action. It is a wrapper around your functionality.
As we can see, there is no support for specifying a set of project links, so users need to specify dependencies one by one in post actions (e.g. add reference).
Once you extend your API, we can utilize it for supporting batch "add reference" operations.
cc: @baronfel
The text was updated successfully, but these errors were encountered: