Skip to content
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

.NET 5 - dotnet tool support for WinForms applications targeting net5.0-windows #16361

Open
guidemetothemoon opened this issue Mar 15, 2021 · 5 comments
Milestone

Comments

@guidemetothemoon
Copy link

Hello.

I have a question regarding dotnet tool supprot for WinForms applications: we have been planning to lift our .NET Core 3.1 Windows Forms applications that are now being packaged as dotnet tools to .NET 5 but this will mean that the target framework for those applications will be .net5.0-windows.

The problem is then that we will not be able to package those apps as dotnet tools anymore, ref. following error message coming from the build pipeline:
C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.PackTool.targets(95,5): error NETSDK1146: PackAsTool does not support TargetPlatformIdentifier being set. For example, TargetFramework cannot be net5.0-windows, only net5.0. PackAsTool also does not support UseWPF or UseWindowsForms when targeting .NET 5 and higher.

Unfortunately I'm not able to find more detailed information or any documentation saying that it's not supported and what alternative approaches are recommended.
Can someone please clarify this for me?

Thanks in advance!

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Mar 15, 2021
@wli3 wli3 added this to the Backlog milestone Mar 19, 2021
@wli3 wli3 removed the untriaged Request triage from a team member label Mar 19, 2021
@wli3 wli3 removed their assignment Mar 19, 2021
@tthiery
Copy link

tthiery commented May 8, 2021

@marcpopMSFT I have the same issue when multi-targeting a console application with <TargetFrameworks>net5.0-windows10.0.19041.0;net5.0</TargetFrameworks> (I use WinRT Bluetooth Stack on Windows and other stacks which do not need a framework).

I am very confused about this considering that dotnet tool install -g has a switch to specify the framework (--framework)

@marcpopMSFT
Copy link
Member

@wli3 do we have this limitation documented anywhere outside of the error message?

@wli3
Copy link

wli3 commented May 11, 2021

Any suggestion to make the error message better? At this point, anything net5.0-windows will not be supported. And there is no easy way to pack only one specific TFM to tools.

The root cause is #12055

@tthiery
Copy link

tthiery commented May 12, 2021

I think the error message is quite alright. The "also" of the WPF/WinForms message is quite correct, but I overread it the first time.

Independent of the error message, it is the mismatch against the expectations which is the problem 😀. We see a CLI parameter and think we can just pack it like a regular multi-target NuGet.

lindexi added a commit to dotnet-campus/dotnetCampus.FileDownloader that referenced this issue Aug 3, 2022
C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.PackTool.targets(95,5): error NETSDK1146: PackAsTool does not support TargetPlatformIdentifier being set. For example, TargetFramework cannot be net5.0-windows, only net5.0. PackAsTool also does not support UseWPF or UseWindowsForms when targeting .NET 5 and higher.

dotnet/sdk#16361
gsuuon added a commit to gsuuon/grab that referenced this issue May 25, 2024
dotnet PackAsTool is busted since dotnet 5.0 if using windowsforms or wpf (though I definitely had it working with dotnet 7). Not sure the right way to do this, I don't like bringing in windowsforms just to get screen resolution and offsets but i've already spent way too long trying to find another way and there doesn't seem to be one. maybe wmi/cim would work, but i couldn't find if it can report the offsets necessary for ffmpeg to record the screen correctly.

I think this workaround basically lies to packastool when it does its check. doesn't seem to have any impact on if it works or not at runtime.

see dotnet/sdk#16361 and dotnet/sdk#12055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants