作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢!


编译参数如下:

build_release:
	docker run -it --rm  \
	--platform linux/amd64 \
	-m 2048m \
	-v "./":/src/ \
	-w /src/server/csharp_backend/ \
	ahfuzhang/csharp-dbg-all-in-one:dotnet10 \
        bash -lc -x ' \
            dotnet restore csharp_backend.csproj -r linux-x64 && \
            dotnet clean csharp_backend.csproj -r linux-x64 -c Release && \
            dotnet publish csharp_backend.csproj \
            -r linux-x64 \
            -p:DefineConstants=UNIX \
            -p:AllowUnsafeBlocks=true \
            -p:PublishAot=true \
            -p:StripSymbols=false \
            -p:StaticLinkedRuntime=true \
            -p:StaticExecutable=true \
            -p:PositionIndependentExecutable=false \
            -p:InvariantGlobalization=true \
            -p:OptimizationPreference=Size \
            -p:CppCompilerAndLinker=clang \
            -p:EventSourceSupport=true \
            -p:PublishReadyToRun=true \
            -p:EmbedAllSources=true \
            --self-contained true \
            -c Release \
            -o /src/build/Release/linux/amd64/'

编译成独立二进制后,运行在 k8s 环境中发生 coredump.
因为容器环境中缺少调试器,暂时未找到 coredump 的原因。