Specify a logger in MSBuild configuration file

2019-07-13 15:00发布

I've written some custom logger for my MSBuild process and it's working fine from the command line:

msbuild <project> /logger:mylogger.dll

the question now is how should I specify my custom logger in the .csproj file so that when I build from Visual Studio my custom logger is used the same way as I use it when running msbuild from the command line.

I haven't found anything to do that here or here.

1条回答
We Are One
2楼-- · 2019-07-13 15:21

This is not possible. In MSBuild API, RegisterLogger has to be called before the build is started. You should not change build configuration while the build is already going. You might be able to hack this by creating custom MSBuild task that adds a new logger in the middle of the build, but that would create more problems than it solves, because logger configuration is per build engine, not per project, so when you add/remove loggers, all projects that are involved in the build are affected.

查看更多
登录 后发表回答