microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.28k stars 674 forks source link

Xaml files loaded in project from related shared project #8609

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] My winui 3 application starts suddenly to show xaml files that are from the shared project reference. It's very annoying and also confusing when multiple files are shown like this.


Original Comments

Feedback Bot on 11/15/2022, 05:29 PM:

(private comment, text removed)

Feedback Bot on 11/21/2022, 05:50 AM:

(private comment, text removed)


Original Solutions

(no solutions)

MSLukeWest commented 1 year ago

Pasting comments from VS investigation (1684052):

This issue is specific to WinUI projects (e.g. can't be reproduced in Wpf projects). I was able to trace this to .nuget\packages\microsoft.windowsappsdk\1.3.230602002\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets that has some logic that adds all Page items as Resource as well. Those "Resource" items end up showing in the project.

To fix this issue, these items should set the Visible property to false.

Before:

<Resource Include="@(Page)" />

<Resource Include="@(ApplicationDefinition)" />

After:

    <!--
    ============================================================
    Adds all XAML Pages to the $(Resource) collection
    ============================================================
    -->
    <ItemGroup Condition=" '$(ManagedAssembly)'=='' ">
        <!-- Add XAML Page items to $(Resource) -->
        <Resource Include="@(Page)">
                <Visible>false</Visible>
        </Resource>

        <Resource Include="@(ApplicationDefinition)" >
                <Visible>false</Visible>
        </Resource>
    </ItemGroup>