900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 如何在本地安装NuGet包.nupkg文件?

如何在本地安装NuGet包.nupkg文件?

时间:2022-07-11 06:30:05

相关推荐

如何在本地安装NuGet包.nupkg文件?

本文翻译自:How do I install a NuGet package .nupkg file locally?

I have some .nupkg files from a C# book.我有一些来自C#书的.nupkg文件。How can I install them?我该如何安装它们?

#1楼

参考:/question/gxtl/如何在本地安装NuGet包-nupkg文件

#2楼

MenuTools→Options→Package Manager菜单工具→选项→包管理器

Give a name and folder location.提供名称和文件夹位置。Click OK.单击确定。Drop your NuGet package files in that folder.将NuGet包文件放在该文件夹中。

Go to your Project, right click and select"Manage NuGet Packages"and select your new package source.转到您的项目,右键单击并选择“管理NuGet包”并选择新的包源。

Here is the documentation .这是文档 。

#3楼

您还可以使用程序包管理器控制台并通过在-Source参数中指定包含程序包文件的目录的路径来调用Install-Packagecmdlet:

Install-Package SomePackage -Source C:\PathToThePackageDir\

#4楼

如果您有.nupkg文件并且只需要.dll文件,您只需将扩展名更改为.zip并找到lib目录。

#5楼

对于我喜欢使用的.nupkg文件:

Install-Package C:\Path\To\Some\File.nupkg

#6楼

Add the files to a folder called LocalPackages next to you solution (it doesn't have to be called that, but adjust the xml in the following step accordingly)将文件添加到解决方案旁边的名为LocalPackages的文件夹中(不必调用它,但在相应的步骤中调整xml)

Create a file called NuGet.config next to your solution file with the following contents使用以下内容在解决方案文件旁边创建一个名为NuGet.config的文件

<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="LocalPackages" value="./LocalPackages" /> </packageSources> <activePackageSource> <!-- this tells that all of them are active --> <add key="All" value="(Aggregate source)" /> </activePackageSource> </configuration>

If the solution is open in Visual Studio, close it, then re-open it.如果解决方案在Visual Studio中打开,请将其关闭,然后重新打开它。

Now your packages should appear in the browser, or be installable using Install-Package现在您的包应该出现在浏览器中,或者可以使用Install-Package进行安装

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。