dotnet / dotnet/winforms

`PublishAot` deployment ignores call to `Application.SetHighDpiMode`

Open
#11,543 9 comments 0 reactions 0 assignees View on GitHub
area-HDPI area-ILLinker/AOT
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

.NET SDK:
Version: 9.0.100-preview.5.24307.3
Commit: 35b2c21ea6
Workload version: 9.0.100-manifests.6407b7e4
MSBuild version: 17.11.0-preview-24279-02+b963c24ef

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64

Microsoft.WindowsDesktop.App 9.0.0-preview.5.24306.8

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

_No response_

### Issue description

`dotnet publish`
![image](https://github.com/dotnet/winforms/assets/10534634/2d8d9032-eb2b-4458-afc5-bd0f9ffc5858)
`dotnet run` or publish with `` in manifest
![image](https://github.com/dotnet/winforms/assets/10534634/344f7230-19f3-4572-904c-83b9ee246d9d)
but specifying dpi awareness in manifest results in warning `CSC : warning WFAC010: Remove high DPI settings from C:\Source\ttt\app.manifest and configure via Application.SetHighDpiMode API or 'ApplicationHighDpiMode' project property`
Display settings
![image](https://github.com/dotnet/winforms/assets/10534634/2a3c0852-c592-4f8f-b6d6-ccc2c59d837f)

### Steps to reproduce

`mkdir ttt && cd ttt && dotnet new winforms`
Form1.cs
```cs
namespace ttt;

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

var cb = new CheckBox();

cb.Location = new Point(3, 73);
cb.Size = new Size(152, 29);
cb.Text = "Always on top";
cb.UseVisualStyleBackColor = true;

Controls.Add(cb);
}
}
```
ttt.csproj
```csproj


WinExe
net9.0-windows
enable
true
enable


true
<_SuppressWinFormsTrimError>true

```
app.manifest
```xml









true


```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.