2017-10-16 175 views
0

我的組織希望在沒有互聯網訪問的情況下將網絡上的所有開發機器隔離開來。在Visual Studio之外管理Nuget包

我發現this article,給出了一些nuget主機產品,以便軟件包可以離線使用。

我的問題是,我無法找到管理軟件包更新的方法,因爲擁有和訪問Internet的計算機不會安裝Visual Studio。

我一直在尋找,如果有一個工具,可讀取所有nupkg文件存儲並檢查是否有更新的版本,並將其下載,或以其他方式讀取手動創建packages.config文件檢查的文件夾較新的版本並將它們下載到一個文件夾中。

有沒有人有一個想法如何用這種方式管理nuget包?我花了上個星期試圖找到一種方式,但我沒有看。

回答

1

Does anyone have an idea how to manage nuget packages in this way?

按照NuGet CLI reference

The update command also updates assembly references in the project file, provided those references already exist.

所以,當我們使用NuGet.exe更新包,我們不僅需要packages.config也是需要的解決方案/項目,否則,您將得到錯誤:

"Unable to locate project file for 'D:\NuGetServer\packages.config'

您可以從機,它具有安裝Visual Studio複製一個簡單的項目,然後用下面的命令行中更新NuGet包文件:

nuget update "YourProjectPath\packages.config" 

不過的NuGet將更新包成默認解決方案文件夾下的文件夾的包,所以我們需要改變的包文件夾,所有nupkg文件更新包之前存儲的文件夾。

具體步驟

  1. nuget.org下載nuget.exe,將其設置爲你的本地計算機。

  2. repositoryPath路徑%appdata%下創建的NuGet文件夾中,添加NuGet.Config文件並更改程序包的文件夾,只是將它設置 「D:\NuGetServer 」:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <packageSources> 
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> 
    </packageSources> 

    <config> 
    <add key="repositoryPath" value="D:\NuGetServer" /> 
    </config> 
</configuration> 
  • 從其他機器複製解決方案,將包裝添加到包裝中。配置文件:

    <?xml version="1.0" encoding="utf-8"?> 
    <packages> 
        <package id="EntityFramework" version="6.1.0" targetFramework="net45" /> 
        <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> 
        <package id="NUnit" version="3.7.0" targetFramework="net45" /> 
    </packages> 
    
  • 打開CMD文件中,切換到的NuGet存儲在步驟1中的路徑,然後使用update命令:

  • enter image description here

    你會發現包在packages.config中更新爲最新版本。

    +0

    完美我錯過了虛擬項目的一部分。謝謝 – Raphael

    相關問題