Skip to content

feat: add custom props/targets to customize project build#3195

Open
filzrev wants to merge 1 commit into
dotnet:masterfrom
filzrev:feat-add-build-customization-via-props-targets
Open

feat: add custom props/targets to customize project build#3195
filzrev wants to merge 1 commit into
dotnet:masterfrom
filzrev:feat-add-build-customization-via-props-targets

Conversation

@filzrev

@filzrev filzrev commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

This PR add infrastructure to customize build with props/targets on CsProj based toolchain.

Background

Existing implementation have following limitations.

  • ImportDirectoryBuildProps/ImportDirectoryBuildTargets are disabled.
    So there is no way to use custom setting when build original benchmark project.
  • When using /p: command line parameter. it's handled as global property and it's applied to all dependent projects.
    It need a way to set MsBuild property to specific project.
  • Ther is no generic way to add custom MSBuild target to all CsProj based toolchain.

What's changed in this PR

1. Add custom props/targets template files
Following template files are added. (Currently, no settings are contained)

  • BenchmarkDotNet.Build.props.txt
  • BenchmarkDotNet.Build.targets.txt

These files expected to be used for following purposes.

  • Set project specific MSBuild settings.
  • Add custom MSBuild target. (e.g. DllGather targets without project build)

2. GeneratorBase.cs
Add GenerateCustomBuildHooksAsync virtual API and invoke on GenerateProjectAsync.
This API is used for generate custom props/targets files that are used on project build.

3. CsProjGenerator.cs.cs
Add GenerateCustomBuildHooksAsync API implementation.

Additionally, some fixed project names are refactored to constant field.

4. Other Templates/*.txt project templates
Add import for props/targets and apply code formatter.

@filzrev filzrev force-pushed the feat-add-build-customization-via-props-targets branch from 43598ba to 750d31b Compare July 11, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant