How to emulate /p msbuild parameter in Visual Studio build?

前端 未结 2 673
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 21:43

That the logical follow-up for the my previous question: \"How to check all projects in solution for some criteria?\"
I was given quite a good answer to use CustomAfterM

相关标签:
2条回答
  • 2021-01-13 22:34

    I use a bit different technique then @Spider M9. I want that all projects in solution tree/all subdirectories from current directory use extended build throw Custom*MicrosoftCommonTargets. I don't like to be forced to change every new project to import custom targets/props.

    I place special file, let's say msbuild.include, in the root directory and my custom targets loader for every project tries to find it in ., ..\, ..\..\, and so on. msbuild.include contains flags that triggers execution of custom actions. If loader can't find this file it disables loading all custom targets and stoppes. This gives me ability to use my build extensions with projects from work repositories and to not use with opensource projects.

    If you are interested in I can publish loader. It's a pretty simple and elegant solution.

    For example I can sign any assembly in all projects in all subfolders with my key.

    0 讨论(0)
  • 2021-01-13 22:42

    I always set up every project to import a standard .props file. Use the GetDirectoryNameOfFileAbove property function (see MSDN) to find it. Do this as the first line of every project file. Once established, you can redirect from that file to other imports. Another trick is to have that standard import (that would obviously be under version control) import conditionally another .props file only if it exists. This optional file would not be in version control, but is available for any developer to create and modify with their own private/temporary properties or other behavior.

    0 讨论(0)
提交回复
热议问题