我有一些c#书中的。nupkg文件。我如何安装它们?
当前回答
在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的目录。第二个开关将禁用所有其他源,例如,这适用于脱机场景。
其他回答
您还可以使用包管理器控制台并通过在-Source参数中指定包含包文件的目录的路径来调用安装包cmdlet:
Install-Package SomePackage -Source C:\PathToThePackageDir\
菜单工具→选项→包管理器
给出名称和文件夹位置。单击OK。将您的NuGet包文件放在该文件夹中。
转到解决方案资源管理器中的项目,右键单击并选择“管理NuGet包”。选择新的包源。
这里是文档。
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进行安装
使用以下3个选项之一打包你的库:
Visual Studio (csproj >属性>包>勾选“生成NuGet包构建”。然后构建解决方案) dotnet命令行(在项目文件夹的命令提示符中:dotnet build,然后dotnet pack命令) NuGet命令行(在项目文件夹的命令提示符中:dotnet build,然后NuGet pack命令)
添加生成的包(在项目文件夹bin >调试(或发布)> *。使用nuget add命令将nupkg文件添加到离线提要(VS2019中的默认位置是C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\) 在VS中,管理NuGet包>右上:更改包源为Microsoft Visual Studio Online Packages。
详细的说明可以在这里找到或在yt
如果你有一个.nupkg文件,只需要.dll文件,你所要做的就是将扩展名更改为.zip,然后找到lib目录。
推荐文章
- 如何为构造函数定制Visual Studio的私有字段生成快捷方式?
- 为什么Visual Studio 2015/2017/2019测试运行器没有发现我的xUnit v2测试
- Visual Studio复制项目
- 如何在iis7应用程序池中设置。net Framework 4.5版本
- 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