.NET Core (简体中文) - ArchWiki

# .NET Core (简体中文)

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
翻译状态：本文是 .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/";

## 参阅

- .NET Core homepage
- The .NET Foundation
- .NET API Browser

Category:

- Frameworks (简体中文)