如何设置.net Core的脱机开发 [英] How do you set up for offline development with .net Core

查看:80
本文介绍了如何设置.net Core的脱机开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在一切都基于nuget包了,您如何进行离线开发?

Now that everything is based off of nuget packages, how do you do offline development?

先运行dotnet new然后再运行dotnet restore有时会使用缓存的程序包,有时会失败,因为它无法联系nuget服务器.

Running dotnet new and then dotnet restore sometimes uses cached packages, and sometimes fails because it can not contact the nuget server.

推荐答案

根据 yishaigalatzer (根据他的Github个人资料适用于雷德蒙德"中的微软"):这是设计使然.请不要添加逻辑来解决此问题." (作为此问题报告讨论的一部分: https://github.com/NuGet/Home/issues/2623 )

According to yishaigalatzer (who, according to his Github profile works for "Microsoft" in "Redmond"): "This is by design. Please don't add logic to work around it." (as part of this issue report discussion: https://github.com/NuGet/Home/issues/2623)

所以..

以下是一些我们可以解决它的方法.所有这些都是为了阻止"dotnet"尝试连接到服务器,并且仅使用本地软件包目录:

Here are some ways we can then work around it. All of these are intended to stop "dotnet" from trying to connect to the server, and to use the local package directory only:

(1)在项目中添加一个NuGet.config文件(与project.json在同一目录中),该文件将从源中删除联机存储库.使用以下内容:

(1) Add a NuGet.config file as part of your project (in the same directory with project.json) that removes the online repository from the sources. Use the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <clear />
    </packageSources>
</configuration>

(2)使用不包含源的自定义NuGet配置(例如"MyCustomNuGet.config"):

(2) Use a custom NuGet configuration (eg. "MyCustomNuGet.config") that includes no sources:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>

然后,当您运行"dotnet restore"时,显式指定使用您的自定义配置文件:

Then when you run "dotnet restore", explicitly specify to use your custom configuration file:

dotnet restore --configfile MyCustomNuGet.config

(3)运行"dotnet restore"时,显式指定本地软件包目录作为源:

(3) When running "dotnet restore", explicitly specify the local package directory as the source:

dotnet restore -s $HOME/.nuget

(或.nuget目录所在的任何位置)

(or wherever the .nuget directory may be)

这篇关于如何设置.net Core的脱机开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