Background

一直想尝试在我的Debian系统上使用dotnet core,然而debian的之前的安装源被我搞得很乱,所以本机装的软件版本也是如此

之前在1.0的版本时候也是出现过 Segmentation fault的错误,

基本上查到的问题是openssl版本的问题不兼容,于是尝试卸载重新安装各自版本,然而问题依旧,

甚至萌生换系统的想法

后来在用英文搜索下终于找到可靠的方案。

按作者的表述 dotnet new 命令出现 segmention fault 的原因是 .NET Core telemetry being incompatible with version 1.1 of OpenSSL.

Telemetry

The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.

就是说微软为了提升用户体验,他们会匿名收集你的使用数据,并在社区分享之类的,当然数据是不包含命令,隐私等等。

你也可以将系统环境变量DOTNET_CLI_TELEMETRY_OPTOUT设为1或者true,这样设置就表示你不参与反馈计划了

个人理解这里匿名提交的时候要用到openssl,然而,dotnet core与debian8上面这个安装的openssl版本不兼容,(实际上我换了版本仍然不行,估计还有其他问题吧)

那看下本机上安装的openssl版本是哪个:

dpkg -s openssl | grep Version
#Version: 1.1.0e-1

之前的调查也表面,本机的这个openssl版本是不兼容.net core,

既然这样的话那我干脆退出反馈计划就好了

终端设置 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量禁止 telemetry.

export DOTNET_CLI_TELEMETRY_OPTOUT=1

至此,问题解决了,继续 .NET Core之旅

hoyho@debian:~/workspace$ export DOTNET_CLI_TELEMETRY_OPTOUT=1
hoyho@debian:~/workspace$ dotnet new console
Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/hoyho/workspace/workspace.csproj...
Restore succeeded.

hoyho@debian:~/workspace$ ls
obj  Program.cs  spreadAPI  workspace.csproj

libcurl

补充,后来发现dotnet restore后没有任何输出,报错也没有,所以问题并没完全解决,继续谷歌,发现漏的包为: libcurl3_7.38.0-4+deb8u10_amd64.deb

你也可以自己搜索下载这个包并使用:dpkg -i xxx你的包

安装完成就修复了

我下载的是这个:http://security.debian.org/debian-security/pool/updates/main/c/curl/libcurl3_7.38.0-4+deb8u10_amd64.deb

github上的issue:https://github.com/dotnet/cli/issues/4109#issuecomment-243461152