在MSBuild配置文件中指定记录器 [英] Specify a logger in MSBuild configuration file

查看:79
本文介绍了在MSBuild配置文件中指定记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为MSBuild流程编写了一些自定义记录器,并且在命令行中可以正常运行:

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

msbuild <project> /logger:mylogger.dll

现在的问题是,我应该如何在.csproj文件中指定自定义记录器,以便从Visual Studio构建时,自定义记录器的使用方式与从命令行运行msbuild时所使用的方式相同.

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.

此处此处.

推荐答案

这是不可能的.在MSBuild API中, RegisterLogger 必须在构建开始之前被调用.在构建已经进行的过程中,您不应更改构建配置.您可能可以通过创建自定义MSBuild任务来破解此问题,该任务会在构建过程的中间添加一个新的记录器,但是这样做会产生超出其解决方案的更多问题,因为记录器配置是按构建引擎而不是按项目进行的,因此添加时/删除记录器,构建中涉及的所有项目都会受到影响.

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.

这篇关于在MSBuild配置文件中指定记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