Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is there a way to run an MSBuild target before the first project or after the last project?#8074

Discussion options

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?

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
3 replies
@adcloeshelle
Comment options

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?

@GangWang01
Comment options

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?

Customize the build for one or more projects specially explains. To control whether to run the target inDirectory.Build.targets for a project, you can add a condition to the target referencing the property set from the project, e.g.<Target Name="PreBuild" Condition="'$(EnablePreBuild)' == 'true'">.

@Nirmal4G
Comment options

Updated Link:https://learn.microsoft.com/visualstudio/msbuild/customize-solution-build

Answer selected byGangWang01
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
4 participants
@adcloeshelle@GangWang01@rainersigwald@Nirmal4G
Converted from issue

This discussion was converted from issue #8072 on October 19, 2022 14:08.


[8]ページ先頭

©2009-2025 Movatter.jp