如何设置.net Core的脱机开发

编程入门 行业动态 更新时间:2024-10-24 14:17:28
本文介绍了如何设置 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个人资料适用于雷德蒙德"中的微软"):这是设计使然.请不要添加逻辑来解决此问题." (作为此问题报告讨论的一部分: github/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: github/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的脱机开发

本文发布于:2023-11-07 00:51:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565106.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何设置   net   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!