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 be used from a Docker container #1060

Closed
bdovaz opened this issue Mar 24, 2023 · 27 comments · Fixed by #1194
Closed

Cannot be used from a Docker container #1060

bdovaz opened this issue Mar 24, 2023 · 27 comments · Fixed by #1194

Comments

@bdovaz
Copy link
Contributor

bdovaz commented Mar 24, 2023

Product and Version Used: 0.5.0

Steps to Reproduce:

  1. Leave these 3 files in the same directory.

csharp_project.csproj:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
  </PropertyGroup>

</Project>

Test.cs:

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

Dockerfile:

FROM python:3.11.2-alpine3.17

RUN apk add dotnet7-sdk

ENV PATH="$PATH:/root/.dotnet/tools"

RUN dotnet tool install --global roslynator.dotnet.cli

COPY . /data

CMD ["roslynator", "analyze", "/data/csharp_project.csproj", "--verbosity", "diagnostic"]
  1. Run docker build . --tag roslynator_test && docker run roslynator_test

Actual Behavior:

One or more errors occurred. (Unable to load shared library 'hostfxr' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr.so: No such file or directory
Error loading shared library hostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr.so: No such file or directory
Error loading shared library libhostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr: No such file or directory
Error loading shared library hostfxr: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr: No such file or directory
Error loading shared library libhostfxr: No such file or directory
)
  Inner exception: Unable to load shared library 'hostfxr' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:

Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr.so: No such file or directory
Error loading shared library hostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr.so: No such file or directory
Error loading shared library libhostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr: No such file or directory
Error loading shared library hostfxr: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr: No such file or directory
Error loading shared library libhostfxr: No such file or directory

Expected Behavior:

It should work.

If I do the same with a similar tool, it works instead, so the problem is in Roslynator.

FROM python:3.11.2-alpine3.17

RUN apk add dotnet7-sdk

ENV PATH="$PATH:/root/.dotnet/tools"

RUN dotnet tool install --global CSharpier

COPY . /data

CMD ["dotnet-csharpier", "/data"]

Output:

Total time:                                                                          339ms
Total files:                                                                           1

@josefpihrt we want to integrate it into MegaLinter but this issue is a stopper for us.

@josefpihrt
Copy link
Collaborator

Hi,

I tried to use official image for .NET SDK mcr.microsoft.com/dotnet/sdk:7.0 and it works as expected.

I would say that there must be some difference when you use .NET SDK image and when you use Alpine with installed .NET. But I have no idea what is the difference.

It is strange that the CSharpier works but again, I was not able to find the difference between Roslynator and CSharpier that could cause this problem.

My wild guess is that the issue is not in Roslynator as it is standard .NET Core global tool, but there may be something wrong/missing when .NET is installed to Alpine.

@bdovaz
Copy link
Contributor Author

bdovaz commented Apr 14, 2023

@josefpihrt but the thing is that with csharpier it works and it is also another tool, it only happens with roslynator this problem.

@josefpihrt
Copy link
Collaborator

It's definitely possible the problem is with Roslynator. Unfortunately I don't have knowledge to find and fix the problem (I tried but I gave up after several hours of "debugging" in docker).

