docfx
                                
                                 docfx copied to clipboard
                                
                                    docfx copied to clipboard
                            
                            
                            
                        docfx building in MSBuild does not respect <TreatWarningsAsErrors>property settings
Operating System: Windows
DocFX Version Used: 2.59.3
Template used: default
Steps to Reproduce:
In an existing docfx fle, where docfx issues a warning when built, do the following:
- Create sdk style csproj file in same dir as docfx.json file to integrate docfx build in msbuild
- add package reference <PackageReference Include="docfx.console" Version="2.59.3" />
- Set <TreatWarningsAsErrors>true</TreatWarningsAsErrors>. Project file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.Build.NoTargets">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  <ItemGroup Label="PackageReferences">
    <PackageReference Include="docfx.console" Version="2.59.3" />
  </ItemGroup>
  
</Project>
- Run dotnet restore and dotnet build from the command line
Expected Behavior: The warning is reflected, and the build fails due to the warning +TreatWarningAsError
Actual Behavior: Console shows docfx waning, but msbuild sees no warnings, here is my console output: [...] Build succeeded with warning. [22-08-01 04:50:55.831]Warning:BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.ConceptualDocumentProcessor.SaveInvalid file link:(~/Re poOptimizations/obpipelines/[email protected]). 1 Warning(s) 0 Error(s)
Build succeeded. 0 Warning(s) 0 Error(s)
There is a WarningsAsErrors option here:
The option would have to be added to DocGenerateCommand around here:
But, until that is implemented, you can add it to DocParameters yourself.
See this thread:
https://github.com/dotnet/docfx/issues/7433#issuecomment-890918387