You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When both WindowsAppSDKSelfContained and code analysis are turned on for a WinUI 3 project, it fails to build due to CA5392: Use DefaultDllImportSearchPaths attribute for P/Invokes in Microsoft.Windows.Foundation.UndockedRegFreeWinRTCS.WindowsAppRuntime_EnsureIsLoaded.
Steps to reproduce the bug
Create a WinUI 3 project (either packaged with single project or with WAP).
Add <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> in the project file.
Turn on code analysis with the following project properties:
@Scottj1s is there a value that could work in all cases? If <WindowsAppSdkUndockedRegFreeWinRTInitialize>true</> is Microsoft.WindowsAppRuntime.dll always colocated with the process' exe? Is WindowsAppSdkUndockedRegFreeWinRTInitialize=true only usable by EXEs or can be used in other cases e.g. class libraries? Would adding this attribute achieve the goal in all cases:
Describe the bug
When both
WindowsAppSDKSelfContained
and code analysis are turned on for a WinUI 3 project, it fails to build due toCA5392: Use DefaultDllImportSearchPaths attribute for P/Invokes in
Microsoft.Windows.Foundation.UndockedRegFreeWinRTCS.WindowsAppRuntime_EnsureIsLoaded
.Steps to reproduce the bug
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
in the project file.See example code repo here: https://github.com/[aries-zhang/WinUI3-Publish-SelfContained](https://github.com/aries-zhang/WinUI3-Publish-SelfContained)
Expected behavior
Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002
Windows version
Windows 11 (24H2): Build 22621
Additional context
Since this is generated code (or included from Nuget?), it makes it hard to suppress the error individually if not a global suppression rule.
The text was updated successfully, but these errors were encountered: