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

Bug: Can't use Microsoft Fakes with cswinrt / windows sdk projects #1885

Open
asklar opened this issue Dec 11, 2024 · 0 comments
Open

Bug: Can't use Microsoft Fakes with cswinrt / windows sdk projects #1885

asklar opened this issue Dec 11, 2024 · 0 comments

Comments

@asklar
Copy link
Member

asklar commented Dec 11, 2024

Description

Looking to use Microsoft Fakes for unit testing, but I can't get it to build.
Need to peel the onion to make Fakes usable.

Isolate your app with shims (unit testing) - Visual Studio (Windows) | Microsoft Learn

Steps To Reproduce

Image

in the fakes config, clear all:

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="Microsoft.Windows.SDK.NET" Version="10.0.22621.38"/>
    <ShimGeneration>
        <Clear />
    </ShimGeneration>
</Fakes>

when building there's at least 2 classes of problems:

  1. Referencing a Windows Metadata component directly when targeting .NET 5 or higher is not supported. (my project references some winrt assemblies via cswinrt, and Fakes seems to want to reference the winmds directly which won't work).
  2. Multiple versions of WinRT.Runtime:

1>------ Build started: Project: ActionFX, Configuration: Debug x64 ------
1>E:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2413,5): error MSB3277: Found conflicts between different versions of "WinRT.Runtime" that could not be resolved. [D:\path_to_my_project\Fakes\mwsdknet\f.csproj]

Expected Behavior

can build with Fakes

Version Info

2.2.0

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant