How to run MSBuild from Powershell without spawning msbuild.exe process?

后端 未结 5 1207
旧时难觅i
旧时难觅i 2020-12-28 21:15

I am considering running MSBuild from a Powershell script by tapping directly to the MSBuild assemblies (as opposed to looking up MSBuild install path and starting msbuild.e

5条回答
  •  太阳男子
    2020-12-28 21:38

    Once upon a time I've been playing with running augmented MSBuild build processes (like, skip some parts of the build more aggressively).

    There were two choices:

    1. Host MSBuild in your own process by loading its DLLs.
    2. Spawn MSBuild.exe the regular way and then inject into it (e.g. loggers provide a decent way in).

    I've implemented both and had to abandon #1 because it wasn't flexible enough.

    For instance, MSBuild has a load of assembly binding redirections in its .config file.

    The Visual Studio process (devenv.exe) which also hosts MSBuild with its API ends up copypasting these into its devenv.exe.config. Mine .exe.config had also to have these, but it adheres you to a specific MSBuild version. And, of course, you have to modify the config. Which is not an option with PS actually, so I doubt if you could get a really stable solution.

提交回复
热议问题