-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[docs] description of changes for the binary logger to work with a new event #10773
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
Merged
YuliiaKovalova
merged 2 commits into
dotnet:main
from
JanProvaznik:dev/janpro/docs-add-event-binlog
Oct 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Adding Custom Events to MSBuild | ||
|
|
||
| MSBuild has many built-in event types, but often you may need to add a new custom one. | ||
|
|
||
| ## Steps for Binary Logger Compatibility | ||
| This guide outlines the steps to ensure the BinaryLogger can work with your new event. | ||
|
|
||
| ### Changes in MSBuild | ||
|
|
||
| 1. **Add the `NewEventArgs` to `src/Framework` folder** | ||
|
|
||
| 2. **Update [BinaryLogRecordKind.cs](https://github.com/dotnet/msbuild/blob/main/src/Build/Logging/BinaryLogger/BinaryLogRecordKind.cs)** | ||
| - Add the new event to the enum | ||
JanProvaznik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 3. **Modify [BinaryLogger.cs](https://github.com/dotnet/msbuild/blob/main/src/Build/Logging/BinaryLogger/BinaryLogger.cs)** | ||
| - Update `FileFormatVersion` | ||
|
|
||
| 4. **Update [BuildEventArgsReader.cs](https://github.com/dotnet/msbuild/blob/main/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs)** | ||
| - Add a new case in the `HandleError` switch | ||
| - Implement the method (imitate other `ReadEventArgs` methods) | ||
|
|
||
| 5. **Modify [BuildEventArgsWriter.cs](https://github.com/dotnet/msbuild/blob/main/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs)** | ||
| - Add a new case in `WriteCore` | ||
| - Document the change above the method | ||
|
|
||
| 6. **Update [LogMessagePacketBase.cs](https://github.com/dotnet/msbuild/blob/main/src/Shared/LogMessagePacketBase.cs)** | ||
| - Add to `LoggingEventType` | ||
| - Add case in `GetBuildEventArgFromId` and `GetLoggingEventId` | ||
|
|
||
| 7. **Create a new test file** | ||
| - Add `Framework.UnitTests/NewEventArgs_Tests.cs` | ||
| - Use [BuildSubmissionStartedEventArgs_Tests.cs](https://github.com/dotnet/msbuild/blob/main/src/Framework.UnitTests/BuildSubmissionStartedEventArgs_Tests.cs) as a reference | ||
|
|
||
| 8. **Update [NodePackets_Tests.cs](https://github.com/dotnet/msbuild/blob/main/src/Build.UnitTests/BackEnd/NodePackets_Tests.cs)** | ||
| - Add relevant test cases | ||
|
|
||
| ### Changes in [MSBuildStructuredLog](https://github.com/KirillOsenkov/MSBuildStructuredLog) | ||
|
|
||
| 1. **Update [BinaryLogRecordKind.cs](https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/BinaryLogger/BinaryLogRecordKind.cs)** | ||
| - Add the new event to the enum | ||
|
|
||
| 2. **Modify [BinaryLogger.cs](https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/BinaryLogger/BinaryLogger.cs)** | ||
| - Increment version | ||
| - Document the change | ||
|
|
||
| 3. **Create `src/StructuredLogger/BinaryLogger/XXXEventArgs.cs`** | ||
| - Implement the class for the new event (copy from MSBuild) | ||
|
|
||
| 4. **Update [BuildEventArgsReader.cs](https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs)** | ||
| - Add a new case in `ReadBuildEventArgs` | ||
|
|
||
| 5. **Modify [BuildEventArgsWriter.cs](https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/BinaryLogger/BuildEventArgsWriter.cs)** | ||
| - Add a new case in `WriteCore` | ||
|
|
||
| ### Example Pull Requests adding adding and serializing events | ||
|
|
||
| Here are some example PRs that demonstrate adding binary log support: | ||
|
|
||
| 1. [Add Buildcheck events support + BuildSubmissionStarted](https://github.com/KirillOsenkov/MSBuildStructuredLog/pull/797) (MSBuildStructuredLog) | ||
| - Corresponding [MSBuild PR](https://github.com/dotnet/msbuild/pull/10424) | ||
|
|
||
| 2. [Add Binary Logger Support for BuildCanceled](https://github.com/dotnet/msbuild/pull/10755) (MSBuild) | ||
| - Corresponding [MSBuildStructuredLog PR](https://github.com/KirillOsenkov/MSBuildStructuredLog/pull/824) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.