Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.UI.Xaml.winmd not included in build output #4701

Closed
ollitanska opened this issue Mar 31, 2021 · 7 comments · Fixed by #4731
Closed

Microsoft.UI.Xaml.winmd not included in build output #4701

ollitanska opened this issue Mar 31, 2021 · 7 comments · Fixed by #4731
Assignees
Labels
area-DevInternal Internal build infrastructure, code cleanup, engineering efficiency area-Islands Xaml Islands feature team-Controls Issue for the Controls team
Milestone

Comments

@ollitanska
Copy link

Describe the bug

After upgrading to v2.6.0-prerelease.210315002 from v2.6.0-prerelease.210227001, the Microsoft.UI.Xaml.winmd is not included in the output directory anymore. Microsoft.UI.Xaml.dll and Microsoft.UI.Xaml.pri are included as expected.

This causes the following exception when starting up the application: 'System.TypeLoadException: Could not find Windows Runtime type 'Microsoft.UI.Xaml.Controls.XamlControlsResources'.

This regression seems to be caused by this commit: #4218

Steps to reproduce the bug

  1. Follow the Xaml Islands guide on https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/host-custom-control-with-xaml-islands
  2. Install version v2.6.0-prerelease.210227001 of the package, application should start fine
  3. Install version v2.6.0-prerelease.210315002 of the package, application will not start. No .winmd file and got System.TypeLoadException exception

Expected behavior
Application would startup normally, Microsoft.UI.Xaml.winmd would be included in the output directory.

Version Info

NuGet package version:
[Microsoft.UI.Xaml.v2.6.0-prerelease.210315002]

Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context
WPF application that hosts a custom UWP control (which uses WinUI 2.6) via XAML Islands.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Mar 31, 2021
@StephenLPeters StephenLPeters added area-DevInternal Internal build infrastructure, code cleanup, engineering efficiency area-Islands Xaml Islands feature team-Controls Issue for the Controls team labels Mar 31, 2021
@StephenLPeters StephenLPeters added this to the WinUI 2.6 milestone Mar 31, 2021
@StephenLPeters
Copy link
Contributor

@ollitanska Thanks for the bug! do you have a repro app you could provide here? it would be handy in fixing this :)

@StephenLPeters
Copy link
Contributor

@ranjeshj I think this is needed for 2.6 release.

@ollitanska
Copy link
Author

@ollitanska Thanks for the bug! do you have a repro app you could provide here? it would be handy in fixing this :)

Here is a minimal repro app.

XamlIslandsSample.zip

@llongley
Copy link
Member

llongley commented Apr 2, 2021

Hi @ollitanska - I have a candidate fix that works on my side, but I was hoping you could test it out and see if it works for you as well before I send it out for PR. Could you put this at the very bottom of App1.csproj, just before </Project>?

  <Target Name="_AddXamlWinmdToPackageLayoutRoot" AfterTargets="BuildNativePackage">
    <ItemGroup>
      <AppxPackagePayload Include="@(XamlWinmd)">
        <TargetPath>Microsoft.UI.Xaml.winmd</TargetPath>
      </AppxPackagePayload>
    </ItemGroup>
    <Copy SourceFiles="@(XamlWinmd)" DestinationFiles="@(XamlWinmd -> '$(OutDir)\%(Filename)%(Extension)')" />
  </Target>

If this does work for you, also try it in whatever app you were using where you found this. If it works in both locations, I can get this fix in the pipeline.

@llongley llongley removed the needs-triage Issue needs to be triaged by the area owners label Apr 2, 2021
@ollitanska
Copy link
Author

Hi @ollitanska - I have a candidate fix that works on my side, but I was hoping you could test it out and see if it works for you as well before I send it out for PR. Could you put this at the very bottom of App1.csproj, just before </Project>?

  <Target Name="_AddXamlWinmdToPackageLayoutRoot" AfterTargets="BuildNativePackage">
    <ItemGroup>
      <AppxPackagePayload Include="@(XamlWinmd)">
        <TargetPath>Microsoft.UI.Xaml.winmd</TargetPath>
      </AppxPackagePayload>
    </ItemGroup>
    <Copy SourceFiles="@(XamlWinmd)" DestinationFiles="@(XamlWinmd -> '$(OutDir)\%(Filename)%(Extension)')" />
  </Target>

If this does work for you, also try it in whatever app you were using where you found this. If it works in both locations, I can get this fix in the pipeline.

Works great, both on the repro app and our real app!

Thanks for quick response!

@llongley
Copy link
Member

llongley commented Apr 3, 2021

Sweet, thanks for the confirmation! I'll get that out for PR.

@sylveon
Copy link
Contributor

sylveon commented Apr 8, 2021

Is it possible to add an option to not copy the file still, since C++ based Xaml islands apps don't need the winmd.

llongley added a commit that referenced this issue Apr 20, 2021
A recent change I made worked around a .NET Native issue by having us no longer copy the WinMD file to the output directory, but that broke unpackaged XAML islands apps since they rely on it being there. I've added a line to the targets file to copy the WinMD once .NET Native compilation has completed, which fixes the issue.

This did, however, surface the fact that we don't currently have any XAML islands coverage in our CI pipeline. To fix that, I've added a WPF application and have a canary test that launches the application in both a packaged and an unpackaged state, and retrieves and clicks a button, just to ensure that both forms of XAML islands apps launch correctly.

Fixes #4701
@ghost ghost removed the working on it label Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-DevInternal Internal build infrastructure, code cleanup, engineering efficiency area-Islands Xaml Islands feature team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants