我有一些c#书中的。nupkg文件。我如何安装它们?
当前回答
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) Create a file called NuGet.config next to your solution file with the following contents <?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.
现在您的包应该出现在浏览器中,或者可以使用Install-Package进行安装
其他回答
只是给一个更新,Visual Studio 2015用户有一些小的变化。
手动使用或安装包,请进入“工具->选项-> NuGet包管理器->包源”
点击“添加”按钮,选择“源”,不要忘记点击“更新”,因为它会更新你的包的文件夹位置,如果你想编辑你想要的包源名称:
要选择添加的包,请右键单击解决方案并选择“管理Nuget包”
右边是下拉列表,然后选择“浏览”以浏览您在文件夹源上指定的包。如果该文件夹源上没有nuget包,这将是空的:
您还可以使用包管理器控制台并通过在-Source参数中指定包含包文件的目录的路径来调用安装包cmdlet:
Install-Package SomePackage -Source C:\PathToThePackageDir\
在Linux上,使用NuGet CLI,命令是类似的。安装我的。nupkg,跑
nuget add -Source some/directory my.nupkg
然后在该目录下运行dotnet restore
dotnet restore --source some/directory Project.sln
或者将该目录添加为NuGet源
nuget sources Add -Name MySource -Source some/directory
然后告诉msbuild使用/p:RestoreAdditionalSources=MySource或/p: restoreresources =MySource的目录。第二个开关将禁用所有其他源,例如,这适用于脱机场景。
菜单工具→选项→包管理器
给出名称和文件夹位置。单击OK。将您的NuGet包文件放在该文件夹中。
转到解决方案资源管理器中的项目,右键单击并选择“管理NuGet包”。选择新的包源。
这里是文档。
如果你有一个.nupkg文件,只需要.dll文件,你所要做的就是将扩展名更改为.zip,然后找到lib目录。
推荐文章
- Visual Studio - Resx文件默认“内部”为“公共”
- 在Visual Studio 2010中有快速查找文件的方法吗?
- Nuget连接尝试失败“无法为源加载服务索引”
- 在Visual Studio中查看多个项目/解决方案
- Visual Studio打开默认浏览器,而不是Internet Explorer
- csproj文件中的“Service Include”是干什么用的?
- 如何在Visual Studio中找到堆栈跟踪?
- 使用不同的Web。在开发和生产环境中进行配置
- 是否有一种方法可以在Visual Studio中删除一行而不剪切它?
- Microsoft Visual Studio的推荐插件
- Visual Studio: ContextSwitchDeadlock
- Visual Studio:如何打破处理异常?
- VS 2017 Git本地提交数据库。每次提交时锁定错误
- 无法启动IIS Express Web服务器,注册URL失败,访问被拒绝
- 如何下载Visual Studio社区版2015(不是2017)