Sdk: [MSBuildExtras] Using msbuild extras under linux fails with missing Microsoft.WinFX.props

Created on 2 Apr 2020  路  8Comments  路  Source: dotnet/sdk

MSBuild extras validates that projects can successfully build under a variety of .NET Runtimes and OSes, and a recent addition of validation of .NET Core 3.1 fails the build under Linux with the following error:

/__t/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props(208,3): 
error MSB4019: The imported project "/__t/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.props" was not found. 
Confirm that the expression in the Import declaration "Microsoft.WinFX.props" is correct, and that the file exists on disk.

This error does not happen with .NET Core 3.0 and 2.2.

The error happens when building this project, with this script.

Most helpful comment

It seems the fix is not merged into SDK 3.1.302! So, I've asked whether it is possible for back porting the fix into 3.1.

All 8 comments

This seems like either an issue with MSBuildExtras itself, or just a limitation of the fact that building projects targeting UAP isn't supported on Linux.

FYI @clairernovotny

just a limitation of the fact that building projects targeting UAP isn't supported on Linux.

That's not it, you can reproduce with just

<Project Sdk="MSBuild.Sdk.Extras">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>
</Project>

This error is caused by a casing issue, where the import here:

https://github.com/dotnet/wpf/blob/165948b449e9de9fbba9843c2695f32a3212158f/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props#L208

Does not match the casing in this folder:

gitpod@ws-XXX:/workspace/uno$ ll /usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets
total 72
drwxr-xr-x 2 root root  4096 Mar 18 17:39 ./
drwxr-xr-x 5 root root  4096 Mar 18 17:39 ../
-rw-r--r-- 1 root root 11191 Feb 28 17:55 Microsoft.NET.Sdk.WindowsDesktop.props
-rw-r--r-- 1 root root  6543 Feb 28 17:55 Microsoft.NET.Sdk.WindowsDesktop.targets
-rw-r--r-- 1 root root  1482 Feb 28 17:55 Microsoft.WinFx.props
-rw-r--r-- 1 root root 40124 Feb 28 17:55 Microsoft.WinFx.targets

The Fix is here: dotnet/wpf#2975

Still happening even with the merged fix (SDK 3.1.302)

This got fixed in https://github.com/dotnet/wpf/commit/b198dcfba5ad68db829dadc4637e244129a3c23b - or at least the failing line removed in that commit.

It seems the fix is not merged into SDK 3.1.302! So, I've asked whether it is possible for back porting the fix into 3.1.

The workaround implemented by Jerome in https://github.com/unoplatform/docker/pull/4/commits/8e13b5b5f68ccc082048913dac88bc86ffe6006b finally made it possible to use MsBuild.Sdk.Extras with .NET Core 3.1 on my Linux machine! Posting this message here for dumb people like me who didn't notice this easy workaround when viewing the issue for the first time. Thank you @jeromelaban! <3

Was this page helpful?
0 / 5 - 0 ratings