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

MSBuild Code Analysis formatting exception #35388

Open
cschuchardt88 opened this issue Sep 14, 2023 · 1 comment
Open

MSBuild Code Analysis formatting exception #35388

cschuchardt88 opened this issue Sep 14, 2023 · 1 comment
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@cschuchardt88
Copy link

cschuchardt88 commented Sep 14, 2023

Describe the bug

The problem is character case problem. This file Crontab.csproj does clearly exist in the repo, but its called CronTab.csproj The T is capitalized in the repo but i renamed it in visual studio. But i guess git didn't pick it up, because the name didn't change?

Exceptions (if any)

dotnet format --verify-no-changes --verbosity diagnostic
  shell: /usr/bin/bash -e {0}
  env:
    DOTNET_VERSION: 7.0.x
    DOTNET_ROOT: /usr/share/dotnet
  The dotnet runtime version is '7.0.11'.
  The dotnet CLI version is '7.0.401'.
  Using MSBuild.exe located in '/usr/share/dotnet/sdk/7.0.401/'.
  Formatting code files in workspace '/home/runner/work/neo-cron-plugin/neo-cron-plugin/ALL.sln'.
  Loading workspace.
  /usr/share/dotnet/sdk/7.0.401/NuGet.targets(400,5): error MSB[3](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185051776/job/16789880870?pr=8#step:4:3)202: The project file "/home/runner/work/neo-cron-plugin/neo-cron-plugin/src/Neo.Plugins.Cron/Crontab.csproj" was not found. [/home/runner/work/neo-cron-plugin/neo-cron-plugin/ALL.sln]
Unhandled exception: System.Exception: Restore operation failed.
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
   at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass[4](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185051776/job/16789880870?pr=8#step:4:4)_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass21_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__17_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass1[5](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185051776/job/16789880870?pr=8#step:4:5)_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__4_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass[7](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185051776/job/16789880870?pr=8#step:4:8)_0.<<UseExceptionHandler>b__0>d.MoveNext()
Error: Process completed with exit code 1.

After rename the file to Crontab.csproj from CronTab.csproj

dotnet format --verify-no-changes --verbosity diagnostic
  shell: /usr/bin/bash -e {0}
  env:
    DOTNET_VERSION: 7.0.x
    DOTNET_ROOT: /usr/share/dotnet
  The dotnet runtime version is '7.0.11'.
  The dotnet CLI version is '7.0.401'.
  Using MSBuild.exe located in '/usr/share/dotnet/sdk/7.0.401/'.
  Formatting code files in workspace '/home/runner/work/neo-cron-plugin/neo-cron-plugin/ALL.sln'.
  Loading workspace.
    Determining projects to restore...
  Restored /home/runner/work/neo-cron-plugin/neo-cron-plugin/src/Neo.Plugins.Cron/Crontab.csproj (in 1.86 sec).
  Project Crontab is using configuration from '/home/runner/work/neo-cron-plugin/neo-cron-plugin/.editorconfig'.
  Project Crontab is using configuration from '/home/runner/work/neo-cron-plugin/neo-cron-plugin/src/Neo.Plugins.Cron/obj/Debug/net7.0/Crontab.GeneratedMSBuildEditorConfig.editorconfig'.
  Project Crontab is using configuration from '/usr/share/dotnet/sdk/7.0.401/Sdks/Microsoft.NET.Sdk/analyzers/build/config/analysislevel_7_default.editorconfig'.
  Complete in 6[3](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185490704/job/16791191160?pr=8#step:4:3)59ms.
  Determining formattable files.
  Complete in 311ms.
  Running formatters.
  Running Code Style analysis.
  Determining diagnostics...
  Running 3 analyzers on Crontab.
  Complete in 2212ms.
  Analysis complete in 2212ms.
  Running Analyzer Reference analysis.
  Determining diagnostics...
  Running 1[4](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185490704/job/16791191160?pr=8#step:4:4)6 analyzers on Crontab.
  Complete in [5](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185490704/job/16791191160?pr=8#step:4:5)[8](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185490704/job/16791191160?pr=8#step:4:9)5ms.
  Analysis complete in 585ms.
  Complete in 3848ms.
  Formatted 0 of 13 files.
  Format complete in [10](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185490704/job/16791191160?pr=8#step:4:11)5[21](https://github.com/cschuchardt88/neo-cron-plugin/actions/runs/6185490704/job/16791191160?pr=8#step:4:22)ms.

Further technical details

  • The dotnet runtime version is '7.0.11'.
  • The dotnet CLI version is '7.0.401'.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Sep 14, 2023
@cschuchardt88 cschuchardt88 changed the title MSBuild Code Analysis formatting MSBuild Code Analysis formatting exception Sep 14, 2023
@cschuchardt88
Copy link
Author

cschuchardt88 commented Sep 18, 2023

The reason it happened is because the solution file has a different case of characters for the project filename then what is on the disk. In this case the output you are seeing from main post of this issue was built on github. Also this happened on my computer as well. Visual studio does case about the case of characters for the filename in a solution file, but dotnet format does. I don't know if this affects *.proj file as well with different case of characters for the name of files on disk. Also im talking about the filenames inside of the solution and *.proj file itself as if edit you changed the file directly and changed the case of characters for the filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants