Skip to content
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

Please provide capability in Nuget CLI to add packages into projects #12204

Closed
gh-andre opened this issue Oct 29, 2022 · 4 comments
Closed

Please provide capability in Nuget CLI to add packages into projects #12204

gh-andre opened this issue Oct 29, 2022 · 4 comments
Labels
Functionality:Install The install command in VS/nuget.exe Product:NuGet.exe NuGet.exe Resolution:ByDesign This issue appears to be ByDesign Style:Packages.Config Type:Feature

Comments

@gh-andre
Copy link

NuGet Product(s) Involved

NuGet.exe

The Elevator Pitch

nuget.exe is missing a chunk of package management functionality in that can download and unpack packages with nuget install, but it won't modify C/C++ project files, which makes it impossible to automate adding packages to generated projects, such as those generated by CMake.

Please provide a way to invoke nuget install in a way that can update .vcxproj files to propagate .props and .targets from packages into project files, including per-project configurations, such as packages.<project-name>.config.

Additional Context and Details

One use of this is to allow installing Nuget dependencies for CMake-generated projects, which lack support for C/C++ Nuget packages. With this feature, it would be possible to run these commands to resolve all project dependencies:

cmake -S . -B build -G "Visual Studio 17 2022"

nuget install package-X --project-name project-A
nuget install package-Y --project-name project-A
nuget install package-X --project-name project-B

cmake --build build --config Debug
cmake --build build --config Release

Being able to modify project files also will provide a more complete solution for package management, which now is scattered between various Nuget tools and Visual Studio UI.

@gh-andre
Copy link
Author

gh-andre commented Nov 6, 2022

I've been looking into this a bit more and there is absolutely no way to automate adding Nuget packages to projects now. If doing so with nuget.exe presents some technical challenges, maybe a simpler way via devenv commands can be implemented for the time being, until Nuget CLI is changed to add the missing functionality.

For example, this command almost works in Command Prompt, but it runs the command before the package manager console is fully set up and reports an object reference error.

devenv /NoSplash /Command "View.PackageManagerConsole Install-Package abc.vs2022 -Project xyz" xyz.sln

Can you maybe update the package manager console to run the command passed the way it is described after the console has been set up? This would allow automating installing packages using this command, followed by Exit, like this:

devenv /NoSplash /Command "View.PackageManagerConsole <nuget command>" /Command Exit solution

Anything, really, would be great because there is no way to automate installing Nuget projects today, which is probably the only package manager there is with this shortcoming. I would use patching, but .vcxproj files may contain absolute paths, such as those generated by CMake and they are not patchable.

@nkolev92
Copy link
Member

nkolev92 commented Nov 7, 2022

Package Installation for packages.config projects involved calling components in Visual Studio that simply not available in NuGet.exe.

NuGet.exe will never have enough information to make the Visual Studio and NuGet.exe instllations be equivalent. Furthermore, installation scripts are not supported on the commandline (packages.config projects) while they are in Visual Studio.

As such, this is not something we want to be adding to NuGet.exe at this point.

@nkolev92 nkolev92 closed this as completed Nov 7, 2022
@nkolev92 nkolev92 added the Resolution:ByDesign This issue appears to be ByDesign label Nov 7, 2022
@gh-andre
Copy link
Author

gh-andre commented Nov 7, 2022

That's hugely disappointing. This would allow CMake to implement much better packager than what they do today, which to scan folders like C:\Program Files\<package>, etc.

I hope you would reconsider this. It doesn't have to be nuget.exe - whatever the current package console is using will be just as good, even if it has to invoke devenv.exe or using something similar - there is a real need out there to be able to automate package installation similar to how one would do with dnf install and apt install.

I will also note that if there was some existing way to accomplish the requirement of installing packages automatically and I asked for an alternative way, that original way could be considered as a resolution By Design. In this case, there is no way to install packages automatically, so the resolution is more like Won't Fix.

@janwilmans
Copy link

@nkolev92 how is this closed as 'completed' ? There is no fix at all, this is a huge problem for cmake users using the Nuget package system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Install The install command in VS/nuget.exe Product:NuGet.exe NuGet.exe Resolution:ByDesign This issue appears to be ByDesign Style:Packages.Config Type:Feature
Projects
None yet
Development

No branches or pull requests

4 participants