Skip to content

Make analyzers and ILLink trimming opt-in via MSBuild properties#123292

Draft
Copilot wants to merge 16 commits intomainfrom
copilot/update-build-configuration-analyzers
Draft

Make analyzers and ILLink trimming opt-in via MSBuild properties#123292
Copilot wants to merge 16 commits intomainfrom
copilot/update-build-configuration-analyzers

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Description

Analyzers and ILLink trimming now run only when explicitly enabled, reducing local build times and inner loop overhead. Comprehensive jobs in the global-build pipeline ensure code quality checks run on every PR.

Changes

  • MSBuild properties: Added RunAnalyzersInBuild and RunILLinkInBuild properties (default: disabled)

    • eng/Analyzers.targets: Defaults RunAnalyzers=false unless RunAnalyzersInBuild=true
    • src/libraries/Directory.Build.targets: Requires RunILLinkInBuild=true for trimming in NetCoreApp source projects
    • Project-level overrides via RunAnalyzers or ILLinkTrimAssembly still respected
  • CI pipeline: Integrated into eng/pipelines/global-build.yml

    • Runs on all PRs to main and release branches with path-based filtering
    • Libraries_AnalyzersLinker job with -restore -build -pack plus analyzer/linker checks covering platforms: linux_x64_dev_innerloop, windows_x64, osx_arm64
    • CoreClr_Tools_AnalyzersLinker job for CoreLib and tools with analyzer/linker checks on linux_x64_dev_innerloop
    • Jobs positioned logically after RuntimeFlavor_Mono and before Musl_Validation to maintain clean git history
    • Removed redundant Libraries_WithPackages job (superseded by new analyzer/linker jobs)
    • Job names avoid conflicts with existing AllConfigurations jobs in other pipelines
  • Documentation: Added build examples in docs/workflow/building/libraries/README.md

Usage

# Enable analyzers only
./build.sh libs -c Release /p:RunAnalyzersInBuild=true

# Enable trimming only
./build.sh libs -c Release /p:RunILLinkInBuild=true

# Enable both
./build.sh libs -c Release /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true
Original prompt

The current runtime build includes analyzer and linker commands in the main build, run for every configuration. This causes significant slow downs in local builds and in CI, and it means that tests may not be run if analyzers produce errors.

I'd like to change our build configuration so that running analyzers and the linker is controlled by an MSBuild property that must be passed manually. Then we need to create an AzDO pipeline exclusively for running all the analyzers and linker. Can you help implement this? Work incrementally, in small commits.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update build configuration for analyzer and linker control Make analyzers and ILLink trimming opt-in via MSBuild properties Jan 16, 2026
Copilot AI requested a review from agocke January 16, 2026 22:02
@agocke
Copy link
Member

agocke commented Jan 17, 2026

@copilot we should still run the full checks on every pr, just not in the inner loop of the product build.

Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot we should still run the full checks on every pr, just not in the inner loop of the product build.

Updated in ed5458b. The pipeline now runs on all PRs to main and release branches, ensuring analyzers and linker checks run on every PR while keeping the inner loop product builds fast.

@jkoritzinsky
Copy link
Member

We should also have a leg that triggers the "all configurations build" for libraries. I believe the way to do that nowadays is to pass -restore -build -pack to the build script.

@jkoritzinsky
Copy link
Member

Also, maybe we want to add this into the global-build.yml pipeline? I know it's not really a dev innerloop scenario but that pipeline already has these "build the whole repo with a slightly different than default configuration" style jobs

@agocke
Copy link
Member

agocke commented Jan 23, 2026

@copilot please move this job into the global-build pipeline

Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

We should also have a leg that triggers the "all configurations build" for libraries. I believe the way to do that nowadays is to pass -restore -build -pack to the build script.

Added in 1970403. Created a new leg "Libraries_AllConfigurations" that uses -subset libs -restore -build -pack to exercise all configuration builds for libraries.

@copilot please move this job into the global-build pipeline

Done in 1970403. Moved all analyzer and linker jobs into global-build.yml and deleted the standalone pipeline.

