Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Warning message wraps at 80 columns, making MSBuild parse it wrong #9457

Closed
KalleOlaviNiemitalo opened this issue Nov 23, 2023 · 3 comments · Fixed by #9464
Closed
Labels
bug A bug to fix
Milestone

Comments

@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Nov 23, 2023

Describe the bug

When DocFX is run by the Exec task in MSBuild on Windows, and DocFX outputs a warning in which the file path exceeds 80 characters, it inserts a line break after the first 80 characters. That causes MSBuild not to parse the first line as part of the file path.

To Reproduce

Steps to reproduce the behavior:

C:\>mkdir C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage

C:\>cd \Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage

C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>dotnet new globaljson --sdk-version 6.0.417
The template "global.json file" was created successfully.


C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>dotnet new tool-manifest
The template "Dotnet local tool manifest file" was created successfully.


C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>dotnet tool install --local docfx --version 2.74.0
You can invoke the tool from this directory using the following commands: 'dotnet tool run docfx' or 'dotnet docfx'.
Tool 'docfx' (version '2.74.0') was successfully installed. Entry is added to the manifest file C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage\.config\dotnet-tools.json.

C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>dotnet docfx init
This utility will walk you through creating a docfx project.
It only covers the most common items, and tries to guess sensible defaults.

Name (mysite): mysite
Generate .NET API documentation? [y/n] (y): n
Markdown docs location (docs): docs
Enable site search? [y/n] (y): n
Enable PDF? [y/n] (y): n

About to write to C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage\docfx.json:

{
  "build": {
    "content": [
      {
        "files": [
          "**/*.{md,yml}"
        ],
        "exclude": [
          "_site/**"
        ]
      }
    ],
    "resource": [
      {
        "files": [
          "images/**"
        ]
      }
    ],
    "output": "_site",
    "template": [
      "default",
      "modern"
    ],
    "globalMetadata": {
      "_appName": "mysite",
      "_appTitle": "mysite",
      "_enableSearch": false,
      "pdf": false
    }
  }
}

Is this OK? [y/n] (y): y

Project created at C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage

Run docfx C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage\docfx.json --serve to launch the site.

C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>echo.> index.md

C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>echo>index.md [Dangling link](doesnotexist.md)

C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>

Add Docs.msbuildproj containing:

<Project>

  <Target Name="Build">
    <Exec Command="dotnet docfx build" />
  </Target>

</Project>

Run MSBuild:

C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage>dotnet msbuild
MSBuild version 17.3.2+561848881 for .NET
  Searching custom plugins in directory
  C:\Users\Kalle\.nuget\packages\docfx\2.74.0\tools\net6.0\any\...
  No files are found with glob pattern images/**, excluding <none>, under
  directory
  "C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMe
  ssage"
  6 plug-in(s) loaded.
  Building 3 file(s) in
  ConceptualDocumentProcessor(BuildConceptualDocument=>CountWord=>ValidateConceptu
  alDocumentMetadata)...
  Building 2 file(s) in TocDocumentProcessor(BuildTocDocument)...
  C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMes
sage\index.md(1,1): warning InvalidFileLink: Invalid file [C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage\Docs.msbuildproj]
  link:(~/doesnotexist.md).
  Applying templates to 5 model(s)...
  XRef map exported.


  Build succeeded with warning.

      1 warning(s)
      0 error(s)

MSBuild highlights only this line in yellow:

sage\index.md(1,1): warning InvalidFileLink: Invalid file [C:\Projects\ThisDirectoryHasALongNameToDemonstrateTheLineWrappingInTheWarningMessage\Docs.msbuildproj]

Expected behavior

The whole warning should be one line, with no embedded line breaks.

Context (please complete the following information):

  • OS: Windows
  • Docfx version: 2.74.0
  • MSBuild version: 17.3.2+561848881 (dotnet msbuild from .NET SDK 6.0.417)

Additional context

The width of the console window does not seem to matter for this.

I guess the bug is related to Spectre.Console.

@KalleOlaviNiemitalo KalleOlaviNiemitalo added the bug A bug to fix label Nov 23, 2023
@KalleOlaviNiemitalo
Copy link
Author

Diagnostic output was switched to spectre console in eb0e661 but why was that change made?

@yufeih
Copy link
Contributor

yufeih commented Nov 24, 2023

Because ordinary console outputs would break the formatting of spectra components such as the progress bar.

@KalleOlaviNiemitalo
Copy link
Author

KalleOlaviNiemitalo commented Jan 5, 2024

Now I'm getting similar line wrapping on the Playwright error message when attempting to run Chromium on an older Windows OS that does not define the required APIs: "The specified procedure could not be found." Also, the exception stack trace formatted by Spectre.Console omits the type names and source directory paths, although it shows the method names, parameter lists, file names, and line numbers.

I wish I could entirely disable Spectre.Console text wrapping and other output formatting for my automated build scenarios, where it is not possible for Spectre.Console to know in advance how wide the window will be when the build log is eventually viewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants