I'm trying to figure out a) if I'm going about this in the right way and b) how to update a solution level nuget package.
我想弄清楚a)我是否以正确的方式解决这个问题,以及b)如何更新解决方案级别的nuget包。
The core problem is that when a package is installed at the solution level (rather than in any particular project) and you try to update it, it doesn't remove the old reference. It just adds a new package reference, and imports both version. Which typically means (what with how powershell modules work) that the earlier powershell modules override the newer ones.
核心问题是,当在解决方案级别(而不是在任何特定项目中)安装软件包并且您尝试更新它时,它不会删除旧的引用。它只是添加了一个新的包引用,并导入了两个版本。这通常意味着(powershell模块如何工作)早期的PowerShell模块覆盖了新的模块。
So what I have to do is uninstall the package and re-install it, which grabs the newer version. Seems inefficient.
所以我要做的就是卸载软件包并重新安装它,它抓住了新版本。似乎效率低下。
Also, I can't seem to install or uninstall a solution level package from console. I have to do it with the Manage Nuget Packages utility, which I hate to use.
此外,我似乎无法从控制台安装或卸载解决方案级别的包。我必须使用Manage Nuget Packages实用程序,我讨厌使用它。
Here is some background on what I'm doing, if it helps:
以下是我正在做的事情的一些背景,如果它有帮助:
I've set up a system at our company of using solution level nuget packages to add custom powershell script modules to the solution, as well as some more generalized scripted solutions I've written (like deleting TFS work items or changing a project name on the file system as well as within code).
我在我们公司建立了一个使用解决方案级别nuget包来为解决方案添加自定义PowerShell脚本模块的系统,以及我编写的一些更通用的脚本解决方案(比如删除TFS工作项或更改项目名称)文件系统以及代码内)。
So one project might have the DataServiceUtilities package and another would have the FrontEndUtilities package.
因此,一个项目可能具有DataServiceUtilities包,另一个项目可能具有FrontEndUtilities包。
So, how can I update these packages without it adding two references? And can solution level operations be done in the Package Manager Console, which always defaults to targeting a project?
那么,如何在不添加两个引用的情况下更新这些包呢?并且可以在Package Manager控制台中完成解决方案级操作,该控制台始终默认为定位项目吗?
1 个解决方案
#1
3
It appears that some of this comes from bugs in the Package Manager GUI tools, and Nuget in general
似乎其中一些来自Package Manager GUI工具中的错误,以及Nuget
The Package Manager GUI tool doesn't handle updates properly for solution level packages. But if you run Update-Package from the package manager console it will correctly uninstall/re-install the solution-level package.
Package Manager GUI工具无法正确处理解决方案级别包的更新。但是,如果从包管理器控制台运行Update-Package,它将正确卸载/重新安装解决方案级别的包。
As for installing from command line, if a package has only a tools folder and no dependencies you can run install from command line and it sill install in the solution and ignore the default project.
至于从命令行安装,如果一个包只有一个工具文件夹而没有依赖项,你可以从命令行运行install,它会在解决方案中安装并忽略默认项目。
However, as of now (Nuget 2.8) Nuget has a bug in it that causes it to treat solution-level packages with dependencies on other solution-level packages as project-level packages. It's apparently been in for about a year, and they claim it will be fixed in VS 2015. You can see the bug here: https://nuget.codeplex.com/workitem/3642
但是,截至目前(Nuget 2.8),Nuget在其中有一个错误,导致它将依赖于其他解决方案级别包的解决方案级别包作为项目级包处理。它显然已经存在了大约一年,他们声称它将在VS 2015中修复。你可以在这里看到错误:https://nuget.codeplex.com/workitem/3642
What this means is you cannot currently create a solution-level package with ANY dependencies. Please note that this is legal according to the documentation. Hopefully it will be fixed next year.
这意味着您目前无法创建具有任何依赖项的解决方案级别包。请注意,根据文档,这是合法的。希望它能在明年修复。
*Update
*更新
Just a quick update. It appears that in VS 2015 they have deprecated (or, more accurately, removed) solution level/tools only packages. After some out outcry they also decided to re-implement them in a future version, but it may be awhile before they do so.
只是一个快速更新。看起来在VS 2015中,他们已经弃用(或者更准确地说,已删除)仅限解决方案级别/工具的软件包。在发出强烈*之后,他们还决定在未来版本中重新实施它们,但它们可能需要一段时间才能实现。
Progress on re-implementing the feature can be found here: https://github.com/NuGet/Home/issues/1521
可以在此处找到重新实现该功能的进展:https://github.com/NuGet/Home/issues/1521
Discussion on how to work around the missing feature can be found here: https://github.com/NuGet/Home/issues/522
有关如何解决缺失功能的讨论,请访问:https://github.com/NuGet/Home/issues/522
#1
3
It appears that some of this comes from bugs in the Package Manager GUI tools, and Nuget in general
似乎其中一些来自Package Manager GUI工具中的错误,以及Nuget
The Package Manager GUI tool doesn't handle updates properly for solution level packages. But if you run Update-Package from the package manager console it will correctly uninstall/re-install the solution-level package.
Package Manager GUI工具无法正确处理解决方案级别包的更新。但是,如果从包管理器控制台运行Update-Package,它将正确卸载/重新安装解决方案级别的包。
As for installing from command line, if a package has only a tools folder and no dependencies you can run install from command line and it sill install in the solution and ignore the default project.
至于从命令行安装,如果一个包只有一个工具文件夹而没有依赖项,你可以从命令行运行install,它会在解决方案中安装并忽略默认项目。
However, as of now (Nuget 2.8) Nuget has a bug in it that causes it to treat solution-level packages with dependencies on other solution-level packages as project-level packages. It's apparently been in for about a year, and they claim it will be fixed in VS 2015. You can see the bug here: https://nuget.codeplex.com/workitem/3642
但是,截至目前(Nuget 2.8),Nuget在其中有一个错误,导致它将依赖于其他解决方案级别包的解决方案级别包作为项目级包处理。它显然已经存在了大约一年,他们声称它将在VS 2015中修复。你可以在这里看到错误:https://nuget.codeplex.com/workitem/3642
What this means is you cannot currently create a solution-level package with ANY dependencies. Please note that this is legal according to the documentation. Hopefully it will be fixed next year.
这意味着您目前无法创建具有任何依赖项的解决方案级别包。请注意,根据文档,这是合法的。希望它能在明年修复。
*Update
*更新
Just a quick update. It appears that in VS 2015 they have deprecated (or, more accurately, removed) solution level/tools only packages. After some out outcry they also decided to re-implement them in a future version, but it may be awhile before they do so.
只是一个快速更新。看起来在VS 2015中,他们已经弃用(或者更准确地说,已删除)仅限解决方案级别/工具的软件包。在发出强烈*之后,他们还决定在未来版本中重新实施它们,但它们可能需要一段时间才能实现。
Progress on re-implementing the feature can be found here: https://github.com/NuGet/Home/issues/1521
可以在此处找到重新实现该功能的进展:https://github.com/NuGet/Home/issues/1521
Discussion on how to work around the missing feature can be found here: https://github.com/NuGet/Home/issues/522
有关如何解决缺失功能的讨论,请访问:https://github.com/NuGet/Home/issues/522