Windows App Certification Kit: DPI-Awareness Validation


Recently, I was working on a new app to publish in the Windows Store (Lua Automation IDE) and I received the following error despite having per monitor DPI specified in the app.manifest file (as a side note, publishing traditional desktop apps to Microsoft is finally very easy).

DPIAwarenessValidation
Warning: The DPI-awareness validation test detected following Warnings:
File LuaAutomation.IDE\LuaAutomation.IDE.exe neither has PerMonitorV2 manifested in the manifest nor calls into DPI Awareness APIs for ex: user32!SetProcessDpiAwarenessContext or user32!SetThreadDpiAwarenessContext.
The app 9b392703-f2cd-4226-9aae-b2a827f6eff3_2022.7.1.0_neutral__622pp7g9gfywj is not DPI Aware.
Impact if not fixed: Apps that are not DPI-aware but are running on a high-DPI display setting can exhibit incorrect scaling of UI elements, clipped text, and blurry images.
How to fix: It is recommended that you declare your app as DPI-aware in the app manifest. Otherwise, app should use DPI Awareness API calls for example:either SetProcessDpiAwarenessContext or SetThreadDpiAwarenessContext APIs.
Writing High-DPI Apps

My mistake was that although I included an app.manifest in the project I did not specify it's location in the csproj file. Note the ApplicationManifest entry in the blow snippet.

csproj

<PropertyGroup>
	<OutputType>WinExe</OutputType>
	<TargetFramework>net6.0-windows</TargetFramework>
	<ApplicationManifest>app.manifest</ApplicationManifest>		
	<Nullable>enable</Nullable>
	<UseWPF>true</UseWPF>
	<RootNamespace>LuaAutomation</RootNamespace>
	<ApplicationIcon>Assets\app.ico</ApplicationIcon>
	<Version>2022.7.21.1</Version>
	<AssemblyName>LuaAutomation.IDE</AssemblyName>
</PropertyGroup>
	```
	
	For full inclusion, here is a copy of the `app.manifest` file I'm using (this is a WPF app targeting .NET Core that will be published to the Microsoft Store).
	
	``` xml
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
	<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
	<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
		<security>
			<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
				<requestedExecutionLevel level="asInvoker" uiAccess="false" />
			</requestedPrivileges>
		</security>
	</trustInfo>

	<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
		<application>
			<!-- Windows 10 and 11 -->
			<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

		</application>
	</compatibility>

	<application xmlns="urn:schemas-microsoft-com:asm.v3">
		<windowsSettings>
			<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
			<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
			<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
		</windowsSettings>
	</application>

</assembly>	
	```