Skip to content

Conversation

@NN---
Copy link
Contributor

@NN--- NN--- commented Dec 29, 2021

Windows 7 doesn't have WinRT API set, making it delay loaded allows running single file executable in Windows 7.
dotnet/sdk#23177

.NET code already performs late binding in utils.cpp and in mscoree CMakeLists.txt .
But not for singlefilehost.exe

The final change should be backported since .NET 6 is the latest LTS version.

@ghost
Copy link

ghost commented Dec 29, 2021

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

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 29, 2021
@NN--- NN--- changed the title Delay load winrt Support Single-file executable in Windows 7 Dec 29, 2021
@NN--- NN--- marked this pull request as ready for review December 29, 2021 19:24
@ghost
Copy link

ghost commented Dec 30, 2021

Tagging subscribers to this area: @agocke, @vitek-karas, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Windows 7 doesn't have WinRT API set, making it delay loaded allows running single file executable in Windows 7.
dotnet/sdk#23177

.NET code already performs late binding in utils.cpp and in mscoree CMakeLists.txt .
But not for singlefilehost.exe

Author: NN---
Assignees: -
Labels:

area-Single-File, community-contribution

Milestone: -

@NN---
Copy link
Contributor Author

NN--- commented Jan 4, 2022

@jkoritzinsky Is there anything preventing this PR to be merged ? Is it possible to backport it to .NET 6 ?

@vitek-karas vitek-karas requested a review from VSadov January 5, 2022 10:10
@vitek-karas
Copy link
Member

@VSadov could you please review this as well?

My main concern is if this is enough. The single-file superhost statically links several other native libs from the runtime, do any of those have a similar problem?

@NN---
Copy link
Contributor Author

NN--- commented Jan 5, 2022

Comparing .NET 5 and .NET 6 single file output, the API set WinRT is the only difference as far as I have seen.
Of course in order to build a single file with Windows 7 runtime identifier I had to remove the RID check in the .NET SDK.

I couldn't figure why the same code doesn't make a statically loaded API set in previous versions.
The code calling RoInitialize in threads.cpp hasn't been changed for years.

@VSadov VSadov self-assigned this Jan 6, 2022
@VSadov
Copy link
Member

VSadov commented Jan 7, 2022

The change looks good. I just need to try the end-to-end scenario with an app running on actual Windows7.

@VSadov
Copy link
Member

VSadov commented Jan 8, 2022

I have verified that with this fix singlefile apps run on Windows7 SP1

I've tried:

  • default console app
  • default wpf app
  • default wpf app with IncludeNativeLibrariesForSelfExtract

@VSadov
Copy link
Member

VSadov commented Jan 8, 2022

BTW. The OS image that I used is fairly minimal, but it looks like it has UCRT (i.e. ucrtbse.dll is present). It was likely installed with some of the updates.

Since UCRT is not a part of OS, it might need to be documented as a requirement on Win7. It is still better than not running at all.

Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NN--- : Thanks!!!

@VSadov VSadov merged commit 92f547a into dotnet:main Jan 8, 2022
@VSadov VSadov added the Servicing-consider Issue for next servicing release review label Jan 8, 2022
@NN---
Copy link
Contributor Author

NN--- commented Jan 8, 2022

Great news!
Can you backport it to .NET 6?
Should I open PR for it?

There is also a small issue with .NET SDK as I mentioned.
The targets file preventing build for Windows 7 RID.
I proposed replacing error with warning, probably better to not show anything and declare single file for Windows 7 as supported.
What do you think ?

@VSadov
Copy link
Member

VSadov commented Jan 8, 2022

Can you backport it to .NET 6?
Should I open PR for it?

There is a bit more process for servicing changes to LTS branch. That is intentional to ensure it is stable.
I will follow up with backporting once we see no issues in main.

We will get to the error/warning too.
Thanks for making this change!

@NN---
Copy link
Contributor Author

NN--- commented Jan 8, 2022

I opened relevant PRs for SDK and 6.0 branch. Without SDK fix, the publishing still fails.
It would be wonderful to have single-file support back in .NET 6 LTS.
My assumption is that not only me who needs this useful feature.

@NN---
Copy link
Contributor Author

NN--- commented Jan 8, 2022

BTW. The OS image that I used is fairly minimal, but it looks like it has UCRT (i.e. ucrtbse.dll is present). It was likely installed with some of the updates.

.NET already requires Windows 7 SP1.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Single-File community-contribution Indicates that the PR has been added by a community member Servicing-consider Issue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants