Skip to content

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

Open
filzrev wants to merge 2 commits 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 2 commits 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 2 times, most recently from 750d31b to fed0ce3 Compare July 12, 2026 01:20
@timcassell

Copy link
Copy Markdown
Collaborator
  • ImportDirectoryBuildProps/ImportDirectoryBuildTargets are disabled.
    So there is no way to use custom setting when build original benchmark project.

Removed in #3196.

  • Set project specific MSBuild settings.

What do you mean? Each toolchain already sets project-specific settings.

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

Can you make that change in the same PR?

I'm uncomfortable merging this without a use.

Also you missed the NativeAot generator that has its template in source.

@filzrev filzrev force-pushed the feat-add-build-customization-via-props-targets branch from fed0ce3 to 753a071 Compare July 15, 2026 14:57
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.

2 participants