-
Notifications
You must be signed in to change notification settings - Fork 258
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
Support hardcoding a different TFM for a packagereference's resolution #7279
Comments
@moh-hassan I'm sorry but this doesn't look like something we would want to have as part of nuget. The packages are shipped as-is, we do not do any modification (even if it is in memory) of them before installing them. There is no way for nuget to implement reliably a feature like this, and there is no reason why someone should have that granular control over what to pick and what not to pick in a package. Implementing something like this would be a hack that might work in some scenarios (like yours), but it might not work in others. If you really need to have that level of control over what a package is installing on your project, you can always take a package, do your custom modifications and repack them. Then consume them from a local source or have your private copies of the packages. |
@PatoBeltran, This feature (without the details of implementation) is currently available in the third party Paket tool Update
|
@moh-hassan You can tell restore to only run with a specific framework, but that framework has to be in your project. If you are allowed to specify custom frameworks to restore certain packages against, build would be likely to fail. |
Thanks @nkolev92 for reply.
and run 'paket install' in the commandline, Paket install only net45 lib(in my issue #7263), only one package without any dependencies. Also, Paket add the following section to the project file myproject.csproj
Note the path \lib\net45\CommandLine.dll (not nestandar15 path)
Paket install all netstandard15 lib dependencies, exactly Like nuget command install-package (no more no less)
OR:
For more details , read the paket.dependencies: Framework restrictions
Sure, I mean the current project in VS IDE or with option I find nuget do this restriction and solve the problem of avoiding of installing many netstandard packages in project net46x in smart way if the empty dependency group exist in the dependencies, and the idea of adding the framework option is raised for me. Many owners of the package forget to add this empty dependency group in multi target package (if no dependencies exist) I mean, by the feature request, the restriction for framework in the command install-package (and the corresponding other commands for consistency) without the details of implementation that I provided. |
Maybe I'm not following you exactly, but here's what I understand. In number 1 you say:
I don't see any difference from before. For net461, NuGet just selects the closest matching framework. The choose statement is required because paket writes to csproj. Regarding number 2: Regarding 3.
I wouldn't call it a restriction. https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets |
Really, Paket find net45 is the closest framework for net461, because i provided a restriction , but nuget find netstandard15 is the closest one. That is the point.
I use the sdk format of csproj in vs 2017 update 3 that target net461, with the properties:
I try to use the PackageReference format with condition, but in vain. May be, I missed something. see in demo project with the new SDK style : |
Sounds to me this is a request for a way to do something like this: Renamed this title to:
In case we don't provide a more elegant way in the future, see this blog post for a hard coded way to do it: Related twitter thread: (has some interesting discussion too) |
Thanks @rrelyea for reply. Good news that the feature will be available in vs 2019
|
Closing as duplicate of #7416 |
Introduction:
I have faced a problem of installing many packages (not needed) in a project net461 as described in this issue #7263 ,Why nuget install many dll dependenices in FFW 4.6.1
I was adviced by @PatoBeltran
I followed his advice by adding an empty group for net45,as the following line:
The details of the solution: #7263 (comment)
and this line resolved the problem.
This requires that the owners of most of the packages should modify .nuspec file and add the previous line.
The Feature Request:
It's nice if you can add to the PowerShell command Install-package command
a parameter named Framework, something like:
And user can define his Nearest Framework ,e.g, net45
The advantage:
The Framework option imply that the nuget install-command when reading the dependency from nuspec file included in the package, add the empty dependency group line:
to dependencies and consequently install net45 lib not netstandard package (which is currently auto selected by nuget for frameork net46x)
For example: the following dependency in nuspec file:
by running the command:
install-package mypacke -Framework net45
The dependencies will become in memory:
This avoid the modification of nuspec file of many packages need to be modified by the owner of the package to add this empty group and avoid installs superfluous dependencies of netstandard as the the Nearest Framework.
The great benefit is enabling the developer immediately to select his nearest package and avoid the installation of netstandard dependncies for framework net461,462,471,..
The same is applied for update-package (may be other commands for consistency)
The text was updated successfully, but these errors were encountered: