.Net Core 下载:
https://dotnet.microsoft.com/download/dotnet-core
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
选择: RHEL 6 x64 版本
mkdir -p "$HOME/dotnet" && tar zxf dotnet-runtime-3.1.8-rhel.6-x64.tar.gz -C "$HOME/dotnet"
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
环境变量加入.bashrc
和.bash_profile
文件末尾
安装依赖:yum install -y krb5-libs libicu openssl-libs
运行测试项目:
dotnet ./ConsoleApp1.dll
Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
at System.Globalization.GlobalizationMode..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.String.ToLowerInvariant()
at System.Text.EncodingHelper.GetCharset()
at System.Text.EncodingHelper.GetEncodingFromCharset()
at System.ConsolePal.GetConsoleEncoding()
at System.Console+<>c.<get_OutputEncoding>b__19_0()
at System.Threading.LazyInitializer.EnsureInitializedCore[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef, System.Object ByRef, System.Func`1<System.__Canon>)
at System.Threading.LazyInitializer.EnsureInitialized[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef, System.Object ByRef, System.Func`1<System.__Canon>)
at System.Console.get_OutputEncoding()
at System.Console.CreateOutputWriter(System.IO.Stream)
at System.Console+<>c.<get_Out>b__26_0()
at System.Threading.LazyInitializer.EnsureInitializedCore[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef, System.Object ByRef, System.Func`1<System.__Canon>)
at System.Threading.LazyInitializer.EnsureInitialized[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef, System.Object ByRef, System.Func`1<System.__Canon>)
at System.Console.get_Out()
at System.Console.WriteLine(System.String)
at ConsoleApp1.Program.Main(System.String[])
ICU报错解决方案:
- 打开:ConsoleApp1.runtimeconfig.json
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
},
"configProperties": {
"System.Globalization.Invariant": true /*添加此设置*/
}
}
}
- 项目csproj添加以下配置
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Globalization.Invariant" Value="true" />
</ItemGroup>
发布独立版时运行出错:
[root@localhost publish]# ./ConsoleApp1
./ConsoleApp1: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./ConsoleApp1)
./ConsoleApp1: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./ConsoleApp1)
[root@localhost publish]#
[root@localhost publish]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
[root@localhost publish]# find / -name "libstdc++.so*"
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
解决方案:
升级:libstdc++.so.6 和 libc.so.6
libstdc++.so.6升级:
wget http://ftp.de.debian.org/debian/pool/main/g/gcc-4.8/libstdc++6-4.8-dbg_4.8.4-1_amd64.deb
ar -x libstdc++6-4.8-dbg_4.8.4-1_amd64.deb
yum install -y xz
xz -d data.tar.xz
tar xvf data.tar
cp usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6.0.19 /usr/lib64
rm -rf /usr/lib64/libstdc++.so.6
ln -s /usr/lib64/libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6
[root@localhost ~]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBC_2.3
GLIBC_2.2.5
GLIBC_2.14
GLIBC_2.18
GLIBC_2.17
GLIBC_2.3.2
GLIBCXX_DEBUG_MESSAGE_LENGTH
libc.so.6升级:
wget http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
tar xvf glibc-2.18.tar.gz
cd glibc-2.18
yum install gcc
mkdir build
cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make -j 4
make localedata/install-locales
make install
strings /lib64/libc.so.6 |grep GLIBC
再次运行测试项目:
[root@localhost publish]# ./ConsoleApp1
Hello World!
异常解决:
make[2]: Entering directory `/root/limit/glibc-2.18/iconv'
/usr/bin/install -c -m 644 iconv.h /usr/include/iconv.h
/usr/bin/install -c -m 644 gconv.h /usr/include/gconv.h
/usr/bin/install -c /root/limit/glibc-2.18/build/iconv/iconvconfig /usr/sbin/iconvconfig.new
/usr/bin/install: cannot create regular file `/usr/sbin/iconvconfig.new': Permission denied
make[2]: *** [/usr/sbin/iconvconfig] Error 1
make[2]: Leaving directory `/root/limit/glibc-2.18/iconv'
make[1]: *** [iconv/subdir_install] Error 2
make[1]: Leaving directory `/root/limit/glibc-2.18'
make: *** [install] 错误 2
[root@JingCuiPBX build]# ll /usr/sbin/iconvconfig.new
ls: 无法访问/usr/sbin/iconvconfig.new: 没有那个文件或目录
是因为 /usr/sbin
被锁定,无法修改
解决办法:
允许修改即可,命令如下:
chattr -i /usr/sbin
如果你想一些特别的文件不能随意修改的话,可以执行如下命令:
chattr +i /usr/sbin
- 分类: dotnet linux
- 标签: .Net Core 3.1