IntelliSense Support for Resources from winui Custom Control Library in nuget

Mahdi Hosseini 270 Reputation points
2025-12-22T12:07:43.4133333+00:00

I was able to make it work by using a hardcoded string:

 <None Include="Themes\Generic.xaml" Pack="true" PackagePath="lib\net8.0-windows10.0.19041\DevWinUI.Controls\Themes\" />

However, since I’m using multiple target frameworks, I need to make it dynamic. So I used:

<None Include="Themes\Generic.xaml" Pack="true" PackagePath="lib\$(targetframework)\DevWinUI.Controls\Themes\" />

However, as you can see, this approach does not work and results in an “Unrecognized framework” error. The DevWinUI.Controls folder and its subfolders/items should be placed inside net10.0-windows10.0.19041, net8.0-…, and net9.0-….

User's image

How can I make this work?

To reproduce the issue, you can create a blank class library, configure it to target multiple frameworks, add an empty resource dictionary at Themes\Generic.xaml, and then enable Generate package on build.

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

Windows development | WinUI
0 comments No comments
{count} votes

Answer accepted by question author
  1. Michael Le (WICLOUD CORPORATION) 10,555 Reputation points Microsoft External Staff Moderator
    2025-12-23T04:21:35.6633333+00:00

    Hello @Mahdi Hosseini ,

    You could try to update your code to:

    <None Include="Themes\Generic.xaml" Pack="true" PackagePath="lib\$(TargetFramework)\DevWinUI.Controls\Themes\" />
    

    If the fix above doesn't work, you can use the TargetsForTfmSpecificContentInPackage approach:

    <PropertyGroup>
      <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackCustomContent</TargetsForTfmSpecificContentInPackage>
    </PropertyGroup>
    
    <Target Name="PackCustomContent">
      <ItemGroup>
        <TfmSpecificPackageFile Include="Themes\Generic.xaml">
          <PackagePath>lib\$(TargetFramework)\DevWinUI.Controls\Themes\</PackagePath>
        </TfmSpecificPackageFile>
      </ItemGroup>
    </Target>
    

    I hope this helps, and happy holidays.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.