Skip to content

Make EventLog work without .NETFramework#45884

Merged
8 commits merged intodotnet:masterfrom
ericstj:eventLogMessages
Dec 15, 2020
Merged

Make EventLog work without .NETFramework#45884
8 commits merged intodotnet:masterfrom
ericstj:eventLogMessages

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Dec 10, 2020

Fixes #27742

This adds a 772KB resource file to the package, however that file compresses down to 6KB in the package.

I chose to keep this as a separate file (as it was in .NETFramework) rather than just embed the resources in S.D.EventLog itself because the consumer for these resources is Windows/EventViewer which is a different process than that which is loading S.D.EventLog. This avoids increasing the memory footprint of the .NET app, however the disk footprint increases. We could consider making this opt-in via targets (which automatically opt-in for ARM64) if folks are concerned with it.

I also chose to keep the .NETFramework path as the default if the file is present, but would be open to hearing folks opinion on deleting this part of the code.

The method I chose for building the dll is similar to what is done for .resources.dlls in .NETCore. A separate invocation of CSC with only attributes, resources, and no other code.

I've tested this manually by mucking with my windows installation (takeown / icacls / move on .NETFramework copy) to simulate a SKU without .NETFramework. I still need to see if I can write some automated tests to cover this.

@ghost
Copy link

ghost commented Dec 10, 2020

Tagging subscribers to this area: @tommcdon, @krwq
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #27742

This adds a 772KB resource file to the package, however that file compresses down to 6KB in the package.

I chose to keep this as a separate file (as it was in .NETFramework) rather than just embed the resources in S.D.EventLog itself because the consumer for these resources is Windows/EventViewer which is a different process than that which is loading S.D.EventLog. This avoids increasing the memory footprint of the .NET app, however the disk footprint increases. We could consider making this opt-in via targets (which automatically opt-in for ARM64) if folks are concerned with it.

I also chose to keep the .NETFramework path as the default if the file is present, but would be open to hearing folks opinion on deleting this part of the code.

The method I chose for building the dll is similar to what is done for .resources.dlls in .NETCore. A separate invocation of CSC with only attributes, resources, and no other code.

I've tested this manually by mucking with my windows installation (takeown / icacls / move on .NETFramework copy) to simulate a SKU without .NETFramework. I still need to see if I can write some automated tests to cover this.

Author: ericstj
Assignees: -
Labels:

area-System.Diagnostics

Milestone: -

@ericstj
Copy link
Member Author

ericstj commented Dec 11, 2020

I plan to add tests for this.

  • Message DLL has no types in it
  • FormatMessage works using message DLL, ids 1 & 64k
  • Register event source and force it to use this message DLL (modify registry), write and read messages and make sure they do the right thing (and ensure the test would fail if they didn't)

@Anipik
Copy link
Contributor

Anipik commented Dec 14, 2020

@ericstj should we merge this one ?

@ericstj
Copy link
Member Author

ericstj commented Dec 14, 2020

I would like for others to weigh in on #45884 (comment).

Copy link
Member

@danmoseley danmoseley left a comment

Choose a reason for hiding this comment

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

LGTM. Did you run tests with the flag necessary to include XunitConstants.IgnoreForCI tests -- that CI won't run?

@ericstj
Copy link
Member Author

ericstj commented Dec 14, 2020

Did you run tests with the flag necessary to include XunitConstants.IgnoreForCI tests -- that CI won't run?

I ran these tests locally (including OuterLoop) on a Win10 machine. I double checked the results and it includes the IgnoreForCI tests: https://gist.github.com/ericstj/01683a2d902958108aa5e481fae70c05.

Also fix one test which would fail on machine without .NETFramework.
@ghost
Copy link

ghost commented Dec 15, 2020

Hello @ericstj!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

ericstj added a commit to ericstj/runtime that referenced this pull request Jan 5, 2021
* Make EventLog work without .NETFramework

* Use a project file instead of targets to create message DLL

* Add EventLogMessagesTests

* Address feedback

* Exclude EventLogMessage tests on net48

* Apply code review feedback

Also fix one test which would fail on machine without .NETFramework.

* Fix HelpLink test
Anipik added a commit that referenced this pull request Jan 14, 2021
* Make EventLog work without .NETFramework (#45884)

* Make EventLog work without .NETFramework

* Use a project file instead of targets to create message DLL

* Add EventLogMessagesTests

* Address feedback

* Exclude EventLogMessage tests on net48

* Apply code review feedback

Also fix one test which would fail on machine without .NETFramework.

* Fix HelpLink test

* Build EventLog package in servicing

Update assembly version of EventLog package and build it in
servicing.

Also update the package baseline to ensure that Windows.Compatibility
package gets the new version.

* Don't rev the platforms package unless we ship it

* Ensure we restore EventLog.Messages

5.0 infra doesn't traverse runtime-specific TFMs during restore.

Workaround by referencing Message project everywhere, and only
including it in package on windows.

Co-authored-by: Anirudh Agnihotry <anirudhagnihotry098@gmail.com>
@ghost ghost locked as resolved and limited conversation to collaborators Jan 14, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventLog without desktop framework installed results in "message is not found" logs in EventViewer

7 participants