Skip to content

Support Single-file executable in Windows 7 - #63196

Merged
VSadov merged 1 commit into
dotnet:mainfrom
NN---:win7
Jan 8, 2022
Merged

Support Single-file executable in Windows 7#63196
VSadov merged 1 commit into
dotnet:mainfrom
NN---:win7

Conversation

@NN---

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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.

@ghostghost 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 winrtSupport Single-file executable in Windows 7Dec 29, 2021
@NN---
NN--- marked this pull request as ready for review December 29, 2021 19:24
@ghost

Copy link
Copy Markdown

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---

NN--- commented Jan 4, 2022

Copy link
Copy Markdown
ContributorAuthor

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

@vitek-karas

Copy link
Copy Markdown
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---

NN--- commented Jan 5, 2022

Copy link
Copy Markdown
ContributorAuthor

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.

@VSadovVSadov self-assigned this Jan 6, 2022
@VSadov

Copy link
Copy Markdown
Member

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

@VSadov

VSadov commented Jan 8, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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.

@VSadovVSadov left a comment

Copy link
Copy Markdown
Member

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:mainJan 8, 2022
@VSadovVSadov added the Servicing-consider Issue for next servicing release review label Jan 8, 2022
@NN---

NN--- commented Jan 8, 2022

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Member

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---

NN--- commented Jan 8, 2022

Copy link
Copy Markdown
ContributorAuthor

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---

NN--- commented Jan 8, 2022

Copy link
Copy Markdown
ContributorAuthor

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.

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

Labels

community-contributionIndicates that the PR has been added by a community memberServicing-considerIssue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@NN---@vitek-karas@VSadov@jkoritzinsky@danmoseley