dotnet --info)Problem description:
Build of WinForms project fails on non-Windows platforms with missing msbuild files
I did see that #947 speaks about a similar case, but from THAT issue it is not clear the submitter wants to build to work so much as the template removed...
Actual behavior:
error MSB4019: The imported project "/home/damageboy/dotnet/sdk/3.0.100-preview5-011568/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.targets"
Expected behavior:
Build should succeed.
Minimal repro:
dotnet new winforms
The template "Windows Forms (WinForms) Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on /tmp/xxx/xxx.csproj...
Restore completed in 96.54 ms for /tmp/xxx/xxx.csproj.
Restore succeeded.
dotnet build
Microsoft (R) Build Engine version 16.0.462+g62fb89029d for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 19.23 ms for /tmp/xxx/xxx.csproj.
/home/damageboy/dotnet/sdk/3.0.100-preview5-011568/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets(14,2): error MSB4019: The imported project "/home/damageboy/dotnet/sdk/3.0.100-preview5-011568/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [/tmp/xxx/xxx.csproj]
Build FAILED.
/home/damageboy/dotnet/sdk/3.0.100-preview5-011568/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets(14,2): error MSB4019: The imported project "/home/damageboy/dotnet/sdk/3.0.100-preview5-011568/Sdks/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.WinFX.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [/tmp/xxx/xxx.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.78
If building WinForms projects on Linux/Mac is going to be a supported scenario please make sure that failed assembly and type loading get a reasonable diagnostic in the build output. In particular C++/CLI assemblies will only work on Windows I think.
Note that failed assembly loads can cascade to failed type loads in other assemblies when the type used something from a C++/CLI assembly. I don't know how much WinForms requires assembly loading at build time, but licx and resx come to mind as candidates to look at. In particular the diagnostics of licx compilation is pretty bad if it fails to load the right assemblies ("lc.exe exited with code -1")
Also I think licx compilation needs to actually execute code so that might make it impossible to build with certain kinds of licensed native 3rd party controls. Just make sure the error diagnostics tell you what the problem is. (Something better than "lc.exe exited with code -1")
I think this is unsupported? @livarcocc @nguerrera @richlander any thing you guys know / think / feel?
I think I should probably try and explain why I think so basic support for this is in order:
Right now, in the current state of .NET Core 3.0 p5, the mere operation of opening a solution with a winforms project fails due to the missing Microsoft.WinFX.targets file on non-Windows build platforms.
This is really unfortunate, as IDEs on those platforms (VSCode, VS4Mac, Rider) will fail to load relevant .csproj files and as a result basic code navigation and refactoring functionality in all 3 projects will be greatly reduces in case of mixed-use solution (3 shared libraries, MacOS UI, WPF UI solution for example).
My aim is not to get full fledged support from Microsoft to fully build WinForms + WPF on Linux/Mac, but to get basic build / inetellisense support to make my IDE more functional.
Issue moved to dotnet/core-sdk #2088 via ZenHub
Most helpful comment
I think I should probably try and explain why I think so basic support for this is in order:
Right now, in the current state of .NET Core 3.0 p5, the mere operation of opening a solution with a winforms project fails due to the missing
Microsoft.WinFX.targetsfile on non-Windows build platforms.This is really unfortunate, as IDEs on those platforms (VSCode, VS4Mac, Rider) will fail to load relevant
.csprojfiles and as a result basic code navigation and refactoring functionality in all 3 projects will be greatly reduces in case of mixed-use solution (3 shared libraries, MacOS UI, WPF UI solution for example).My aim is not to get full fledged support from Microsoft to fully build WinForms + WPF on Linux/Mac, but to get basic build / inetellisense support to make my IDE more functional.