question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MSTest project won't compile with WinUI referenced

See original GitHub issue

Describe the bug If you create an MSTest project and reference WinUI you get build errors making it impossible to use these APIs in testing.

Steps to reproduce the bug

  1. Create a new MS Test .NET 5 test project
  2. Add WinUI 3 Preview 4
  3. Try and compile and observe these errors:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2451,5): warning MSB3842: Project "WinUITests" depends upon SDK "Visual C++ 2015-2019 UWP Desktop Runtime for native apps v14.0" which supports apps targeting "Windows 10.0". To verify whether "Visual C++ 2015-2019 UWP Desktop Runtime for native apps v14.0" is compatible with "Windows 10.0.18362.0", contact the SDK author or see http://go.microsoft.com/fwlink/?LinkID=309181.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2451,5): error MSB3843: Project "WinUITests" targets platform "Windows", but references SDK "Visual C++ 2015-2019 UWP Desktop Runtime for native apps v14.0" which targets platform "UAP".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2451,5): warning MSB3842: Project "WinUITests" depends upon SDK "Microsoft Universal CRT Debug Runtime v10.0.18362.0" which supports apps targeting "Windows 10.0". To verify whether "Microsoft Universal CRT Debug Runtime v10.0.18362.0" is compatible with "Windows 10.0.18362.0", contact the SDK author or see http://go.microsoft.com/fwlink/?LinkID=309181.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2451,5): error MSB3843: Project "WinUITests" targets platform "Windows", but references SDK "Microsoft Universal CRT Debug Runtime v10.0.18362.0" which targets platform "UAP".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2451,5): warning MSB3842: Project "WinUITests" depends upon SDK "Visual C++ 2015-2019 Runtime for Universal Windows Platform Apps v14.0" which supports apps targeting "Windows 10.0". To verify whether "Visual C++ 2015-2019 Runtime for Universal Windows Platform Apps v14.0" is compatible with "Windows 10.0.18362.0", contact the SDK author or see http://go.microsoft.com/fwlink/?LinkID=309181.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2451,5): error MSB3843: Project "WinUITests" targets platform "Windows", but references SDK "Visual C++ 2015-2019 Runtime for Universal Windows Platform Apps v14.0" which targets platform "UAP".

Full csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0-windows10.0.18362</TargetFramework>
    <TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
    <IsPackable>false</IsPackable>
    <PlatformTarget>x64</PlatformTarget>
    <RootNamespace>WinUITests</RootNamespace>
    <RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.WinUI" Version="3.0.0-preview4.210210.4" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
    <PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
    <PackageReference Include="coverlet.collector" Version="3.0.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <Manifest Include="$(ApplicationManifest)" />
  </ItemGroup>

</Project>

Expected behavior Project compiles fine.

Screenshots

image

Version Info

NuGet package version: [Microsoft.WinUI 3.0.0-preview4.210210.4]

Windows app type:

UWP Win32
Yes
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

An alternative approach to reproduce is to create a new WinUI project and add this package to the project:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
dotMortencommented, Mar 15, 2021

Thanks Scott. That makes way more sense

1reaction
Scottj1scommented, Mar 15, 2021

Sorry - clarified wording

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot compile WinUI 3.0 app that references a custom ...
I have a Visual Studio 2019 solution that contains two project. The first project has been created using the "Windows Runtime Component ...
Read more >
WinUI Desktop Unit Tests - #ifdef Windows
In this blog post, we'll jump straight into how to create a Unit Test project for WinUI Desktop, using MSTest!
Read more >
Create your first WinUI 3 (Windows App SDK) project
In this topic we'll see how to use Visual Studio to create a new project for a C# .NET or C++ app that...
Read more >
NET Core MSTest Project throwing method not found error
1. Create Unit test project targeting .Net Core. 2. Add a reference to the Telerik.JustMock.dll that targets the .Net Framework.
Read more >
Exe published from default WinUI 3/Windows App SDK ...
It works just fine compiling/debugging/running it from Visual Studio 2022. When when I try to Publish (right-click on the project, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found