Skip to main content

WinForm AOT发布

· 1分钟阅读
xkyii

环境

  • Windows 10
  • 9.0.100-preview.7.24407.12
  • Microsoft Visual Studio Community 2022 (64 位) - Current 版本 17.11.2

工程

  • 新建项目

  • 修改项目配置WinFormAot.csproj:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
<!-- 禁止裁剪和AOT冲突的报错 -->
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>

<!-- 支持winxp可以试试加上
<WindowsSupportedOSPlatformVersion>5.1</WindowsSupportedOSPlatformVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetPlatformMinVersion>5.1</TargetPlatformMinVersion>
-->
</PropertyGroup>
</Project>
  • 发布配置参考:

  • 发布