dotnet / dotnet/msbuild

Option to run target once per project in multi-targeting build

Open
#2,781 8 comments 17 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

I'm trying to generate some additional sources for multi-targeting project (with TargetFrameworks).
Sources will be the same for both TargetFramework. When I attach my target with BeforeTargets to BeforeBuild, it will be executed twice - and with /m switch it may fail as both will try to generate same file.
I've tried to solve it by moving it to BeforeTargets DispatchToInnerBuilds and target really executed only once at correct time with 1-project solution. When solution contains more than one project and they reference, build could be started from ResolveReference target of other project. In that way it will be run in parallel with my source-generating target, which is not what I want.

Is there any way to run target only once in multi-targeting project and still be sure, that all compile-related task will be executed only after it?

I could provide sample application if it help.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.