-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add documentation for enabling binlog collection via env var #12805
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
Open
YuliiaKovalova
wants to merge
7
commits into
main
Choose a base branch
from
dev/ykovalova/binlog_env_var_spec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+158
−0
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1f96d76
Add documentation for enabling binlog collection via env var
YuliiaKovalova e77a44d
Merge branch 'main' into dev/ykovalova/binlog_env_var_spec
YuliiaKovalova 30fb3e8
Merge branch 'main' into dev/ykovalova/binlog_env_var_spec
YuliiaKovalova e7a7da1
fix review comments
YuliiaKovalova 3ed3407
more cleanup
YuliiaKovalova 7758473
fix comments
YuliiaKovalova aa0328a
add more info
YuliiaKovalova 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
113 changes: 113 additions & 0 deletions
113
documentation/specs/enable-binlog-collection-by-env-var
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,113 @@ | ||
| ## Purpose | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Enable binary logging in CI/CD pipelines when `-noAutoResponse` blocks response files, without modifying build scripts or project files. | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Supported Arguments | ||
|
|
||
| - `-bl` / `/bl` / `-binarylogger` / `/binarylogger` (with optional parameters) | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `-check` / `/check` (with optional parameters - requires code modification to support `deferred` mode) | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **All other switches are blocked** as security risks. These two switches are diagnostic/monitoring tools that don't affect build behavior or enable code execution. | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Argument Processing Order | ||
|
|
||
| 1. **MSBuild.rsp** (next to MSBuild.exe) - skipped if `-noAutoResponse` present | ||
| 2. **Directory.Build.rsp** (next to project) - skipped if `-noAutoResponse` present | ||
| 3. **MSBUILD_LOGGING_ARGS** - always processed, regardless of `-noAutoResponse` | ||
| 4. **Command-line arguments** - highest precedence | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The environment variable is processed **after** checking for `-noAutoResponse`, making it a reliable fallback when response files are disabled. | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Parameter Merging | ||
|
|
||
| ### Challenge | ||
|
|
||
| Multiple sources can specify the same argument type (e.g., `-bl` from both environment variable and command line). MSBuild must determine how to handle conflicts. | ||
|
|
||
| ### Merging Strategy | ||
|
|
||
| **Binary Logger (-bl)** | ||
| - Multiple `-bl` arguments are **allowed and cumulative** | ||
| - Each creates a separate binlog file | ||
| - Example: `MSBUILD_LOGGING_ARGS=-bl:env.binlog` + command line `-bl:cmd.binlog` → both files created | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **Build Check (-check)** | ||
| - Multiple `-check` arguments are **merged** | ||
| - Later specifications override earlier ones for the same check | ||
| - Example: `MSBUILD_LOGGING_ARGS=-check:deferred` + command line `-check` (immediate) → immediate mode wins | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Precedence for Conflicts | ||
|
|
||
| When the same parameter is specified in multiple locations: | ||
|
|
||
| 1. Command-line arguments (highest priority) | ||
| 2. MSBUILD_LOGGING_ARGS environment variable | ||
| 3. Directory.Build.rsp | ||
| 4. MSBuild.rsp (lowest priority) | ||
|
|
||
| **Implementation Note**: MSBuild's existing argument parser handles merging logic. The environment variable arguments are prepended to the command line before parsing, ensuring natural precedence. | ||
|
|
||
| ## Implementation Flow | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. MSBuildApp.Execute() called | ||
| 2. Check for `-noAutoResponse` in command line | ||
| 3. Process response files (if no `-noAutoResponse`) | ||
| 4. Read MSBUILD_LOGGING_ARGS environment variable | ||
| 5. Validate and filter arguments | ||
| 6. Prepend valid arguments to command line | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 7. **Parse combined command line** (merging happens here) | ||
| 8. Execute build | ||
|
|
||
| ## Warning Messages | ||
|
|
||
| All issues are logged as **warnings**, never errors. Builds must not fail due to environment variable processing. | ||
baronfel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Informational**: "Using arguments from MSBUILD_LOGGING_ARGS environment variable: {0}" | ||
| - **Rejected Argument**: "MSBUILD_LOGGING_ARGS: Ignoring unsupported argument '{0}'. Only -bl and -check arguments are allowed." | ||
| - **Processing Error**: "Error processing MSBUILD_LOGGING_ARGS environment variable: {0}" | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Build Check (-check) Handling | ||
|
|
||
| ### Deferred Analysis Mode | ||
|
|
||
| `-check:deferred` enables binlog replay analysis without build-time overhead: | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **During build**: Flag recorded in binlog, BuildCheck NOT activated | ||
| - **During replay**: Binlog reader activates BuildCheck for analysis | ||
|
|
||
| **Rationale**: BuildCheck analysis can be expensive. Environment variable is for diagnostics that can be analyzed later, allowing teams to record data without performance impact. | ||
|
|
||
| ### Example Workflow | ||
|
|
||
| ```bash | ||
| # 1. Configure environment | ||
| set MSBUILD_LOGGING_ARGS=-bl:build.binlog -check:deferred | ||
|
|
||
| # 2. Run build (normal speed, no BuildCheck overhead) | ||
| msbuild solution.sln | ||
|
|
||
| # 3. Later: Replay binlog (BuildCheck analyzes recorded events) | ||
| msbuild build.binlog | ||
| ``` | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## CI/CD Integration | ||
|
|
||
| ### Approach A: Response File (Traditional) | ||
| - Create `Directory.Build.rsp` with binlog argument | ||
| - Might be blocked by `-noAutoResponse` | ||
|
|
||
| ### Approach B: Environment Variable (New) | ||
| - Set `MSBUILD_LOGGING_ARGS=-bl:build.binlog` | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Works with `-noAutoResponse` | ||
| - No file creation needed | ||
|
|
||
| ### Combining Both Approaches | ||
|
|
||
| ```bash | ||
| # Environment provides base logging | ||
| set MSBUILD_LOGGING_ARGS=-bl:base.binlog -check:deferred | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Command line adds specific logging | ||
| msbuild solution.sln -bl:detailed.binlog | ||
|
|
||
| # Result: Two binlog files created (base.binlog + detailed.binlog) | ||
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.