- Notifications
You must be signed in to change notification settings - Fork1.4k
Is there a way to run an MSBuild target before the first project or after the last project?#8074
-
We have a use case where we want to run some pre-build or post-build logic for the entire solution. Is there a way to do this via an MSBuild Task? |
BetaWas this translation helpful?Give feedback.
All reactions
Yes:https://learn.microsoft.com/visualstudio/msbuild/customize-your-build#customize-the-solution-build. However, it may not do what you want, since it doesn't apply in Visual Studio.
You may instead want to use aDirectory.Build.targets to inject a target into every project, and inside that target use theMSBuild task to build a project that contains your pre-build logic.
Replies: 1 comment 3 replies
-
Yes:https://learn.microsoft.com/visualstudio/msbuild/customize-your-build#customize-the-solution-build. However, it may not do what you want, since it doesn't apply in Visual Studio. You may instead want to use a |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thank you for the quick response! TIL about those solution props/targets files! For the second option - how does that work? If the target is in every project, wouldn't that mean we'd run the pre-build step for every project? Or the idea is MSBuild is smart enough to know the project is already built so skips building it multiple times? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Customize the build for one or more projects specially explains. To control whether to run the target in |
BetaWas this translation helpful?Give feedback.
All reactions
-
Updated Link:https://learn.microsoft.com/visualstudio/msbuild/customize-solution-build |
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #8072 on October 19, 2022 14:08.