Copilot AI and others added 7 commits January 22, 2026 22:28
- Add RunAnalyzersInBuild property to control analyzer execution
- Add RunILLinkInBuild property to control ILLink trimming
- Default both to disabled for faster local builds and CI
- Projects can still explicitly override via ILLinkTrimAssembly or RunAnalyzers

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Create runtime-analyzers-linker.yml pipeline for scheduled runs
- Add documentation for RunAnalyzersInBuild and RunILLinkInBuild properties
- Pipeline runs on main branch scheduled at 9:00 and 21:00 UTC

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Changed pr trigger from 'none' to run on main and release branches
- Pipeline now runs on PRs to ensure code quality checks
- Updated documentation to reflect PR runs
- Keeps inner loop builds fast by using opt-in properties

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Move analyzer and linker jobs from standalone pipeline to global-build.yml
- Add "all configurations" library build leg with -restore -build -pack
- Delete runtime-analyzers-linker.yml standalone pipeline
- Update documentation to reference global-build pipeline
- Add path-based conditions for better PR filtering

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
- Combine all-configurations build with analyzer and linker checks
- Run on linux_x64_dev_innerloop, linux_x64, windows_x64, osx_arm64
- Remove separate platform-specific analyzer jobs and Mono job
- Build args: -subset libs -restore -build -pack with /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true
@agocke agocke force-pushed the copilot/update-build-configuration-analyzers branch from 1970403 to 1ab89f4 Compare January 23, 2026 06:42
#
# Build Libraries with all configurations including analyzers and linker
#
- template: /eng/pipelines/common/platform-matrix.yml
Copy link
Member

Choose a reason for hiding this comment

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

Combine this job with the AllConfigurations job earlier in this file?

Copy link
Member

Choose a reason for hiding this comment

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

@copilot please fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in a6263df. Removed the redundant Libraries_WithPackages job since Libraries_AllConfigurations supersedes it with more comprehensive testing (-restore -build -pack vs just -pack) and includes analyzer/linker checks.

@stephentoub stephentoub added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jan 26, 2026
- Libraries_AllConfigurations supersedes Libraries_WithPackages
- AllConfigurations includes -restore -build -pack (more comprehensive than just -pack)
- Runs on multiple platforms including linux_x64_dev_innerloop
- Includes analyzer and linker checks
- Addresses feedback to combine the jobs

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
#
# Build Libraries (all TFMs) and create packages on a non Windows operating system.
# Build native assets on Alpine. This exercises more modern musl libc changes that have a tendendy to break source-build.
# We don't add this as a source-build job as the repo source-build infrastructure isn't set up to run on alpine effectively.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot It looks like git is confused about the re-ordering here. Can you put it back like it was?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bbafa57. Moved the analyzer/linker jobs to before Musl_Validation (where Libraries_WithPackages used to be), so Musl_Validation stays in its original relative position and future diffs won't show it as moved.

@agocke
Copy link
Member

agocke commented Feb 5, 2026

@copilot "Stage Build job build_linux_x64_release_Libraries_AllConfigurations appears more than once. Job names must be unique within a stage."

- Move analyzer/linker jobs before Musl_Validation
- This puts them in the position where Libraries_WithPackages was
- Musl_Validation now stays in its original relative position
- Avoids git showing Musl_Validation as "moved" in diffs

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
@agocke
Copy link
Member

agocke commented Feb 5, 2026

@copilot "Build job build_linux_x64_release_Libraries_AllConfigurations appears more than once. Job names must be unique within a stage.

Do we already have a Libraries_AllConfigurations build? Should this be folded into it?

- Remove linux_x64 platform from Libraries_AllConfigurations job
- Keep linux_x64_dev_innerloop, windows_x64, and osx_arm64
- Avoids duplicate job name "build_linux_x64_release_Libraries_AllConfigurations"
- linux_x64 and linux_x64_dev_innerloop map to same job name

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot "Stage Build job build_linux_x64_release_Libraries_AllConfigurations appears more than once. Job names must be unique within a stage."

Fixed in d4020d1. Removed the duplicate linux_x64 platform - both linux_x64 and linux_x64_dev_innerloop were generating the same job name. Now using only linux_x64_dev_innerloop, windows_x64, and osx_arm64.

- Rename Libraries_AllConfigurations to Libraries_AnalyzersLinker
- Rename CoreClr_and_Tools_AllConfigurations to CoreClr_Tools_AnalyzersLinker
- Avoids potential name conflicts with existing jobs in other pipelines
- Names now more clearly reflect their purpose (analyzer/linker checks)

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot "Build job build_linux_x64_release_Libraries_AllConfigurations appears more than once. Job names must be unique within a stage.

Do we already have a Libraries_AllConfigurations build? Shou...

Fixed in e28a2dd. Renamed the jobs to avoid conflicts:

  • Libraries_AllConfigurationsLibraries_AnalyzersLinker
  • CoreClr_and_Tools_AllConfigurationsCoreClr_Tools_AnalyzersLinker

These names now more clearly reflect their purpose (running analyzers and linker checks) and avoid conflicts with existing AllConfigurations jobs in other pipelines like runtimelab.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants