Difference between revisions of ".NET Core (简体中文)"

From ArchWiki
Jump to navigation Jump to search
(遥测: Link to Environment variables.)
(Add Troubleshooting section.)
 
Line 17: Line 17:
 
== 遥测 ==
 
== 遥测 ==
  
遥测功能默认被打开,可以通过[[设置环境变量|Environment variables]] {{ic|DOTNET_CLI_TELEMETRY_OPTOUT=1}} 关闭遥测。
+
遥测功能默认被打开,可以通过[[Environment variables|设置环境变量]] {{ic|1=DOTNET_CLI_TELEMETRY_OPTOUT=1}} 关闭遥测。
 +
 
 +
== 问题解决 ==
 +
 
 +
=== "the required library libhostfxr.so could not be found" error ===
 +
 
 +
Some of the dotnet SDK tools (for example ''libman'', ''dotnet-watch'' etc.) may expect you to have the environment variable {{ic|DOTNET_ROOT}} pre-configured. If it's not, an error like this one could be observed: [https://github.com/dotnet/cli/issues/9114]
 +
 
 +
A fatal error occurred, the required library libhostfxr.so could not be found.
 +
If this is a self-contained application, that library should exist in [/home/my_user/.dotnet/tools/.store/microsoft.web.librarymanager.cli/1.0.172/microsoft.web.librarymanager.cli/1.0.172/tools/netcoreapp2.1/any/].
 +
If this is a framework-dependent application, install the runtime in the default location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location.
 +
 
 +
The workaround is to manually export {{ic|DOTNET_ROOT}} in your shell:
 +
 
 +
{{hc|1=~/.bashrc|2=
 +
export DOTNET_ROOT=/opt/dotnet
 +
}}
 +
 
 +
=== 无法找到指定的 SDK ===
 +
 
 +
Mono 和 Dotnet 的 MSBuild SDK 库冲突了,请在 shell 中手动设置路径,将示例中的版本号替换为实际安装的版本:
 +
 
 +
{{hc|1=~/.bashrc|2=
 +
export MSBuildSDKsPath="/opt/dotnet/sdk/2.2.105/Sdks/";
 +
}}
  
 
== 参阅 ==
 
== 参阅 ==

Latest revision as of 03:35, 15 July 2019

翻译状态: 本文是英文页面 .NET Core翻译,最后翻译时间:2019-04-24,点击这里可以查看翻译后英文页面的改动。

.NET Core 是 Microsoft 开发的开源软件框架,支持 C#, Visual Basic 和 F#。和之前的 .NET Framework 相比,它支持跨平台开发,设计上更加模块化,面向现代程序开发。

安装

如果要运行 .NET Core 管理的程序,请安装 dotnet-runtime

要使用 .NET Core 编写程序,还需要安装 dotnet-sdk

微软推荐使用 Visual Studio Code 编译和调试 .NET Core 程序,它是微软开发的基于 Electron 的开源 IDE。

遥测

遥测功能默认被打开,可以通过设置环境变量 DOTNET_CLI_TELEMETRY_OPTOUT=1 关闭遥测。

问题解决

"the required library libhostfxr.so could not be found" error

Some of the dotnet SDK tools (for example libman, dotnet-watch etc.) may expect you to have the environment variable DOTNET_ROOT pre-configured. If it's not, an error like this one could be observed: [1]

A fatal error occurred, the required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/home/my_user/.dotnet/tools/.store/microsoft.web.librarymanager.cli/1.0.172/microsoft.web.librarymanager.cli/1.0.172/tools/netcoreapp2.1/any/].
If this is a framework-dependent application, install the runtime in the default location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location.

The workaround is to manually export DOTNET_ROOT in your shell:

~/.bashrc
export DOTNET_ROOT=/opt/dotnet

无法找到指定的 SDK

Mono 和 Dotnet 的 MSBuild SDK 库冲突了,请在 shell 中手动设置路径,将示例中的版本号替换为实际安装的版本:

~/.bashrc
export MSBuildSDKsPath="/opt/dotnet/sdk/2.2.105/Sdks/";

参阅