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

EnableWindowsTargeting does not work well for building WinApps in linux #34197

Closed
ali50m opened this issue Feb 22, 2023 · 10 comments · Fixed by #34466
Closed

EnableWindowsTargeting does not work well for building WinApps in linux #34197

ali50m opened this issue Feb 22, 2023 · 10 comments · Fixed by #34466
Assignees
Labels
cli/subsvc doc-enhancement Improve the current content [org][type][category] dotnet-fundamentals/svc Pri2 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@ali50m
Copy link
Contributor

ali50m commented Feb 22, 2023

Hi Team,

I am trying to build and publish my WPF(.net7-windows) through the github action pipeline. After reading this blog, I find EnableWindowsTargeting can be used for build Windows App on a linux machine.

However, after publishing the app in ubuntu-latest runner and run it, I find there is a unwanted console output window after my app is lauching. It does not act like the building artifact from windows machine.

I also tried publish the app on ther linux machines and found the same behavior. The console output window is annoying.

You can also see this issue in this blog.

Please kindly let me know if there is any other properties need to combine with EnableWindowsTargeting for building a WPF app in linux, or it is a bug?

BTW, the windows runner for github action is really slow, and expensive, comparing to ubuntu runner. :(


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 69434

@ali50m
Copy link
Contributor Author

ali50m commented Feb 22, 2023

#30076

@tdykstra
Copy link
Contributor

@marcpopMSFT who can help with this issue?

@tdykstra tdykstra added support-request Support-style question;customer needs help solving a problem [org][type][category] and removed ⌚ Not Triaged Not triaged labels Feb 22, 2023
@tdykstra tdykstra self-assigned this Feb 22, 2023
@abitzer
Copy link

abitzer commented Mar 1, 2023

I have the same issue on .NET 6.0.
It seems the PE Header of the executable "states:

  • "User Interface" : "Windows console" rather than "Windows GUI"
  • In addition the file information like e.g. File Version, Company Name, ... are missing

@marcpopMSFT
Copy link
Member

Adding @dsplaisted who did that feature. I think the extra window comes from the apptype being winexe though I'm not sure why it would behave differently when built on windows versus linux.

@tdykstra tdykstra added the waiting-on-feedback Waiting for feedback from SMEs before they can be merged label Mar 3, 2023
@abitzer
Copy link

abitzer commented Mar 6, 2023

I think this could be a side effect of: dotnet/runtime#3828

@dsplaisted
Copy link
Member

I think this could be a side effect of: dotnet/runtime#3828

That's correct. Currently EnableWindowsTargeting is more meant to allow you to check that your Windows-targeted code compiles correctly, so you can make changes on Mac OS or Linux and not have to worry as much about whether you've broken the Windows build.

For actually producing the app that will be shipped, you still should generally do that from a Windows OS. Fixing dotnet/runtime#3828 would be a good step, but even if we do that there might be other issues that prevent the output from a non-Windows build from being the same as when building on Windows.

@ali50m
Copy link
Contributor Author

ali50m commented Mar 7, 2023

I am not sure whether the original intention of this design is to allow users to compile programs for windows on different platforms. Judging from the problems reported by NETSDK1100, it seems to be so.

I think, if .net team can't make .net Windows program run cross-platform, but at least please make it cross-platform compiling, so that developers can easily use linux CI/CD to build release applications.

@curia-damiano
Copy link

The docs at https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#enablewindowstargeting state this:

Set the EnableWindowsTargeting property to true to build Windows apps (for example, Windows Forms or Windows Presentation Foundation apps) on a non-Windows platform. If you don't set this property to true, you'll get build warning NETSDK1100. This error occurs because targeting and runtime packs aren't automatically downloaded on platforms that aren't supported. By setting this property, those packs are downloaded when cross-targeting.

We could correct the docs into "to test the buildability of Windows apps... on a non-Windows platform".
But in the current state, the Windows build should run fine on Linux.

@dsplaisted
Copy link
Member

@tdykstra Per the discussion here, it would be good to update the docs for EnableWindowsTargeting to include something like this:

NOTE: This property is currently recommended to allow development on non-Windows platforms. The final application that is released should still be built on Windows. When building on a non-Windows platform, the output may not be the same as when building on Windows. In particular, the executable will not be marked as a Windows application (which means that it will always launch a console window) and won't have an icon embedded.

@tdykstra tdykstra added doc-enhancement Improve the current content [org][type][category] 🗺️ reQUEST Triggers an issue to be imported into Quest. and removed waiting-on-feedback Waiting for feedback from SMEs before they can be merged support-request Support-style question;customer needs help solving a problem [org][type][category] labels Mar 8, 2023
@ghost ghost added the in-pr This issue will be closed (fixed) by an active pull request. label Mar 8, 2023
@github-actions github-actions bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Mar 9, 2023
@ghost ghost removed the in-pr This issue will be closed (fixed) by an active pull request. label Mar 10, 2023
@alexrp
Copy link
Contributor

alexrp commented Aug 25, 2023

Note that this needs to be revisited after:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli/subsvc doc-enhancement Improve the current content [org][type][category] dotnet-fundamentals/svc Pri2 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants