CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

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

Open asklar opened this issue 11 months ago • 0 comments

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

asklar avatar Dec 11 '24 21:12 asklar