Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/workflow/building/libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,27 @@ One can build in Debug or Release mode from the root by doing `./build.sh libs -

One can build 32- or 64-bit binaries or for any architecture by specifying in the root `./build.sh libs -arch [value]` or in a project `/p:TargetArchitecture=[value]` after the `dotnet build` command.

### Building with Analyzers and Linker

By default, code analyzers and ILLink trimming are disabled during local builds and CI to improve build performance. To enable these features during a build, pass the following properties:

- **Analyzers**: To run code analyzers during the build, use `/p:RunAnalyzersInBuild=true`:
```bash
./build.sh libs -c Release /p:RunAnalyzersInBuild=true
```

- **ILLink Trimming**: To run ILLink trimming during the build, use `/p:RunILLinkInBuild=true`:
```bash
./build.sh libs -c Release /p:RunILLinkInBuild=true
```

- **Both**: To enable both analyzers and trimming:
```bash
./build.sh libs -c Release /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true
```

These features are automatically run in the global-build CI pipeline for all PRs to ensure code quality without impacting regular build times. Individual projects can still override these settings by explicitly setting `RunAnalyzers` or `ILLinkTrimAssembly` properties in their project files.

## Working in Visual Studio

If you are working on Windows, and use Visual Studio, you can open individual libraries projects into it. From within Visual Studio you can then build, debug, and run tests.
Expand Down
5 changes: 5 additions & 0 deletions eng/Analyzers.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<Project>
<PropertyGroup>
<!-- By default, analyzers are disabled to speed up local builds and CI.
Set RunAnalyzersInBuild=true to enable analyzers during the build. -->
<RunAnalyzers Condition="'$(RunAnalyzers)' == '' and '$(RunAnalyzersInBuild)' != 'true'">false</RunAnalyzers>
</PropertyGroup>
<PropertyGroup Condition="'$(UsingMicrosoftNoTargetsSdk)' == 'true' or
'$(UsingMicrosoftDotNetSharedFrameworkSdk)' == 'true' or
'$(MSBuildProjectExtension)' == '.pkgproj' or
Expand Down
21 changes: 21 additions & 0 deletions eng/pipelines/global-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ extends:
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
eq(variables['isRollingBuild'], true))

#
# 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?

parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: release
platforms:
- linux_x64_dev_innerloop
- linux_x64
- windows_x64
- osx_arm64
jobParameters:
nameSuffix: Libraries_AllConfigurations
buildArgs: -subset libs -restore -build -pack -c $(_BuildConfig) /p:RunAnalyzersInBuild=true /p:RunILLinkInBuild=true
timeoutInMinutes: 120
condition:
or(
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true),
eq(variables['isRollingBuild'], true))

#
# Build Repo SourceBuild
#
Expand Down
5 changes: 4 additions & 1 deletion src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@
'$(TargetFrameworkVersion)' == 'v$(NetCoreAppCurrentVersion)' and
('$(IsNETCoreAppRef)' == 'true' or '$(IsNETCoreAppSrc)' == 'true')">true</DisableImplicitFrameworkReferences>
<!-- Enable trimming for any source project that's part of the shared framework.
Don't attempt to trim PNSE assemblies which are generated from the reference source. -->
Don't attempt to trim PNSE assemblies which are generated from the reference source.
By default, trimming is disabled to speed up local builds and CI.
Set RunILLinkInBuild=true to enable trimming during the build. -->
<ILLinkTrimAssembly Condition="'$(ILLinkTrimAssembly)' == '' and
'$(RunILLinkInBuild)' == 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(IsNETCoreAppSrc)' == 'true' and
'$(GeneratePlatformNotSupportedAssembly)' != 'true' and
Expand Down