Do you think you could post this issue to a repo where you could get some help (such as https://github.com/dotnet/sdk)?

@jamesHargreaves12
Copy link
Contributor

I was seeing the same issue when running the roslynator cli on my mac. I could convince myself that the issue was coming from MSBulidLocator and so I opened an issue there microsoft/MSBuildLocator#210.

@bdovaz In the short term, downgrading the version of the Roslynator cli to 0.3.3 should hopefully work for you. This has a dependency on an earlier version of MSBuildLocator (1.4.1) which did not have the same issues.

@josefpihrt
Copy link
Collaborator

I believe @jamesHargreaves12 is right.

I was probably to eager to update MSBuildLocator to latest version. I'm not sure what are changes between 1.4.1. and 1.5.5 but I think I would be reasonable to change version of MSBuildLocator back to 1.4.1. as it is more stable version.

@bdovaz
Copy link
Contributor Author

bdovaz commented Apr 21, 2023

Ok, I'm starting to understand something...

CSharpier does not have this dependency (Microsoft.Build.Locator).

Well as far as I can see there are 2 alternatives:

In my opinion obviously the second option is better.

@josefpihrt
Copy link
Collaborator

Temporary solved with #1079.

I would keep this issue open till the root cause is fixed.

@bdovaz
Copy link
Contributor Author

bdovaz commented Apr 23, 2023

@josefpihrt you are going to release a new release in NuGet, right?

Thanks!

@josefpihrt
Copy link
Collaborator

https://www.nuget.org/packages/Roslynator.DotNet.Cli/0.6.0

@bdovaz
Copy link
Contributor Author

bdovaz commented May 14, 2023

@josefpihrt I have encountered another problem.

With the above case I now get:

Roslynator Version: 0.6.0.0
Roslynator Target Framework: .NET Core
Roslyn Version: 4.5.0.0
Available MSBuild locations:
  .NET Core SDK, Version: 7.0.104, Path: /usr/lib/dotnet/sdk/7.0.104/
MSBuild location is '/usr/lib/dotnet/sdk/7.0.104/'
Load project '/data/csharp_project.csproj'
  Evaluate  00:00.26  csharp_project.csproj
  Build     00:00.22  csharp_project.csproj
  Resolve   00:00.09  csharp_project.csproj (net6.0)
Done loading project '/data/csharp_project.csproj'
Analyze 'csharp_project'
Resolve assembly 'System.Composition.AttributedModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Unable to resolve assembly 'System.Composition.AttributedModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Resolve assembly 'System.Composition.AttributedModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Unable to resolve assembly 'System.Composition.AttributedModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
One or more errors occurred. (Could not load file or assembly 'System.Composition.AttributedModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
)
  Inner exception: Could not load file or assembly 'System.Composition.AttributedModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

If I try from outside a container, it works.

If I change the to netstandard2.0 (inside the container), it works.

Edit: I think the problem comes from here:

https://github.com/JosefPihrt/Roslynator/blob/56128e43a83749379e54e854a74451d5e6609422/src/CommandLine/AssemblyResolver.cs#L41

@bdovaz
Copy link
Contributor Author

bdovaz commented May 24, 2023

@josefpihrt have you been able to investigate something? The problem as I say arises from that class and specifically in the AssemblyResolve event that in the case of being inside a docker container does not seem to like it (I do not know if this is the cause).

Why do you override the resolution of certain assemblies?

Thanks.

@josefpihrt
Copy link
Collaborator

@bdovaz sorry for the late answer.

I recently bumped Roslyn version to 4.6.0 and it seems that it fixed the issue.

I tried to run it locally inside docker and the errors are gone and I can see some diagnostics (I added Roslynator analyzers to project).

csproj file:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="roslynator.analyzers" Version="4.3.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Dockerfile:

FROM python:3.11.2-alpine3.17

RUN apk add dotnet7-sdk

ENV PATH="$PATH:/root/.dotnet/tools"

COPY . /data

RUN dotnet tool install --global roslynator.dotnet.cli --version 0.6.1 --add-source /data/nuget

RUN dotnet restore /data/csharp_project.csproj

CMD ["roslynator", "analyze", "/data/csharp_project.csproj", "--verbosity", "diagnostic"]

If you want to try it then just do following steps:

  1. Checkout current main

  2. Update version in Directory.Build.props

<RoslynatorCliPackageVersion>0.6.1</RoslynatorCliPackageVersion>
  1. Run tools/build_cli.ps1

  2. Copy out/Release/*.nupkg to nuget

@bdovaz
Copy link
Contributor Author

bdovaz commented Jul 11, 2023

@josefpihrt I have tested it and it works perfectly!

In fact I have created a PR #1110 which contributes to the documentation as I have followed your steps but some more were missing and by the way I have improved some little thing.

I'm waiting for a new release in NuGet.

Thank you!

@bdovaz
Copy link
Contributor Author

bdovaz commented Aug 30, 2023

@josefpihrt
Copy link
Collaborator

@bdovaz Great! I prepared PR #1194. Could you install CLI from the PR's artifacts and test it?

@bdovaz
Copy link
Contributor Author

bdovaz commented Aug 31, 2023

@josefpihrt The only thing I find strange is the Unable to resolve assembly which I don't know if it's normal or not.

[+] Building 5.0s (10/10) FINISHED                                                                       docker:default
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 1.78kB                                                                             0.0s
 => [internal] load metadata for docker.io/library/python:3.11.2-alpine3.17                                        0.5s
 => [1/5] FROM docker.io/library/python:3.11.2-alpine3.17@sha256:4b4078a3ab81edc2f5725cd42b065beaeeb4f9be3b4b1e3b  0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 4.22kB                                                                                0.0s
 => CACHED [2/5] RUN apk add dotnet7-sdk                                                                           0.0s
 => [3/5] COPY . /data                                                                                             0.1s
 => [4/5] RUN dotnet tool install --global roslynator.dotnet.cli --version 0.7.1-alpha1194.700.1 --add-source /da  2.3s
 => [5/5] RUN dotnet restore /data/csharp_project.csproj                                                           1.6s
 => exporting to image                                                                                             0.4s
 => => exporting layers                                                                                            0.4s
 => => writing image sha256:da2537a6c5c73aa79dbacf6a3d00cf8c77f63bfd7ba889755f0ac383f9001e75                       0.0s
 => => naming to docker.io/library/roslynator_test                                                                 0.0s

What's Next?
  View summary of image vulnerabilities and recommendations → docker scout quickview
Roslynator Version: 0.7.1.0
Roslynator Target Framework: .NET Core
Roslyn Version: 4.6.0.0
Available MSBuild locations:
  .NET Core SDK, Version: 7.0.104, Path: /usr/lib/dotnet/sdk/7.0.104
MSBuild location is '/usr/lib/dotnet/sdk/7.0.104'
Load project '/data/csharp_project.csproj'
  Evaluate  00:00.30  csharp_project.csproj
  Build     00:00.34  csharp_project.csproj
  Resolve   00:00.11  csharp_project.csproj (net7.0)
Done loading project '/data/csharp_project.csproj'
Analyze 'csharp_project'
Resolve assembly 'Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL'
Unable to resolve assembly 'Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Resolve assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Unable to resolve assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Add analyzer assembly 'Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Add analyzer assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Resolve assembly 'Microsoft.Interop.JavaScript.JSImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'
Unable to resolve assembly 'Microsoft.Interop.JavaScript.JSImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Resolve assembly 'Microsoft.Interop.SourceGeneration, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Unable to resolve assembly 'Microsoft.Interop.SourceGeneration, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Resolve assembly 'Microsoft.Interop.LibraryImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'
Unable to resolve assembly 'Microsoft.Interop.LibraryImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Add analyzer assembly 'Microsoft.Interop.LibraryImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Resolve assembly 'System.Text.Json.SourceGeneration, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL'
Unable to resolve assembly 'System.Text.Json.SourceGeneration, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Resolve assembly 'System.Text.RegularExpressions.Generator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'
Unable to resolve assembly 'System.Text.RegularExpressions.Generator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Add analyzer assembly 'System.Text.RegularExpressions.Generator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  281 supported diagnostics with prefix 'CA' (CA1000, CA1001, CA1002, CA1003, CA1005, CA1008, CA1010, CA1012, CA1014, CA1016, CA1017, CA1018, CA1019, CA1021, CA1024, CA1027, CA1028, CA1030, CA1031, CA1032, CA1033, CA1034, CA1036, CA1040, CA1041, CA1043, CA1044, CA1045, CA1046, CA1050, CA1051, CA1052, CA1054, CA1055, CA1056, CA1058, CA1060, CA1061, CA1062, CA1063, CA1064, CA1065, CA1066, CA1067, CA1068, CA1069, CA1070, CA1200, CA1303, CA1304, CA1305, CA1307, CA1308, CA1309, CA1310, CA1311, CA1401, CA1416, CA1417, CA1418, CA1419, CA1420, CA1421, CA1422, CA1501, CA1502, CA1505, CA1506, CA1507, CA1508, CA1509, CA1700, CA1707, CA1708, CA1710, CA1711, CA1712, CA1713, CA1715, CA1716, CA1720, CA1721, CA1724, CA1725, CA1727, CA1802, CA1805, CA1806, CA1810, CA1812, CA1813, CA1814, CA1815, CA1816, CA1819, CA1820, CA1821, CA1822, CA1823, CA1824, CA1825, CA1826, CA1827, CA1828, CA1829, CA1830, CA1831, CA1832, CA1833, CA1834, CA1835, CA1836, CA1837, CA1838, CA1839, CA1840, CA1841, CA1842, CA1843, CA1844, CA1845, CA1846, CA1847, CA1848, CA1849, CA1850, CA1851, CA1852, CA1853, CA1854, CA1855, CA2000, CA2002, CA2007, CA2008, CA2009, CA2011, CA2012, CA2013, CA2014, CA2015, CA2016, CA2017, CA2018, CA2019, CA2020, CA2100, CA2101, CA2109, CA2119, CA2153, CA2200, CA2201, CA2207, CA2208, CA2211, CA2213, CA2214, CA2215, CA2216, CA2217, CA2219, CA2225, CA2226, CA2227, CA2229, CA2231, CA2234, CA2235, CA2237, CA2241, CA2242, CA2243, CA2244, CA2245, CA2246, CA2247, CA2248, CA2249, CA2250, CA2251, CA2252, CA2253, CA2254, CA2255, CA2256, CA2257, CA2258, CA2259, CA2260, CA2300, CA2301, CA2302, CA2305, CA2310, CA2311, CA2312, CA2315, CA2321, CA2322, CA2326, CA2327, CA2328, CA2329, CA2330, CA2350, CA2351, CA2352, CA2353, CA2354, CA2355, CA2356, CA2361, CA2362, CA3001, CA3002, CA3003, CA3004, CA3005, CA3006, CA3007, CA3008, CA3009, CA3010, CA3011, CA3012, CA3061, CA3075, CA3076, CA3077, CA3147, CA5350, CA5351, CA5358, CA5359, CA5360, CA5361, CA5362, CA5363, CA5364, CA5365, CA5366, CA5367, CA5368, CA5369, CA5370, CA5371, CA5372, CA5373, CA5374, CA5375, CA5376, CA5377, CA5378, CA5379, CA5380, CA5381, CA5382, CA5383, CA5384, CA5385, CA5386, CA5387, CA5388, CA5389, CA5390, CA5391, CA5392, CA5393, CA5394, CA5395, CA5396, CA5397, CA5398, CA5399, CA5400, CA5401, CA5402, CA5403, CA5404, CA5405)
  8 supported diagnostics with prefix 'SYSLIB' (SYSLIB1045, SYSLIB1054, SYSLIB1055, SYSLIB1056, SYSLIB1057, SYSLIB1058, SYSLIB1060, SYSLIB1061)
Done analyzing project '/data/csharp_project.csproj' in 00:02.12

0 diagnostics found

`

@josefpihrt
Copy link
Collaborator

@bdovaz sorry for the delay.

The only thing I find strange is the Unable to resolve assembly which I don't know if it's normal or not.

Aside from the "Unable to resolve assembly" logs, does it work as you expect or not? I see "0 diagnostics found" at the end. Is it expected?

@bdovaz
Copy link
Contributor Author

bdovaz commented Sep 23, 2023

@josefpihrt I don't know, it's the example I put in my first post in this thread, I guess it's expected? How do you tell it which rules to use using the cli? Because using the NuGet packages I know that it is done with the .editorconfig file.

@bdovaz
Copy link
Contributor Author

bdovaz commented Nov 7, 2023

@josefpihrt if I add Roslynator packages to csproj they don't appear in the log, as if it can't find them:

<ItemGroup>
    <PackageReference Include="Roslynator.Analyzers" Version="4.6.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.6.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

If I run it outside of Docker I do see logs of the type but instead from inside the container all these logs do not appear:

Resolve assembly 'Roslynator.CSharp.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator.CSharp.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Analyzers_Roslynator.Workspaces.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Analyzers_Roslynator.Workspaces.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Analyzers_Roslynator.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Analyzers_Roslynator.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Analyzers_Roslynator.CSharp, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Analyzers_Roslynator.CSharp, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Analyzers_Roslynator.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Analyzers_Roslynator.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Add analyzer assembly 'Roslynator.CSharp.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Resolve assembly 'Roslynator.CSharp.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator.CSharp.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Add analyzer assembly 'Roslynator.CSharp.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Resolve assembly 'Roslynator_Analyzers_Roslynator.CSharp.Workspaces, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Analyzers_Roslynator.CSharp.Workspaces, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Analyzers_Roslynator.Workspaces.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Analyzers_Roslynator.Workspaces.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator.Formatting.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator.Formatting.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Workspaces.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Workspaces.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Common, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Add analyzer assembly 'Roslynator.Formatting.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Resolve assembly 'Roslynator.Formatting.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator.Formatting.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Add analyzer assembly 'Roslynator.Formatting.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.CSharp.Workspaces, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.CSharp.Workspaces, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Workspaces.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Workspaces.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.CSharp, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.CSharp, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
Resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Unable to resolve assembly 'Roslynator_Formatting_Analyzers_Roslynator.Core, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'.
251 supported diagnostics with prefix 'RCS' (RCS0001, RCS0002, RCS0003, RCS0005, RCS0006, RCS0007, RCS0008, RCS0009, RCS0010, RCS0011, RCS0012, RCS0013, RCS0014, RCS0015, RCS0016, RCS0020, RCS0021, RCS0022, RCS0023, RCS0024, RCS0025, RCS0027, RCS0028, RCS0029, RCS0030, RCS0031, RCS0032, RCS0033, RCS0034, RCS0036, RCS0038, RCS0039, RCS0041, RCS0042, RCS0043, RCS0044, RCS0045, RCS0046, RCS0048, RCS0049, RCS0050, RCS0051, RCS0052, RCS0053, RCS0054, RCS0055, RCS0056, RCS0057, RCS0058, RCS0059, RCS0060, RCS1001, RCS1002, RCS1003, RCS1004, RCS1005, RCS1006, RCS1007, RCS1008, RCS1009, RCS1010, RCS1012, RCS1013, RCS1014, RCS1015, RCS1016, RCS1018, RCS1019, RCS1020, RCS1021, RCS1031, RCS1032, RCS1033, RCS1034, RCS1035, RCS1036, RCS1037, RCS1038, RCS1039, RCS1040, RCS1041, RCS1042, RCS1043, RCS1044, RCS1048, RCS1049, RCS1050, RCS1051, RCS1052, RCS1055, RCS1056, RCS1058, RCS1059, RCS1060, RCS1061, RCS1063, RCS1064, RCS1065, RCS1066, RCS1068, RCS1069, RCS1070, RCS1071, RCS1072, RCS1073, RCS1074, RCS1077, RCS1078, RCS1080, RCS1081, RCS1084, RCS1085, RCS1089, RCS1090, RCS1091, RCS1093, RCS1094, RCS1096, RCS1097, RCS1098, RCS1099, RCS1100, RCS1101, RCS1102, RCS1103, RCS1104, RCS1105, RCS1106, RCS1107, RCS1108, RCS1110, RCS1111, RCS1112, RCS1113, RCS1114, RCS1118, RCS1123, RCS1124, RCS1126, RCS1128, RCS1129, RCS1132, RCS1133, RCS1134, RCS1135, RCS1136, RCS1139, RCS1140, RCS1141, RCS1142, RCS1143, RCS1145, RCS1146, RCS1151, RCS1154, RCS1155, RCS1156, RCS1157, RCS1159, RCS1160, RCS1161, RCS1163, RCS1164, RCS1165, RCS1166, RCS1168, RCS1169, RCS1170, RCS1171, RCS1172, RCS1173, RCS1174, RCS1176, RCS1177, RCS1179, RCS1180, RCS1181, RCS1182, RCS1186, RCS1187, RCS1188, RCS1189, RCS1190, RCS1191, RCS1192, RCS1193, RCS1194, RCS1195, RCS1196, RCS1197, RCS1198, RCS1199, RCS1200, RCS1201, RCS1202, RCS1203, RCS1204, RCS1205, RCS1206, RCS1207, RCS1208, RCS1209, RCS1210, RCS1211, RCS1212, RCS1213, RCS1214, RCS1215, RCS1216, RCS1217, RCS1218, RCS1220, RCS1221, RCS1222, RCS1223, RCS1224, RCS1225, RCS1226, RCS1227, RCS1228, RCS1229, RCS1230, RCS1231, RCS1232, RCS1233, RCS1234, RCS1235, RCS1236, RCS1237, RCS1238, RCS1239, RCS1240, RCS1241, RCS1242, RCS1243, RCS1244, RCS1246, RCS1247, RCS1248, RCS1249, RCS1250, RCS1251, RCS1252, RCS1253, RCS1254, RCS1255, RCS1256, RCS1257, RCS1258, RCS1259, RCS1260)
  80 fixable diagnostics with prefix 'CA' (CA1001, CA1008, CA1012, CA1018, CA1019, CA1027, CA1028, CA1032, CA1033, CA1036, CA1052, CA1054, CA1064, CA1066, CA1067, CA1309, CA1311, CA1419, CA1421, CA1507, CA1707, CA1725, CA1726, CA1802, CA1805, CA1813, CA1815, CA1820, CA1821, CA1822, CA1823, CA1825, CA1826, CA1827, CA1828, CA1829, CA1830, CA1831, CA1832, CA1833, CA1834, CA1835, CA1836, CA1837, CA1839, CA1840, CA1841, CA1842, CA1843, CA1845, CA1846, CA1847, CA1850, CA1852, CA1853, CA1854, CA1855, CA2007, CA2009, CA2016, CA2101, CA2119, CA2200, CA2208, CA2215, CA2217, CA2225, CA2226, CA2229, CA2231, CA2235, CA2237, CA2242, CA2244, CA2247, CA2249, CA2250, CA2251, CA2256, CA2257)
  2 fixable diagnostics with prefix 'CS' (CS0659, CS0660)
  251 fixable diagnostics with prefix 'RCS' (RCS0001, RCS0002, RCS0003, RCS0005, RCS0006, RCS0007, RCS0008, RCS0009, RCS0010, RCS0011, RCS0012, RCS0013, RCS0014, RCS0015, RCS0016, RCS0020, RCS0021, RCS0022, RCS0023, RCS0024, RCS0025, RCS0027, RCS0028, RCS0029, RCS0030, RCS0031, RCS0032, RCS0033, RCS0034, RCS0036, RCS0038, RCS0039, RCS0041, RCS0042, RCS0043, RCS0044, RCS0045, RCS0046, RCS0048, RCS0049, RCS0050, RCS0051, RCS0052, RCS0053, RCS0054, RCS0055, RCS0056, RCS0057, RCS0058, RCS0059, RCS0060, RCS1001, RCS1002, RCS1003, RCS1004, RCS1005, RCS1006, RCS1007, RCS1008, RCS1009, RCS1010, RCS1012, RCS1013, RCS1014, RCS1015, RCS1016, RCS1018, RCS1019, RCS1020, RCS1021, RCS1031, RCS1032, RCS1033, RCS1034, RCS1035, RCS1036, RCS1037, RCS1038, RCS1039, RCS1040, RCS1041, RCS1042, RCS1043, RCS1044, RCS1048, RCS1049, RCS1050, RCS1051, RCS1052, RCS1055, RCS1056, RCS1058, RCS1059, RCS1060, RCS1061, RCS1063, RCS1064, RCS1065, RCS1066, RCS1068, RCS1069, RCS1070, RCS1071, RCS1072, RCS1073, RCS1074, RCS1077, RCS1078, RCS1080, RCS1081, RCS1084, RCS1085, RCS1089, RCS1090, RCS1091, RCS1093, RCS1094, RCS1096, RCS1097, RCS1098, RCS1099, RCS1100, RCS1101, RCS1102, RCS1103, RCS1104, RCS1105, RCS1106, RCS1107, RCS1108, RCS1110, RCS1111, RCS1112, RCS1113, RCS1114, RCS1118, RCS1123, RCS1124, RCS1126, RCS1128, RCS1129, RCS1132, RCS1133, RCS1134, RCS1135, RCS1136, RCS1139, RCS1140, RCS1141, RCS1142, RCS1143, RCS1145, RCS1146, RCS1151, RCS1154, RCS1155, RCS1156, RCS1157, RCS1159, RCS1160, RCS1161, RCS1163, RCS1164, RCS1165, RCS1166, RCS1168, RCS1169, RCS1170, RCS1171, RCS1172, RCS1173, RCS1174, RCS1176, RCS1177, RCS1179, RCS1180, RCS1181, RCS1182, RCS1186, RCS1187, RCS1188, RCS1189, RCS1190, RCS1191, RCS1192, RCS1193, RCS1194, RCS1195, RCS1196, RCS1197, RCS1198, RCS1199, RCS1200, RCS1201, RCS1202, RCS1203, RCS1204, RCS1205, RCS1206, RCS1207, RCS1208, RCS1209, RCS1210, RCS1211, RCS1212, RCS1213, RCS1214, RCS1215, RCS1216, RCS1217, RCS1218, RCS1220, RCS1221, RCS1222, RCS1223, RCS1224, RCS1225, RCS1226, RCS1227, RCS1228, RCS1229, RCS1230, RCS1231, RCS1232, RCS1233, RCS1234, RCS1235, RCS1236, RCS1237, RCS1238, RCS1239, RCS1240, RCS1241, RCS1242, RCS1243, RCS1244, RCS1246, RCS1247, RCS1248, RCS1249, RCS1250, RCS1251, RCS1252, RCS1253, RCS1254, RCS1255, RCS1256, RCS1257, RCS1258, RCS1259, RCS1260)

@josefpihrt
Copy link
Collaborator

josefpihrt commented Nov 7, 2023

@bdovaz I can confirm the same behavior on my local machine (outside of docker).

I have a fix which works on my local machine, can you try it and let me know if it works for you?

It's this PR: #1237

  1. Checkout the PR
  2. Run tools/reinstall_cli.ps1 (which will replace installed Roslynator CLI with locally built package)

@bdovaz
Copy link
Contributor Author

bdovaz commented Nov 9, 2023

@josefpihrt no Roslynator analyzers in logs

Steps I have followed:

  1. Clone main (the PR you already merge it so there is no original branch).
  2. Execute tools/reinstall_cli.ps1
  3. I copied src\CommandLine\bin\Release\Roslynator.DotNet.Cli.1.0.0.nupkg to the nuget folder.
  4. I have used this Dockerfile that you put Cannot be used from a Docker container #1060 (comment) changing 0.6.1 to 1.0.0.0
  5. Docker command: docker build . --tag roslynator_test && docker run roslynator_test

Used csproj #1060 (comment)

Output:

Roslynator Version: 1.0.0.0
Roslynator Target Framework: .NET Core
Roslyn Version: 4.7.0.0
Available MSBuild locations:
  .NET Core SDK, Version: 7.0.104, Path: /usr/lib/dotnet/sdk/7.0.104
MSBuild location is '/usr/lib/dotnet/sdk/7.0.104'
Load project '/data/csharp_project.csproj'
  Evaluate  00:00.34  csharp_project.csproj
  Build     00:00.52  csharp_project.csproj
  Msbuild failed when processing the file '/data/csharp_project.csproj' with message: /usr/lib/dotnet/sdk/7.0.104/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets: (267, 5): The "ResolvePackageAssets" task failed unexpectedly.
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages'.
   at NuGet.Packaging.FallbackPackagePathResolver..ctor(String userPackageFolder, IEnumerable`1 fallbackPackageFolders)
   at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable`1 packageFolders)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
   at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
  Resolve   00:00.15  csharp_project.csproj (net7.0)
Done loading project '/data/csharp_project.csproj'
Fix 'csharp_project'
Add analyzer assembly 'Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Add analyzer assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Add analyzer assembly 'Microsoft.Interop.LibraryImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Add analyzer assembly 'System.Text.RegularExpressions.Generator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  79 supported diagnostics with prefix 'CA' (CA1001, CA1008, CA1012, CA1018, CA1019, CA1027, CA1028, CA1032, CA1033, CA1036, CA1052, CA1054, CA1064, CA1066, CA1067, CA1309, CA1311, CA1419, CA1421, CA1507, CA1707, CA1725, CA1802, CA1805, CA1813, CA1815, CA1820, CA1821, CA1822, CA1823, CA1825, CA1826, CA1827, CA1828, CA1829, CA1830, CA1831, CA1832, CA1833, CA1834, CA1835, CA1836, CA1837, CA1839, CA1840, CA1841, CA1842, CA1843, CA1845, CA1846, CA1847, CA1850, CA1852, CA1853, CA1854, CA1855, CA2007, CA2009, CA2016, CA2101, CA2119, CA2200, CA2208, CA2215, CA2217, CA2225, CA2226, CA2229, CA2231, CA2235, CA2237, CA2242, CA2244, CA2247, CA2249, CA2250, CA2251, CA2256, CA2257)
  3 supported diagnostics with prefix 'SYSLIB' (SYSLIB1045, SYSLIB1054, SYSLIB1057)
  80 fixable diagnostics with prefix 'CA' (CA1001, CA1008, CA1012, CA1018, CA1019, CA1027, CA1028, CA1032, CA1033, CA1036, CA1052, CA1054, CA1064, CA1066, CA1067, CA1309, CA1311, CA1419, CA1421, CA1507, CA1707, CA1725, CA1726, CA1802, CA1805, CA1813, CA1815, CA1820, CA1821, CA1822, CA1823, CA1825, CA1826, CA1827, CA1828, CA1829, CA1830, CA1831, CA1832, CA1833, CA1834, CA1835, CA1836, CA1837, CA1839, CA1840, CA1841, CA1842, CA1843, CA1845, CA1846, CA1847, CA1850, CA1852, CA1853, CA1854, CA1855, CA2007, CA2009, CA2016, CA2101, CA2119, CA2200, CA2208, CA2215, CA2217, CA2225, CA2226, CA2229, CA2231, CA2235, CA2237, CA2242, CA2244, CA2247, CA2249, CA2250, CA2251, CA2256, CA2257)
  2 fixable diagnostics with prefix 'CS' (CS0659, CS0660)
  4 fixable diagnostics with prefix 'SYSLIB' (SYSLIB1045, SYSLIB1051, SYSLIB1054, SYSLIB1057)
  Compile 'csharp_project'
  Analyze 'csharp_project'
Done fixing project '/data/csharp_project.csproj' in 00:03.11

@josefpihrt
Copy link
Collaborator

I would call it a progress 😀.

Anyway, it looks like a issue with Microsoft.Build.Locator. Do you think you could create an issue in their repo? They will likely give some relevant feedback.

There is also a possibility that the issue has been fixed in the latest version of Microsoft.Build.Locator 1.6.10. Currently used version is 1.6.1. PR #1240 contains latest version of locator so you can try it.

@bdovaz
Copy link
Contributor Author

bdovaz commented Nov 9, 2023

Same result...

The thing is that as I say, outside of Docker is fine, the problem is when using it inside Docker...

What I do not understand is why you blame it to Microsoft.Build.Locator, seeing the code you do it with a class of this repository called AnalyzerAssemblyLoader no?

@josefpihrt
Copy link
Collaborator

I don't see AnalyzerAssemblyLoader in the callstack but I see Microsoft.Build... there so I think that it's reasonable to report it in Microsoft.Build.Locator repo.

@bdovaz
Copy link
Contributor Author

bdovaz commented Nov 9, 2023

@josefpihrt "NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder" has nothing to do with Microsoft.Build.Locator, the key is:

https://stackoverflow.com/a/70181962/699056

I already had bin / obj folder when running docker command.

The other problem is that if I don't add in the Dockerfile:

RUN dotnet restore /data/csharp_project.csproj.

Before executing the fix command of the Roslynator cli, it does not find anything.

Output:

Roslynator Version: 1.0.0.0
Roslynator Target Framework: .NET Core
Roslyn Version: 4.7.0.0
Available MSBuild locations:
  .NET Core SDK, Version: 7.0.104, Path: /usr/lib/dotnet/sdk/7.0.104
MSBuild location is '/usr/lib/dotnet/sdk/7.0.104'
Load project '/data/csharp_project.csproj'
  Evaluate  00:00.34  csharp_project.csproj
  Build     00:00.38  csharp_project.csproj
  Resolve   00:00.11  csharp_project.csproj (net7.0)
Done loading project '/data/csharp_project.csproj'
Fix 'csharp_project'
Add analyzer assembly 'Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Add analyzer assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Version=7.0.7.5901, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Add analyzer assembly 'Roslynator.CSharp.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Add analyzer assembly 'Roslynator.CSharp.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Add analyzer assembly 'Roslynator.Formatting.Analyzers.CodeFixes, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Add analyzer assembly 'Roslynator.Formatting.Analyzers, Version=4.6.1.0, Culture=neutral, PublicKeyToken=926ea54d246a765e'
Add analyzer assembly 'Microsoft.Interop.LibraryImportGenerator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Add analyzer assembly 'System.Text.RegularExpressions.Generator, Version=7.0.8.16401, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  79 supported diagnostics with prefix 'CA' (CA1001, CA1008, CA1012, CA1018, CA1019, CA1027, CA1028, CA1032, CA1033, CA1036, CA1052, CA1054, CA1064, CA1066, CA1067, CA1309, CA1311, CA1419, CA1421, CA1507, CA1707, CA1725, CA1802, CA1805, CA1813, CA1815, CA1820, CA1821, CA1822, CA1823, CA1825, CA1826, CA1827, CA1828, CA1829, CA1830, CA1831, CA1832, CA1833, CA1834, CA1835, CA1836, CA1837, CA1839, CA1840, CA1841, CA1842, CA1843, CA1845, CA1846, CA1847, CA1850, CA1852, CA1853, CA1854, CA1855, CA2007, CA2009, CA2016, CA2101, CA2119, CA2200, CA2208, CA2215, CA2217, CA2225, CA2226, CA2229, CA2231, CA2235, CA2237, CA2242, CA2244, CA2247, CA2249, CA2250, CA2251, CA2256, CA2257)
  251 supported diagnostics with prefix 'RCS' (RCS0001, RCS0002, RCS0003, RCS0005, RCS0006, RCS0007, RCS0008, RCS0009, RCS0010, RCS0011, RCS0012, RCS0013, RCS0014, RCS0015, RCS0016, RCS0020, RCS0021, RCS0022, RCS0023, RCS0024, RCS0025, RCS0027, RCS0028, RCS0029, RCS0030, RCS0031, RCS0032, RCS0033, RCS0034, RCS0036, RCS0038, RCS0039, RCS0041, RCS0042, RCS0043, RCS0044, RCS0045, RCS0046, RCS0048, RCS0049, RCS0050, RCS0051, RCS0052, RCS0053, RCS0054, RCS0055, RCS0056, RCS0057, RCS0058, RCS0059, RCS0060, RCS1001, RCS1002, RCS1003, RCS1004, RCS1005, RCS1006, RCS1007, RCS1008, RCS1009, RCS1010, RCS1012, RCS1013, RCS1014, RCS1015, RCS1016, RCS1018, RCS1019, RCS1020, RCS1021, RCS1031, RCS1032, RCS1033, RCS1034, RCS1035, RCS1036, RCS1037, RCS1038, RCS1039, RCS1040, RCS1041, RCS1042, RCS1043, RCS1044, RCS1048, RCS1049, RCS1050, RCS1051, RCS1052, RCS1055, RCS1056, RCS1058, RCS1059, RCS1060, RCS1061, RCS1063, RCS1064, RCS1065, RCS1066, RCS1068, RCS1069, RCS1070, RCS1071, RCS1072, RCS1073, RCS1074, RCS1077, RCS1078, RCS1080, RCS1081, RCS1084, RCS1085, RCS1089, RCS1090, RCS1091, RCS1093, RCS1094, RCS1096, RCS1097, RCS1098, RCS1099, RCS1100, RCS1101, RCS1102, RCS1103, RCS1104, RCS1105, RCS1106, RCS1107, RCS1108, RCS1110, RCS1111, RCS1112, RCS1113, RCS1114, RCS1118, RCS1123, RCS1124, RCS1126, RCS1128, RCS1129, RCS1132, RCS1133, RCS1134, RCS1135, RCS1136, RCS1139, RCS1140, RCS1141, RCS1142, RCS1143, RCS1145, RCS1146, RCS1151, RCS1154, RCS1155, RCS1156, RCS1157, RCS1159, RCS1160, RCS1161, RCS1163, RCS1164, RCS1165, RCS1166, RCS1168, RCS1169, RCS1170, RCS1171, RCS1172, RCS1173, RCS1174, RCS1176, RCS1177, RCS1179, RCS1180, RCS1181, RCS1182, RCS1186, RCS1187, RCS1188, RCS1189, RCS1190, RCS1191, RCS1192, RCS1193, RCS1194, RCS1195, RCS1196, RCS1197, RCS1198, RCS1199, RCS1200, RCS1201, RCS1202, RCS1203, RCS1204, RCS1205, RCS1206, RCS1207, RCS1208, RCS1209, RCS1210, RCS1211, RCS1212, RCS1213, RCS1214, RCS1215, RCS1216, RCS1217, RCS1218, RCS1220, RCS1221, RCS1222, RCS1223, RCS1224, RCS1225, RCS1226, RCS1227, RCS1228, RCS1229, RCS1230, RCS1231, RCS1232, RCS1233, RCS1234, RCS1235, RCS1236, RCS1237, RCS1238, RCS1239, RCS1240, RCS1241, RCS1242, RCS1243, RCS1244, RCS1246, RCS1247, RCS1248, RCS1249, RCS1250, RCS1251, RCS1252, RCS1253, RCS1254, RCS1255, RCS1256, RCS1257, RCS1258, RCS1259, RCS1260)
  3 supported diagnostics with prefix 'SYSLIB' (SYSLIB1045, SYSLIB1054, SYSLIB1057)
  80 fixable diagnostics with prefix 'CA' (CA1001, CA1008, CA1012, CA1018, CA1019, CA1027, CA1028, CA1032, CA1033, CA1036, CA1052, CA1054, CA1064, CA1066, CA1067, CA1309, CA1311, CA1419, CA1421, CA1507, CA1707, CA1725, CA1726, CA1802, CA1805, CA1813, CA1815, CA1820, CA1821, CA1822, CA1823, CA1825, CA1826, CA1827, CA1828, CA1829, CA1830, CA1831, CA1832, CA1833, CA1834, CA1835, CA1836, CA1837, CA1839, CA1840, CA1841, CA1842, CA1843, CA1845, CA1846, CA1847, CA1850, CA1852, CA1853, CA1854, CA1855, CA2007, CA2009, CA2016, CA2101, CA2119, CA2200, CA2208, CA2215, CA2217, CA2225, CA2226, CA2229, CA2231, CA2235, CA2237, CA2242, CA2244, CA2247, CA2249, CA2250, CA2251, CA2256, CA2257)
  2 fixable diagnostics with prefix 'CS' (CS0659, CS0660)
  251 fixable diagnostics with prefix 'RCS' (RCS0001, RCS0002, RCS0003, RCS0005, RCS0006, RCS0007, RCS0008, RCS0009, RCS0010, RCS0011, RCS0012, RCS0013, RCS0014, RCS0015, RCS0016, RCS0020, RCS0021, RCS0022, RCS0023, RCS0024, RCS0025, RCS0027, RCS0028, RCS0029, RCS0030, RCS0031, RCS0032, RCS0033, RCS0034, RCS0036, RCS0038, RCS0039, RCS0041, RCS0042, RCS0043, RCS0044, RCS0045, RCS0046, RCS0048, RCS0049, RCS0050, RCS0051, RCS0052, RCS0053, RCS0054, RCS0055, RCS0056, RCS0057, RCS0058, RCS0059, RCS0060, RCS1001, RCS1002, RCS1003, RCS1004, RCS1005, RCS1006, RCS1007, RCS1008, RCS1009, RCS1010, RCS1012, RCS1013, RCS1014, RCS1015, RCS1016, RCS1018, RCS1019, RCS1020, RCS1021, RCS1031, RCS1032, RCS1033, RCS1034, RCS1035, RCS1036, RCS1037, RCS1038, RCS1039, RCS1040, RCS1041, RCS1042, RCS1043, RCS1044, RCS1048, RCS1049, RCS1050, RCS1051, RCS1052, RCS1055, RCS1056, RCS1058, RCS1059, RCS1060, RCS1061, RCS1063, RCS1064, RCS1065, RCS1066, RCS1068, RCS1069, RCS1070, RCS1071, RCS1072, RCS1073, RCS1074, RCS1077, RCS1078, RCS1080, RCS1081, RCS1084, RCS1085, RCS1089, RCS1090, RCS1091, RCS1093, RCS1094, RCS1096, RCS1097, RCS1098, RCS1099, RCS1100, RCS1101, RCS1102, RCS1103, RCS1104, RCS1105, RCS1106, RCS1107, RCS1108, RCS1110, RCS1111, RCS1112, RCS1113, RCS1114, RCS1118, RCS1123, RCS1124, RCS1126, RCS1128, RCS1129, RCS1132, RCS1133, RCS1134, RCS1135, RCS1136, RCS1139, RCS1140, RCS1141, RCS1142, RCS1143, RCS1145, RCS1146, RCS1151, RCS1154, RCS1155, RCS1156, RCS1157, RCS1159, RCS1160, RCS1161, RCS1163, RCS1164, RCS1165, RCS1166, RCS1168, RCS1169, RCS1170, RCS1171, RCS1172, RCS1173, RCS1174, RCS1176, RCS1177, RCS1179, RCS1180, RCS1181, RCS1182, RCS1186, RCS1187, RCS1188, RCS1189, RCS1190, RCS1191, RCS1192, RCS1193, RCS1194, RCS1195, RCS1196, RCS1197, RCS1198, RCS1199, RCS1200, RCS1201, RCS1202, RCS1203, RCS1204, RCS1205, RCS1206, RCS1207, RCS1208, RCS1209, RCS1210, RCS1211, RCS1212, RCS1213, RCS1214, RCS1215, RCS1216, RCS1217, RCS1218, RCS1220, RCS1221, RCS1222, RCS1223, RCS1224, RCS1225, RCS1226, RCS1227, RCS1228, RCS1229, RCS1230, RCS1231, RCS1232, RCS1233, RCS1234, RCS1235, RCS1236, RCS1237, RCS1238, RCS1239, RCS1240, RCS1241, RCS1242, RCS1243, RCS1244, RCS1246, RCS1247, RCS1248, RCS1249, RCS1250, RCS1251, RCS1252, RCS1253, RCS1254, RCS1255, RCS1256, RCS1257, RCS1258, RCS1259, RCS1260)
  4 fixable diagnostics with prefix 'SYSLIB' (SYSLIB1045, SYSLIB1051, SYSLIB1054, SYSLIB1057)
  Compile 'csharp_project'
  Analyze 'csharp_project'
  Found 3 diagnostics in 'csharp_project'
  Fix 1 RCS1102 'Make class static.'
    Test.cs(5,11): error RCS1102: Make class static.
  Fix 1 RCS1118 'Mark local variable as const.'
    Test.cs(9,13): error RCS1118: Mark local variable as const.
  Fix 1 RCS1163 'Unused parameter.'
    Test.cs(7,26): error RCS1163: Unused parameter 'args'.
  Fixer 'Roslynator.CSharp.CodeFixes.UnusedParameterCodeFixProvider' registered no action for diagnostic 'RCS1163'
    Test.cs(7,26): error RCS1163: Unused parameter 'args'.
  Compile 'csharp_project' iteration 2
  Analyze 'csharp_project'
  Found 1 diagnostic in 'csharp_project'
  Fix 1 RCS1163 'Unused parameter.'
    Test.cs(7,26): error RCS1163: Unused parameter 'args'.
  Fixer 'Roslynator.CSharp.CodeFixes.UnusedParameterCodeFixProvider' registered no action for diagnostic 'RCS1163'
    Test.cs(7,26): error RCS1163: Unused parameter 'args'.
  Compile 'csharp_project' iteration 3
  Analyze 'csharp_project'
  Unfixed diagnostics:
    1 RCS1163 Unused parameter.
      Test.cs(7,26): error RCS1163: Unused parameter 'args'.
  Fixed diagnostics:
    1 RCS1102 Make class static.
      Test.cs(5,11): error RCS1102: Make class static.
    1 RCS1118 Mark local variable as const.
      Test.cs(9,13): error RCS1118: Mark local variable as const.
Done fixing project '/data/csharp_project.csproj' in 00:03.83

Unfixed diagnostics:
  1 RCS1163 Unused parameter.

Fixed diagnostics:
  1 RCS1102 Make class static.
  1 RCS1118 Mark local variable as const.

2 diagnostics fixed

@bdovaz
Copy link
Contributor Author

bdovaz commented Nov 9, 2023

@josefpihrt is that for me the clearest confusion comes from the fact that I thought that the Roslynator cli already included all the Roslynator analyzers / fixers implicitly, not that you had to have the NuGet package installed in the csproj itself. I find the setup confusing.

@josefpihrt
Copy link
Collaborator

It's great that the problem has been solved!

Actually, the very early versions of CLI contains Roslynator analyzers, but it turned out that it's not a good practice. First of all, you have to bind CLI version with analyzers versions, which is not good.

But the main question is what is the use case for this feature? Let's say that you have a project that does not reference roslynator.analyzers and you want to run roslynator fix as a one-time operation. But why wouldn't you reference roslynator.analyzers in that project. You most definitely want the analyzers/rules to be enforced in IDE, CI/CD etc. So I don't see a use case for Roslynator analyzers to be included in CLI.

But the documentation could be improved to make this more clear, see #1241.

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

Successfully merging a pull request may close this issue.

3 participants