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

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

Merged
merged 2 commits into from
Feb 7, 2022
Merged

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

merged 2 commits into from
Feb 7, 2022

Conversation

NN---
Copy link
Contributor

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

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.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jan 8, 2022
@ghost
Copy link

ghost commented Jan 8, 2022

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

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

VSadov commented Jan 8, 2022

CC: @agocke

@VSadov
Copy link
Member

VSadov commented Jan 10, 2022

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

@VSadov VSadov added the Servicing-consider Issue for next servicing release review label Jan 10, 2022
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

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.

@jeffschwMSFT jeffschwMSFT removed the Servicing-consider Issue for next servicing release review label Jan 11, 2022
@agocke agocke requested a review from VSadov January 11, 2022 18:06
@agocke
Copy link
Member

agocke commented Jan 11, 2022

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

@VSadov
Copy link
Member

VSadov commented Jan 11, 2022

@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
Contributor Author

NN--- commented Jan 19, 2022

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

@agocke agocke added the Servicing-consider Issue for next servicing release review label Jan 20, 2022
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jan 20, 2022
@leecow leecow added this to the 6.0.3 milestone Jan 20, 2022
@NN---
Copy link
Contributor Author

NN--- commented Jan 24, 2022

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

@agocke
Copy link
Member

agocke commented Jan 24, 2022

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

NN--- commented Jan 24, 2022

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.0 Feb 7, 2022
@NN--- NN--- deleted the 6.0 branch February 7, 2022 19:02
@ghost ghost locked as resolved and limited conversation to collaborators Mar 10, 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-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants