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

Cannot dotnet format ASP.NET Core projects #1519

Closed
ranma42 opened this issue Feb 16, 2022 · 36 comments
Closed

Cannot dotnet format ASP.NET Core projects #1519

ranma42 opened this issue Feb 16, 2022 · 36 comments

Comments

@ranma42
Copy link

ranma42 commented Feb 16, 2022

After upgrading to 6.0.2 (6.0.200) I got errors when trying to format projects using the web SDK, i.e.

<Project Sdk="Microsoft.NET.Sdk.Web">

Initially I assumed that I had something wrong or unexpected in the project I was working on and/or in my environment, as the error is basically the same as that in #1500; unfortunately in my case even removing all other SDKs did not fix the issue.

EDIT: since the report, new docker images have been released; the reproducer is now much simpler: #1519 (comment)

I tried to reproduce it using one of the standard docker images, but the latest ones are 6.0.102, not 6.0.200, so I wrote this Dockerfile. Its first stage is based on https://github.com/dotnet/dotnet-docker/blob/17971807fc0f4ff5a0eca53deb2d85fff990d95c/src/sdk/6.0/bullseye-slim/amd64/Dockerfile updating just DOTNET_SDK_VERSION and dotnet_sha512
The second stage is the actual reproducer: it creates a simple webapp (from the template) and tries to format it

ARG REPO=mcr.microsoft.com/dotnet/aspnet
FROM $REPO:6.0.2-bullseye-slim-amd64 AS sdk-6.0.200

ENV \
    # Unset ASPNETCORE_URLS from aspnet base image
    ASPNETCORE_URLS= \
    # Do not generate certificate
    DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
    # Do not show first run text
    DOTNET_NOLOGO=true \
    # SDK version
    DOTNET_SDK_VERSION=6.0.200 \
    # Enable correct mode for dotnet watch (only mode supported in a container)
    DOTNET_USE_POLLING_FILE_WATCHER=true \
    # Unset Logging__Console__FormatterName from aspnet base image
    Logging__Console__FormatterName= \
    # Skip extraction of XML docs - generally not useful within an image/container - helps performance
    NUGET_XMLDOC_MODE=skip \
    # PowerShell telemetry for docker image usage
    POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetSDK-Debian-11

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        curl \
        git \
        wget \
    && rm -rf /var/lib/apt/lists/*

# Install .NET SDK
RUN curl -fSL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
    && dotnet_sha512='334f3ea4bfeb736bed61c5896796a09d640b0ae74605c514edc5869c395befb7cfc795b58c922f14560e7d41c89c073c62ed01eefc6d9f13aa916e3478949c24' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    && mkdir -p /usr/share/dotnet \
    && tar -oxzf dotnet.tar.gz -C /usr/share/dotnet ./packs ./sdk ./sdk-manifests ./templates ./LICENSE.txt ./ThirdPartyNotices.txt \
    && rm dotnet.tar.gz \
    # Trigger first run experience by running arbitrary cmd
    && dotnet help

# Install PowerShell global tool
RUN powershell_version=7.2.1 \
    && curl -fSL --output PowerShell.Linux.x64.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Linux.x64.$powershell_version.nupkg \
    && powershell_sha512='bfd0fac3fe5e905156d28433dbf4978d5cea69a4f1b63cb5b8d903f865f0febf4a1b0476a5b84a8e3509b354c44b0cd9e79b31a105176f03b90693ff51c7bb0b' \
    && echo "$powershell_sha512  PowerShell.Linux.x64.$powershell_version.nupkg" | sha512sum -c - \
    && mkdir -p /usr/share/powershell \
    && dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.x64 \
    && dotnet nuget locals all --clear \
    && rm PowerShell.Linux.x64.$powershell_version.nupkg \
    && ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
    && chmod 755 /usr/share/powershell/pwsh \
    # To reduce image size, remove the copy nupkg that nuget keeps.
    && find /usr/share/powershell -print | grep -i '.*[.]nupkg$' | xargs rm

# my reproducer

FROM sdk-6.0.200 AS my-test

WORKDIR /app
RUN dotnet new webapp
RUN dotnet format -v diag --verify-no-changes

This reliably reproduces the issue and results in the errors:

Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

I am unsure if this is actually a dotnet format problem or some kind of packaging issue of the SDK.
In the second case, sorry for the noise 😇

@gnuechtel
Copy link

I had the same experience yesterday.
Our build broke after the recent .NET SDK update to version 6.0.200.
We also have an ASP.NET core application and a library.
For the first one, dotnet format fails, for the latter not.

@RobClenshaw
Copy link

RobClenshaw commented Feb 16, 2022

I'm having the same error with a console application and .NET SDK 6.0.200.
Edit: Ignore this, I made a mistake. It's just our ASP.NET project which has the error.

@ranma42
Copy link
Author

ranma42 commented Feb 16, 2022

I'm having the same error with a console application and .NET SDK 6.0.200.

uhm... interesting!

I tried using this as the second stage in the Dockerfile and it builds just fine in my environment.

FROM sdk-6.0.200 AS my-test

WORKDIR /app
RUN dotnet new console
RUN dotnet format -v diag --verify-no-changes

what SDK are you using in the csproj? Microsoft.NET.Sdk.Web (default for dotnet new webapp) or Microsoft.NET.Sdk (default for dotnet new console)?

@RobClenshaw
Copy link

what SDK are you using in the csproj?

Oops, I was inadvertently including an ASP.NET Core project when running dotnet format. Apologies. That will be why I encountered the problem.

@bjharo
Copy link

bjharo commented Feb 16, 2022

I started noticing this problem yesterday. We have a test automation framework based on .NET 6 that gets built in Azure DevOps. We have a pipeline that runs to build the framework and check formatting whenever someone submits a PR.

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
  - task: UseDotNet@2
    displayName: 'Use .NET 6 SDK'
    inputs:
      version: 6.0.x
      packageType: sdk
      includePreviewVersions: false

  - task: DotNetCoreCLI@2
    displayName: 'Restore Packages'
    inputs:
      command: 'restore'

  - task: DotNetCoreCLI@2
    displayName: 'Format Check'
    inputs:
      command: 'custom'
      custom: 'format'
      arguments: '--severity warn --verify-no-changes'

  - task: DotNetCoreCLI@2
    displayName: 'Build Test Framework'
    inputs:
      command:  'build'

As you can see, the pipeline uses whatever the most recent version of the SDK is. Since 6.0.200, the format task is generating this error:

File name: 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

I was able to replicate the same thing on my local machine once I upgraded to 6.0.200. The framework itself is a pretty simple solution with four projects using using Microsoft.NET.Sdk.

craigktreasure added a commit to craigktreasure/SlnUp that referenced this issue Feb 16, 2022
  - This change adjusts the .NET SDK version installed to be fixed to 6.0.102 to workaround issues with `dotnet format` (see dotnet/format#1519).
craigktreasure added a commit to craigktreasure/SlnUp that referenced this issue Feb 16, 2022
- This change adjusts the .NET SDK version installed to be fixed to 6.0.102 to workaround issues with `dotnet format` (see dotnet/format#1519).
@craigktreasure
Copy link

I'm seeing this issue in repos without any ASP.NET Core projects. Hoping this can be fixed soon to unblock moving to newer SDK versions supporting Visual Studio 17.1.

@niemyjski
Copy link

Also seeing this issue since I upgrade my sdk to 6.0.200

@manuelkroiss
Copy link

manuelkroiss commented Feb 17, 2022

Also seeing this issue.

What I found:
It still works for class library/console projects with

<Project Sdk="Microsoft.NET.Sdk">

It does not work for

<Project Sdk="Microsoft.NET.Sdk.Web">

as @ranma42 already mentioned.

@badcel
Copy link

badcel commented Feb 17, 2022

For me dotnet format fails on console projects (<Project Sdk="Microsoft.NET.Sdk">).

In my case dotnet format --no-restore --verify-no-changes --exclude *.Generated.cs fails with exit code 2 and no more information provided.

@ranma42
Copy link
Author

ranma42 commented Feb 17, 2022

as pointed out in #1521 docker images for 6.0.200 have been released, so the reproducer is now much simpler:

FROM mcr.microsoft.com/dotnet/sdk:6.0.200 AS my-test

WORKDIR /app
RUN dotnet new webapp
RUN dotnet format -v diag --verify-no-changes

(note that this is the full Dockerfile, not the second stage of the build)

@lsaudon
Copy link

lsaudon commented Feb 18, 2022

Install dotnet-format dotnet tool install --global dotnet-format and use dotnet-format, to solve the problem.

@Oceanswave
Copy link

@lsaudon The dotnet format command is now part of the dotnet 6.0 sdk so installing the separate dotnet-format tool should not be required - and indeed this worked with the 6.0.102 release - breaking changes should not be introduced in patch releases.

@lsaudon
Copy link

lsaudon commented Feb 18, 2022

@lsaudon The dotnet format command is now part of the dotnet 6.0 sdk so installing the separate dotnet-format tool should not be required - and indeed this worked with the 6.0.102 release - breaking changes should not be introduced in patch releases.

I know dotnet format is a part of the dotnet 6.0, but what is more important security patch or format code ?
I think is a simple solution for use latest version of dotnet and use format too.

@Oceanswave
Copy link

Oceanswave commented Feb 18, 2022

The matters are being conflated - Generally the CI/CD process where dotnet format gets run and where an app is hosted are different environments. The patch addresses a DoS vulnerability in runtime/hosting environments which generally isn't a vulnerability in CI/CD processes.

However, that same patch shouldn't break shouldn't break everyone's CI/CD processes that run dotnet format.

What you describe in installing the dotnet-format global tool is a workaround, and it may be a valid, good workaround, but it doesn't "Solve the problem"

The reason that myself and possibly others are here is because the dotnet format commands in my CI/CD pipelines are now broken because of this patch release and that needs to be addressed.

@Meligy
Copy link

Meligy commented Feb 19, 2022

The workaround of using the tool

dotnet tool install dotnet-format
dotnet tool run dotnet-format -- -w -s info -a info

Seems to bring the same error for me.

Although in my case I have it as a local tool not global.

@niemyjski
Copy link

niemyjski commented Feb 23, 2022

Is there an eta for a fix on this? There are a lot of issues being opened and this seems like a blocking issue for many.

@WeihanLi
Copy link
Contributor

I had the same issue on .NET 7 preview 1

OS: Windows
Project: https://github.com/WeihanLi/WeihanLi.Common

Diagnostic logs are as follows:

PS C:\projects\sources\WeihanLi.Common> dotnet format --verbosity=diag
  The dotnet runtime version is '7.0.0-preview.1.22076.8'.
  The dotnet CLI version is '7.0.100-preview.1.22110.4'.
  Using MSBuild.exe located in 'C:\Program Files\dotnet\sdk\7.0.100-preview.1.22110.4\'.
  Formatting code files in workspace 'C:\projects\sources\WeihanLi.Common\WeihanLi.Common.sln'.
  Loading workspace.
    Determining projects to restore...
  All projects are up-to-date for restore.
Found project reference without a matching metadata reference: C:\projects\sources\WeihanLi.Common\src\WeihanLi.Data\WeihanLi.Data.csproj
Found project reference without a matching metadata reference: C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Aspect.AspectCore\WeihanLi.Common.Aspect.AspectCore.csproj
Found project reference without a matching metadata reference: C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Aspect.Castle\WeihanLi.Common.Aspect.Castle.csproj
Found project reference without a matching metadata reference: C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Logging.Log4Net\WeihanLi.Common.Logging.Log4Net.csproj
Found project reference without a matching metadata reference: C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Logging.Serilog\WeihanLi.Common.Logging.Serilog.csproj
  Project WeihanLi.Common(netstandard2.0) is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common(netstandard2.0) is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common\obj\Debug\netstandard2.0\WeihanLi.Common.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common(netstandard2.1) is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common(netstandard2.1) is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common\obj\Debug\netstandard2.1\WeihanLi.Common.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common(net6.0) is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common(net6.0) is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common\obj\Debug\net6.0\WeihanLi.Common.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common(net6.0) is using configuration from 'C:\Program Files\dotnet\sdk\7.0.100-preview.1.22110.4\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_6_default.editorconfig'.
  Project WeihanLi.Common.Test is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.     
  Project WeihanLi.Common.Test is using configuration from 'C:\projects\sources\WeihanLi.Common\test\WeihanLi.Common.Test\obj\Debug\net6.0\WeihanLi.Common.Test.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Test is using configuration from 'C:\Program Files\dotnet\sdk\7.0.100-preview.1.22110.4\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_6_default.editorconfig'.
  Project DotNetCoreSample is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project DotNetCoreSample is using configuration from 'C:\projects\sources\WeihanLi.Common\samples\DotNetCoreSample\obj\Debug\net6.0\DotNetCoreSample.GeneratedMSBuildEditorConfig.editorconfig'.
  Project DotNetCoreSample is using configuration from 'C:\Program Files\dotnet\sdk\7.0.100-preview.1.22110.4\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_6_default.editorconfig'.
  Project AspNetCoreSample is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project AspNetCoreSample is using configuration from 'C:\projects\sources\WeihanLi.Common\samples\AspNetCoreSample\obj\Debug\net6.0\AspNetCoreSample.GeneratedMSBuildEditorConfig.editorconfig'.
  Project AspNetCoreSample is using configuration from 'C:\Program Files\dotnet\sdk\7.0.100-preview.1.22110.4\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_6_default.editorconfig'.
  Project WeihanLi.Common.Benchmark is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common.Benchmark is using configuration from 'C:\projects\sources\WeihanLi.Common\perf\WeihanLi.Common.Benchmark\obj\Debug\net6.0\WeihanLi.Common.Benchmark.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Benchmark is using configuration from 'C:\Program Files\dotnet\sdk\7.0.100-preview.1.22110.4\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_6_default.editorconfig'.
  Project WeihanLi.Data is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Data is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Data\obj\Debug\netstandard2.0\WeihanLi.Data.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Logging.Log4Net is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common.Logging.Log4Net is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Logging.Log4Net\obj\Debug\netstandard2.0\WeihanLi.Common.Logging.Log4Net.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Logging.Serilog is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common.Logging.Serilog is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Logging.Serilog\obj\Debug\netstandard2.0\WeihanLi.Common.Logging.Serilog.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Aspect.Castle is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common.Aspect.Castle is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Aspect.Castle\obj\Debug\netstandard2.0\WeihanLi.Common.Aspect.Castle.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Aspect.AspectCore(netstandard2.0) is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common.Aspect.AspectCore(netstandard2.0) is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Aspect.AspectCore\obj\Debug\netstandard2.0\WeihanLi.Common.Aspect.AspectCore.GeneratedMSBuildEditorConfig.editorconfig'.
  Project WeihanLi.Common.Aspect.AspectCore(netstandard2.1) is using configuration from 'C:\projects\sources\WeihanLi.Common\.editorconfig'.
  Project WeihanLi.Common.Aspect.AspectCore(netstandard2.1) is using configuration from 'C:\projects\sources\WeihanLi.Common\src\WeihanLi.Common.Aspect.AspectCore\obj\Debug\netstandard2.1\WeihanLi.Common.Aspect.AspectCore.GeneratedMSBuildEditorConfig.editorconfig'.
  Complete in 10904ms.
  Determining formattable files.
  Complete in 1978ms.
  Running formatters.
  Running Code Style analysis.
  Determining diagnostics...
  Running 4 analyzers on WeihanLi.Common(netstandard2.0).
  Running 4 analyzers on WeihanLi.Common(netstandard2.1).
  Running 4 analyzers on WeihanLi.Common(net6.0).
  Running 4 analyzers on WeihanLi.Common.Test.
  Running 4 analyzers on DotNetCoreSample.
  Running 4 analyzers on AspNetCoreSample.
  Running 4 analyzers on WeihanLi.Common.Benchmark.
  Running 4 analyzers on WeihanLi.Data.
  Running 4 analyzers on WeihanLi.Common.Logging.Log4Net.
  Running 4 analyzers on WeihanLi.Common.Logging.Serilog.
  Running 4 analyzers on WeihanLi.Common.Aspect.Castle.
  Running 4 analyzers on WeihanLi.Common.Aspect.AspectCore(netstandard2.0).
  Running 4 analyzers on WeihanLi.Common.Aspect.AspectCore(netstandard2.1).
  Complete in 17092ms.
  Fixing diagnostics...
  Complete in 28ms.
  Analysis complete in 17121ms.
Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerFinderHelpers.<>c.<LoadAnalyzersAndFixers>b__0_0(Assembly assembly)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable source)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerFinderHelpers.LoadAnalyzersAndFixers(IEnumerable`1 assemblies) 
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerReferenceInformationProvider.GetAnalyzersAndFixers(Project project)
   at System.Collections.Immutable.ImmutableDictionary.<>c__DisplayClass9_0`3.<ToImmutableDictionary>b__0(TSource element)
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.SelectIListIterator`2.MoveNext()
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)      
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary[TSource,TKey,TValue](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 keyComparer, IEqualityComparer`1 valueComparer) 
   at System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary[TSource,TKey,TValue](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerReferenceInformationProvider.GetAnalyzersAndFixers(Solution solution, FormatOptions formatOptions, ILogger logger)
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerFormatter.FormatAsync(Solution solution, ImmutableArray`1 formattableDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.RunCodeFormattersAsync(Solution solution, ImmutableArray`1 formattableDocuments, FormatOptions formatOptions, ILogger logger, List`1 formattedFiles, 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__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass26_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass24_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__23_0>d.MoveNext()        
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass21_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__8_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__7_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseExceptionHandler>b__0>d.MoveNext()
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'       
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 

@craigktreasure
Copy link

@justinmchase I hit it in all 3 (macOS, Ubuntu, and Windows) on my projects. Perhaps your Jenkins Ubuntu build isn't using 6.0.20x?

@maxoulaf2
Copy link

@justinmchase Well I guess when you call dotnet it goes automatically looking for the last SDK version installed, based on the folder name. So if you rename the folder name it fallbacks to the last correct version (6.0.101 in my case).

@justinmchase
Copy link

@craigktreasure You are correct, despite me attempting to set it to 201 its actually pulling an older version:

+ dotnet --version
6.0.101

craigktreasure added a commit to craigktreasure/SlnUp that referenced this issue Mar 11, 2022
  - Due to dotnet/sdk#23972 and dotnet/format#1519, i'm going to start using the `dotnet-format` tool instead of the version integrated into the SDK.
craigktreasure added a commit to craigktreasure/SlnUp that referenced this issue Mar 11, 2022
  - Due to dotnet/sdk#23972 and dotnet/format#1519, i'm going to start using the `dotnet-format` tool instead of the version integrated into the SDK.
craigktreasure added a commit to craigktreasure/SlnUp that referenced this issue Mar 11, 2022
* Revert "Change .NET SDK version to a fixed version (#52)"

This reverts commit c05605a.

* Update to latest .NET 6 SDK

* Use `dotnet-format`

  - Due to dotnet/sdk#23972 and dotnet/format#1519, i'm going to start using the `dotnet-format` tool instead of the version integrated into the SDK.
@jmarolf jmarolf added this to the SDK 6.0.202 Release milestone Mar 14, 2022
@jmarolf
Copy link
Contributor

jmarolf commented Mar 14, 2022

This will be fixed tin the 6.0.202 SDK release. I will leave this issue open until that release is downloadable.

@MarkusRodler
Copy link

@jmarolf Thanks for the info that it will be fixed in a future release! Can you tell us if there is an ETA? It doesn' t need to be to precise. Only if we are talking about hours, days, weeks or even months?

@DamianEdwards
Copy link
Member

Servicing runs on a monthly cadence, so if it's not in the next patch-Tuesday release, it's likely going to be in the release after that.

@achingono
Copy link

Another workaround that has worked for me (if tool is installed locally) is to run:
dotnet dotnet-format

@ranma42
Copy link
Author

ranma42 commented Apr 13, 2022

The .NET 6.0.202 SDK has been released.
The SDK-provided dotnet format tool works again in my environment (both in docker and directly) 🚀

@ranma42 ranma42 closed this as completed Apr 13, 2022
aaronpowell added a commit to Azure/data-api-builder that referenced this issue Apr 20, 2022
seantleonard added a commit to Azure/data-api-builder that referenced this issue Apr 20, 2022
* Update Solution to .Net 6

* Dedupe Functions Csproj config for function version.

* update build CI config to windows-latest which include latest vs2022 and .net6 SDK

* Update to windows-2022. windows-latest is not there yet.

* Configure build pipeline for ubuntu-latest

* Update VmImage to windows-2022 as windows-latest does not have .net6

* update Cosmos pipeline to use windows-2022

* Dockerfile set dotnet version to 6.0

* Remove custom install dotnet format tool build step as it is included in .NET6

* Update dependencies

* dotnet/format#1519 is fixed so unpinning sdk version

* adding dotnet tool installer task

Co-authored-by: Aaron Powell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests