novotnyllc/MSBuildSdkExtras

error MSB4019: "Microsoft.WinFX.props" was not found

mvanbeusekom opened this issue · 9 comments

On my Ubuntu machine, I run into the error below when trying to compile a .NET Standard 2.0 class library using the MSBuild.Sdk.Extras package (if I switch back to the default Microsoft.NET.Sdk the error does't show):

error MSB4019: The imported project "/usr/share/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.

Steps to reproduce:

  1. Create a new project using dotnet new classlib;
  2. Update the project SDK in the .csproj file so it reads <Project Sdk="MSBuild.Sdk.Extras">;
  3. Add a new file called global.json to the root of the project with the following content:
{
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.0.54"
  }
} 
  1. Restore all NuGet packages: dotnet restore
  2. Build the project with dotnet build

I have noticed that the Microsoft.WinFX.props file does exists but spelled with a lower case "x". For now a workaround is to simply rename the file:

sudo mv "/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFx.props" "/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.props"

Not sure this is the correct place for this issue. But it looks like the Microsoft.WinFX.props target is incorrectly referenced by the MSBuild.Sdk.Extras package since it is ment to be used fro WPF and WinForms projects which are not supported on Linux and MacOS. My assumption is this problem doesn't occur on MacOS since it doesn't use a case sensitive filesystem be default.

Same here MacOSX (case sensitive) newly installed.

Google.Play.Services and AndroidX (Xamarin.Android) builds

diskutil info /

output:

   Device Identifier:         disk1s6
   Device Node:               /dev/disk1s6
   Whole:                     No
   Part of Whole:             disk1

   Volume Name:               MacOSX
   Mounted:                   Yes
   Mount Point:               /

   Partition Type:            41504653-0000-11AA-AA11-00306543ECAC
   File System Personality:   Case-sensitive APFS
   Type (Bundle):             apfs
   Name (User Visible):       APFS (Case-sensitive)
   Owners:                    Enabled

Workaround:

sudo mv \
    /usr/local/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFx.props \
    /usr/local/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.props

Expected someone should've hit this.

The Fix is here: dotnet/wpf#2975

@Nirmal4G

You fixed WPF, but what about other projects?

Solution is to add tests on Mac case sensitive APFS as early as possible. Xamarin.Android team is quite safe regarding to this problem, because some of the team members are working on Linux which is case sensitive by default.
This issue might impact other teams.

@moljac dotnet/wpf#2975 (comment)

You fixed WPF, but what about other projects?

If there are any other targets that are in incorrect case, please let me know. For now, your workaround to rename the file is the solution.
You can also report to the appropriate team, if it's not open source OR You can also create issue/PR in the repos which host the targets.

@Nirmal4G

I'm on Xamarin.Android team and detected this "by accident". Who would install case sensitive filesystem support, but crazy bored guy... And I did.
We discovered few issues in our builds, but this maybe should be fixed here.

And maybe case sensitive tests could be added.

@moljac

Yeah, on the other hand, tests should be added. For the fix, we could conditionally import the desktop sdk targets.

I meant the WinFX targets.

Since, we always import the desktop Sdk props/targets which in turn imports the WinFX targets with incorrect casing and that'll fail in case sensitive OS / file systems.

Duplicate of #207 ? See dotnet/sdk#11108