Skip to content

[release/6.0] Support Single-file executable in Windows 7 - #63533

Merged
safern merged 2 commits into
dotnet:release/6.0from
NN---:6.0
Feb 7, 2022
Merged

[release/6.0] Support Single-file executable in Windows 7#63533
safern merged 2 commits into
dotnet:release/6.0from
NN---:6.0

Conversation

@NN---

@NN---NN--- commented Jan 8, 2022

Copy link
Copy Markdown
Contributor

Backport #63196 to .NET 6.0

Customer Impact

As of .NET 6.0 single file apps are not supported on Windows7.
A 6.0 singlefile app does not include API set files (api-ms-win-... files). It was assumed that the apps cannot run without bundling/extracting these files due to various dependencies.

Turns out the actual API set requirements of .NET runtime are very modest. We only use UCRT and WinRT API sets.

  • UCRT, if present, is known to the loader and does not need API set files
  • WinRT API is used to initialize WinRT and only if WinRT is present and detected by a dynamic check.

So the real reason why 6.0 singlefile app does not run on Windows7 is because api-ms-win-core-winrt-l1-1-0.dll is eagerly loaded, even though it would not be used.

Making api-ms-win-core-winrt-l1-1-0.dll delayloaded in singlefilehost enables apps to run. That would also match the behavior of standalone coreclr.dll where api-ms-win-core-winrt-l1-1-0.dll is also delayloaded.

Basically, with this change, instead of not supporting singlefile apps on Windows7, we can support, as long as SP1 and UCRT are installed, which is reasonable expectation and SP1 is already a requirement.

Testing

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

I've tried:

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

Risk

Risk is low.
Currently .net 6.0 singlefile apps do not run on Windows7 at all, so it can't get worse.
For other versions of Windows, singlefile app will just match closer the delayload behavior of standalone coreclr.dll.

@ghostghost added area-Single-File community-contribution Indicates that the PR has been added by a community member labels Jan 8, 2022
@ghost

ghost commented Jan 8, 2022

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

Backport #63196 to .NET 6.0

Author:NN---
Assignees:-
Labels:

area-Single-File

Milestone:-

@VSadovVSadov self-assigned this Jan 8, 2022
@VSadovVSadov changed the title Support Single-file executable in Windows 7 (.NET 6.0)[release/6.0] Support Single-file executable in Windows 7Jan 8, 2022
@VSadov

Copy link
Copy Markdown
Member

CC: @agocke

@VSadov

Copy link
Copy Markdown
Member

I have tested the release/6.0 changes and they unblock 6.0 singlefile apps on Windows7, as expected.

@VSadovVSadov added the Servicing-consider Issue for next servicing release review label Jan 10, 2022

@jeffschwMSFTjeffschwMSFT 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.

Approved. We should take for consideration in 6.0.x. We will need to ensure to get a code review from the owning area and look at the CI failures.

@jeffschwMSFTjeffschwMSFT removed the Servicing-consider Issue for next servicing release review label Jan 11, 2022
@agocke
agocke requested a review from VSadovJanuary 11, 2022 18:06
@agocke

Copy link
Copy Markdown
Member

@VSadov How confident are we that this will solve all problems for win7?

@VSadov

VSadov commented Jan 11, 2022

Copy link
Copy Markdown
Member

@agocke It fixes the known problem - it no longer requires api-ms-win-core-winrt-l1-1-0.dll be present, by delay-loading it. We use it conditionally only if winrt is available, and Windows7 does not have it.
That is the only API set besides UCRT that singlefilehost.exe requires.

 Image has the following dependencies:
KERNEL32.dll
ADVAPI32.dll
ole32.dll
OLEAUT32.dll
USER32.dll
VERSION.dll
SHELL32.dll
api-ms-win-core-winrt-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll

The crt API sets are known to the OS loader and the actual implementation is loaded instead, assuming that UCRT is installed, which we should document as a requirement on Windows 7, but it is a reasonable assumption.

Considering that a WPF app runs with this fix, a lot of other apps will run.
Next to not being able to run any kind of singlefile app, this is definitely an improvement.

@NN---

Copy link
Copy Markdown
ContributorAuthor

@VSadov .NET 5 already requires UCRT in Windows 7.
There is nothing changed here.

@agockeagocke added the Servicing-consider Issue for next servicing release review label Jan 20, 2022
@leecowleecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jan 20, 2022
@leecowleecow added this to the 6.0.3 milestone Jan 20, 2022
@NN---

Copy link
Copy Markdown
ContributorAuthor

@leecow The SDK fix is mandatory for publishing: dotnet/sdk#23336

@agocke

Copy link
Copy Markdown
Member

If we can't bring the SDK fix in in time, users can also use the win-x64 RID until the next update.

@NN---

Copy link
Copy Markdown
ContributorAuthor

The SDK fix is merely removing the warning and string resources.
Currently main and 6.0.3xx branch don't build successfully.
This why PR is failing right now.

@safern
safern merged commit d3213e3 into dotnet:release/6.0Feb 7, 2022
@NN---
NN--- deleted the 6.0 branch February 7, 2022 19:02
@ghostghost locked as resolved and limited conversation to collaborators Mar 10, 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-approvedApproved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@NN---@VSadov@agocke@jeffschwMSFT@leecow@safern