如何在本地安裝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樓

參考:https://stackoom.com/question/gxtl/如何在本地安裝NuGet包-nupkg文件


#2樓

Menu ToolsOptionsPackage 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-Package cmdlet:

Install-Package SomePackage -Source C:\PathToThePackageDir\

#4樓

如果您有.nupkg文件並且只需要.dll文件,您只需將擴展名更改爲.zip並找到lib目錄。


#5樓

對於我喜歡使用的.nupkg文件:

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

#6樓

  1. 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)
  2. 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> 
  3. 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進行安裝

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章