命令:
sudo dotnet publish -c Release
报错内容:
MSBuild version 17.4.0+18d5aef85 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
oschina2022 -> /mnt/d/GitHub/oschina2022/oschina2022/bin/Release/net7.0/linux-x64/oschina2022.dll
/usr/bin/ld: cannot find -lz
collect2 : error : ld returned 1 exit status [/mnt/d/GitHub/oschina2022/oschina2022/oschina2022.csproj]
/usr/share/dotnet/sdk/7.0.101/Sdks/Microsoft.DotNet.ILCompiler/build/Microsoft.NETCore.Native.targets(346,5): error MSB3073: The command ""gcc" "obj/Release/net7.0/linux-x64/native/oschina2022.o" -o "bin/Release/net7.0/linux-x64/native/oschina2022" /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/sdk/libbootstrapper.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/sdk/libRuntime.WorkstationGC.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Globalization.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.IO.Compression.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Net.Security.Native.a /home/maikebing/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.1/framework/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -lstdc++ -ldl -lm -lz -lrt -pie -Wl,-z,relro -Wl,-z,now -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/mnt/d/GitHub/oschina2022/oschina2022/oschina2022.csproj]
解决方法:
sudo apt-get install zlib1g-dev
标签:bin,ld,maikebing,x64,7.0,oschina2022,linux,dotnet From: https://www.cnblogs.com/MysticBoy/p/17011612.html