我有一些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进行安装

其他回答

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

Install-Package SomePackage -Source C:\PathToThePackageDir\

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包,这将是空的:

最近我想安装松鼠。windows,我尝试安装包松鼠。windows -版本2.0.1从https://www.nuget.org/packages/squirrel.windows/,但它失败了一些错误。所以我下载了squirrel.windows.2.0.1。nupkg并保存在D:\Downloads\,然后我可以通过install - package squirrel成功安装它。windows -verbose -Source D:\Downloads\ -Scope CurrentUser -SkipDependencies

使用以下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