-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NETSDK1100 blocks building on Linux #3592
Comments
Could you split your project? Blocking the usage of that SDK on non-windows platforms is very much by design for us. We have no considered people multi-targeting with that SDK into older TFMs. |
I suppose I could split the project. But I'd sorely miss the virtues that multi-targeting projects brought by converging all those project-per-TFM that we used to see everywhere. |
Ah, but that only really solves the test project problem. I have exactly the same problem in the product project as well. And that project packs all the TFMs together. So splitting that project would require a great deal of effort to write a custom pack step since no one project could self-pack any more. :( |
I'm hitting this again, with another project. I'd very much like to support WPF on .NET Core 3.0 in microsoft/vs-threading#548 but cannot do it because simply referencing How can I get a WindowsBase reference assembly for the .NET Core 3.0 target of the project? |
@livarcocc Your workaround doesn't work either. Even if we have multiple projects, the very fact that we ever used <frameworkReferences>
<group targetFramework=".NETCoreApp3.0">
<frameworkReference name="Microsoft.WindowsDesktop.App" />
</group>
</frameworkReferences> This kills my project for all downstream consumers of my package that want to build on mac/linux while targeting .NET Core 3.0. They fail with this error:
This makes no sense to the downstream consumer because they don't have that |
Works around dotnet/sdk#3592 as described in AArnott/Xunit.StaFact#35
I don't think we have changed our position on this. Our concern is folks who do more than just reference assemblies running their builds on linux when their projects depend on windows tools. The chances of success go down drastically and can lead to a very confusing experience. @nguerrera and @dsplaisted can you think of an alternative here? |
I think we went back and forth a bit on this during development. We ended up disabling referencing WindowsDesktop on non-Windows because we didn't want to ship the WindowsDesktop targeting pack together with the SDK on Mac and Linux, but if it was still supported it would have always been downloaded whether it was needed or not, because at the time we're restoring we don't know if it will be needed based on a transitive reference. I think when we made the decision our intention was to monitor feedback and try to enable the scenario of referencing WindowsDesktop on Mac/Linux in the future if necessary. This seems like an indication that it may be necessary. |
Thanks, @dsplaisted. It sure would make it easier. At the moment my plan is to remove .NET Core 3.0 WPF/WinForms support from my Xunit.StaFact package because essentially what I have is a regression in my package now. The only way forward (unless we get ref assemblies available off-Windows) will be to create a new |
The xunit workaround is ugly, but at least technically feasible. For the vs-threading library, it forces us into either of these unfortunate choices:
Both of these are ugly choices, but the second option is more ugly. So we simply will cut WPF support on netcoreapp3.0 till such time as the .NET Core SDK allows referencing WPF assemblies/packages without breaking linux/mac consumption. |
Given the lack of response to this, I'm going to go ahead and remove .NET Core WPF/WinForms support from Xunit.StaFact (and try to create a separate package to support it, if feasible). (CC: @RussKie) I'll also plan on never fully supporting WPF on .NET Core in the vs-threading library. And again, this is because there's no way to support WPF/WinForms on .NET Core 3.0 without dropping support for .NET Core 3.0 on non-Windows OS's. I'm picking the lesser of two evils here. But it's awfully painful to not have what seems like a simple fix to this. I hope it comes one day. |
FYI this is on our radar. I think we will try to improve this for .NET 5 (no promises of course). |
I ran into this myself with the 3.1 SDK. My workaround was to add this to my csproj file. This is a workaround, of course, so your mileage may vary. <ItemGroup>
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App" IsWindowsOnly="false" />
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App.WPF" IsWindowsOnly="false" />
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App.WindowsForms" IsWindowsOnly="false" />
</ItemGroup> |
….1 (dotnet#3592) - Microsoft.NET.Sdk - 3.1.100-rtm.19565.1
This allow play with .NET Core support for tutorials. These tutorials still can be built only on Windows. See dotnet/sdk#3592 So if any configuration changes should be present, they now can be split not on Core/Full ,but on Windows/NonWindows basis. I know that there some difference in codebase, but I do not play with that yet.
The original post discusses multi-targeting specifically, but I was wondering what the chances are of being able to build Windows-only applications on Linux in future? I have a .NET Core WinForms app where only a single UI assembly targets the Would this be as 'straightforward' as something like a targeting pack to satisfy type dependencies at build time, or are there other Windows-only tools in play when building an assembly that targets |
There are some discussions for this in the individual projects (WinForms and WPF) - there is some interest to have this happen, but I'm not aware of anyone actively working towards it.
Unlikely since I've not noticed anyone working on it, and .NET 5 is close to release (nothing new going in at this point). Some people claim to have gotten cross compilation on Linux targeting Windows working for some specific scenarios by using workarounds, but I haven't been following these discussions nor have I tried it myself. |
We would like to enable this but it's certainly not going to be in .NET 5. Part of the issue is that we think most people developing on Mac / Linux will not want to build Windows UI projects, so we don't want to bloat the SDK for them by including the support by default. For .NET 6, we will be adding more support for .NET SDK optional workloads, which should eventually provide us a way of having the Windows UI support as an optional component that's not installed by default. |
Why must this additional support be built into the SDK at all? Why not have it be a nuget package that can be referenced by UI projects, that includes the SDK tools necessary to build such projects? |
Sadly this workaround does not work for net5.0-windows 😢 This would help save a lot of GitHub Actions minutes if we could build on ubuntu. |
Still seems to be an issue, also on Mac... Any idea how to fix? |
We are seeing this issue as well. We have an cross-platform application consisting of several binaries/projects. Only one of those project targets net5.0-windows. IMO: saving some MB or even GB of data is not a good arguement to break docker builds. Probably no one will be noticing it if you include it , except of the people, that are trying to do reproducable cross-platform builds, that are going to work then. I'am developing some xamarin-apps as well and the biggest inconvenience there is that if you want to build a release you have to start compiling the code on different platforms. Please don't go the same route with NET5 and NET6. It will make me regret not to have chosen electron. I tried switching to mcr.microsoft.com/dotnet/sdk:6.0, but it resulted in the same error:
|
I have the same issue on macOS |
same issue on mac visual studio |
any updates on that? |
So, net6 was released and it still an issue. |
It makes sense, but you don't need to use WinUI to be required to use "net6.0-windows10.0.xxxxx" target. |
Last I tried (which was a while ago) the .NET SDK was engineered to block WPF/WinForms references unless on Windows. Even though they are just ref assemblies and could compile just fine on another platform. :( |
We'd dearly love to be able to do this as well. In our case, our CI/CD environment runs on macOS, and part of it uses a local SonarQube installation to build and analyse the codebase. We have a single That currently leaves us with two options: either set up a Windows-based build environment just for the WPF app (which then means two sets of SonarQube analysis runs/reports), or remove the WPF app project from the solution (meaning no SonarQube analysis for any WPF-specific code). |
Does anybody knows currently working workarounds for .net 5/6? Apart from using separated sln. |
I really wish this was higher prioritized. Please allow us to build on Linux when targeting Windows. |
Ridiculous that this doesn't work. |
This workaround just saved me. Now my application is building properly on GitLab CI. My setup:
Thank u! |
For my scenario at least, the fix was to add this property to the project: <EnableWindowsTargeting>true</EnableWindowsTargeting> My scenario being that I'm referencing the latest |
Looks like we never closed this when Daniel added that new property as a workaround. |
I'm sorry but I do not understand how these workarounds are supposed to work. Can someone please elaborate? I have a WPF project that I'd like to compile on Linux, mostly as part of the CI to check the build works. I would not mind if the produced executable does not work. I already set
Here is my dotnet --info:
|
@emmenlau I've also just run into this today, also .net 8 on Ubuntu 24.04. For me the issue was that I was using the 'new' Ubuntu-packaged release of dotnet instead of the Microsoft release. See this discussion. Seems the Ubuntu packages do not include the full set of workloads required for targeting Windows builds. The solution was remove all the Ubuntu dotnet packages (apt --purge remove dotnet*) and then install using the Microsoft install script instead (don't forget to add to your path). After that I was able to build my project which targets both net8.0 and net8.0-windows without any problems. Using the Microsoft packages over the Ubuntu ones may not be appropriate for you for other reasons. There is a post further down in that discussion link which suggests it's possible to manually download and extract the workload files and copy them in to the correct place in your dotnet installation, but that sounds like a maintenance nightmare to me - for me the script was the way to go. |
Oh my, this seems to be the solution!!! I've just briefly tested it, and indeed, the Microsoft official upstream packages contain several more SDKs, which are missing in the Ubuntu provided packages. This is quite sad and frustrating, since all Microsoft websites recommend the Ubuntu packages. But at least there is some solution! |
I have a test project which multi-targets between net472;netcoreapp2.1;netcoreapp3.0.
Only when targeting net472 or netcoreapp3.0 does it reference or use any WPF/WinForms types. Nevertheless, I have to set the SDK attribute to
Microsoft.NET.Sdk.WindowsDesktop
for this to work with netcoreapp3.0 at all, AFAIK.This blocks the test project from building the
netcoreapp2.1
target on linux, which blocks me testing my library on Linux.How should I proceed?
The text was updated successfully, but these errors were encountered: