.NET AOT Parameters

2022年10月8日 64点热度 2人点赞 0条评论
内容目录

Project publish parameters:

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

file

Enable trimming:
file
file
file

Disable reflection:

<IlcDisableReflection>true</IlcDisableReflection>

file

Add NuGet package reference:

	<ItemGroup>
		<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" />
	</ItemGroup>

Other configurations:

  <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 requires .NET 7 to use.

Simple configuration:

		<!-- Publish related-->
		<PublishSingleFile>true</PublishSingleFile>
		<SelfContained>false</SelfContained>
		<RuntimeIdentifier>win-x64</RuntimeIdentifier>
		
		<!-- AOT related-->
		<TrimMode>full</TrimMode>
		<RunAOTCompilation>True</RunAOTCompilation>
		<PublishTrimmed>true</PublishTrimmed>
		<PublishAot>true</PublishAot>
		<IlcDisableReflection>true</IlcDisableReflection>

痴者工良

高级程序员劝退师

文章评论