简体   繁体   English

没有NuGet的NuGet软件包还原同意

[英]NuGet package restore consent without NuGet

We recently added a few dependencies to our project using NuGet. 我们最近使用NuGet在我们的项目中添加了一些依赖项。 To keep the binaries out of the version control system, I enabled the package restore feature and added the resulting .nuget folder to the repository. 为了使二进制文件不受版本控制系统的影响,我启用了软件包还原功能,并将生成的.nuget文件夹添加到存储库中。 Also the project with the dependencies got the RestorePackages option set to true , and an Import -tag for the nuget.targets within the .nuget folder. 同样,具有依赖项的项目将RestorePackages选项设置为true ,并在.nuget文件夹nuget.targets设置为Import -tag。

So that all works well on my machine with NuGet installed and the package restore feature enabled in my VS settings. 这样,在安装了NuGet并在VS设置中启用了程序包还原功能的计算机上,所有程序都可以正常运行。 However when I want to use this setup to install the dependencies on other machines I run into a few problems. 但是,当我想使用此设置在其他计算机上安装依赖项时,遇到了一些问题。

I was under the impression that one advantage of including the nuget.exe would allow me to use this on machines that do not necessarily have NuGet installed. 我的印象是,包括nuget.exe一个优点是可以让我在不一定安装NuGet的计算机上使用它。 However, after reading the article on consent I think the reason it actually fails is that those machines do not have the package restore feature enabled in their settings – obviously as they technically do not even know about NuGet. 但是,在阅读了有关同意书文章后,我认为它实际上失败的原因是那些机器未在其设置中启用软件包还原功能-显然,因为它们在技术上甚至都不了解NuGet。

What is the preferred way to enable package restore on machines that do not have NuGet installed? 在未安装NuGet的计算机上启用软件包还原的首选方法是什么? Is not having NuGet installed actually a valid option other than for build servers? 除了构建服务器以外,没有安装NuGet实际上不是有效选项吗?

Or ideally, is there a way to enable package restore by default from the solution if NuGet isn't installed itself and as such the setting could not be set by the user? 还是理想情况下,如果未自行安装NuGet且用户无法设置此设置,是否有办法默认从解决方案中启用程序包还原? (I actually could think of a setup-script that creates a NuGet.Config to %AppData&\\NuGet ) (我实际上可以想到一个安装脚本,该脚本将创建一个NuGet.Config%AppData&\\NuGet

Try this: 尝试这个:

Install-Package NuGetEnablePackageRestore

Or check the contents of the package (unzip it), you'll find some interesting stuff there that will help you out (eg there's a way to set an environment variable from within MSBuild). 或检查的内容(将其解压缩),您会在其中找到一些有趣的东西(例如,可以通过MSBuild设置环境变量)。 You can download the package within the browser after logging into NuGet. 登录NuGet后,可以在浏览器中下载软件包。

"Or ideally, is there a way to enable package restore by default from the solution if NuGet isn't installed itself and as such the setting could not be set by the user?" “或者理想情况下,如果未自行安装NuGet且因此用户无法设置此设置,是否有办法默认从解决方案中启用软件包还原?”

The alternative to install NuGet and enabling consent through the Settings is to set the following environment variable : 安装NuGet并通过“设置”启用同意的另一种方法是设置以下环境变量:

set EnableNuGetPackageRestore=true

If EnableNuGetPackageRestore (mentioned by Alexandre Dion) variable used as emmited Property for Msbuild script (I strongly suspect it work this way, but cant check right now) - you can tune up your projects or sln to set this additional property to true. 如果EnableNuGetPackageRestore(由Alexandre Dion提到)变量用作Msbuild脚本的模仿属性(我强烈怀疑它可以这种方式工作,但现在不能检查)-您可以调整项目或sln将此附加属性设置为true。

Anyway, according to this you should have at least nuget.exe as console manager for each dev. 无论如何, 根据此 ,每个开发人员至少应具有nuget.exe作为控制台管理器。 Otherwise you cant fetch referenced nuget packages. 否则,您将无法获取引用的nuget包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM