内容目录
项目发布参数:
dotnet publish -c Release -r win-x64 -p:PublishProfile=FolderProfile --no-self-contained
dotnet publish -c Release -r win-x64 -p:PublishProfile=FolderProfile -p:PublishReadyToRun=true -p:PublishTrimmed=true --self-contained false
开启裁剪:
关闭反射:
<IlcDisableReflection>true</IlcDisableReflection>
添加 Nuget 包引用:
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" />
</ItemGroup>
其它配置:
<TrimMode>full</TrimMode>
<RunAOTCompilation>True</RunAOTCompilation>
<PublishTrimmed>true</PublishTrimmed>
<PublishAot>true</PublishAot>
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
<PublishReadyToRunEmitSymbols>false</PublishReadyToRunEmitSymbols>
<DebuggerSupport>false</DebuggerSupport>
<EnableUnsafeUTF7Encoding>true</EnableUnsafeUTF7Encoding>
<InvariantGlobalization>true</InvariantGlobalization>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<MetadataUpdaterSupport>true</MetadataUpdaterSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<IlcDisableReflection >true</IlcDisableReflection>
PublishAot 需要在 .NET 7 下使用。
简单的配置:
<!-- 发布相关-->
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<!-- AOT 相关-->
<TrimMode>full</TrimMode>
<RunAOTCompilation>True</RunAOTCompilation>
<PublishTrimmed>true</PublishTrimmed>
<PublishAot>true</PublishAot>
<IlcDisableReflection>true</IlcDisableReflection>
文章评论