docfx icon indicating copy to clipboard operation
docfx copied to clipboard

docfx building in MSBuild does not respect <TreatWarningsAsErrors>property settings

Open DkSkydancer opened this issue 3 years ago • 2 comments

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:

  1. Create sdk style csproj file in same dir as docfx.json file to integrate docfx build in msbuild
  2. add package reference <PackageReference Include="docfx.console" Version="2.59.3" />
  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>
  1. 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)

DkSkydancer avatar Aug 01 '22 17:08 DkSkydancer

See this thread:

https://github.com/dotnet/docfx/issues/7433#issuecomment-890918387

paulushub avatar Aug 02 '22 08:08 paulushub