2017-10-16 176 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

    相关问题