Open
Description
Describe the bug
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:
<AnalysisMode>all</AnalysisMode> <AnalysisLevel>latest</AnalysisLevel> <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- Build the project.
See example code repo here: https://github.com/[aries-zhang/WinUI3-Publish-SelfContained](https://github.com/aries-zhang/WinUI3-Publish-SelfContained)
Expected behavior
- Build should be successful.
- No potential DLL hijacking risks should present.
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.