How to change verbosity of the MSBuild task?

后端 未结 1 713
北恋
北恋 2021-02-20 09:49

I\'d like to have a different verbosity for the msbuild project invoked from the commandline, and those invoked by the MSBuild task from within the project. For example:

相关标签:
1条回答
  • 2021-02-20 10:06

    You have two options (at least) :)

    1. Create one additional msbuild script for building abc projects "BuildABC.proj"

          <Target Name="BuildABC">
            <MSBuild Projects="a.csproj;b.csproj;c.csproj" BuildInParallel="true"/>
          </Target>
      

      In your parent script execute MSBuild using Exec task and call "BuildABC.proj" with minimal verbosity

          <Target Name=Foo>
            <Exec Command="msbuild /v:m /m:2 BuildABC.proj"/>
          </Target>
      

      You have to pass explicitly all parent properties needed in the BuildABC project to msbuild /p parameter.

    2. Use custom logger. See this how to do it. In this case you can use your original script:

      <Target Name=Foo>
        <MSBuild Projects="a.csproj;b.csproj;c.csproj"/>
      </Target>
      

      In your custom logger do not log anything related to e.g. "a.csproj" project between ProjectStarted and ProjectFinished events where e.ProjectFile == "a.csproj" (to disable diagnostic logging on "a.csproj" project while building parent project with diagnostic verbosity)

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