-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Comments
Hi, I tried to use official image for .NET SDK 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. |
@josefpihrt but the thing is that with csharpier it works and it is also another tool, it only happens with roslynator this problem. |
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)? |
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. |
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. |
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. |
Temporary solved with #1079. I would keep this issue open till the root cause is fixed. |
@josefpihrt you are going to release a new release in NuGet, right? Thanks! |
@josefpihrt I have encountered another problem. With the above case I now get:
If I try from outside a container, it works. If I change the to Edit: I think the problem comes from here: |
@josefpihrt have you been able to investigate something? The problem as I say arises from that class and specifically in the Why do you override the resolution of certain assemblies? Thanks. |
@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:
Dockerfile:
If you want to try it then just do following steps:
|
@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! |
@josefpihrt The only thing I find strange is the
` |
@bdovaz sorry for the delay.
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? |
@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. |
@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:
|
@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
|
@josefpihrt no Roslynator analyzers in logs Steps I have followed:
Used csproj #1060 (comment) Output:
|
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 |
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 |
I don't see |
@josefpihrt "NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder" has nothing to do with 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:
Before executing the fix command of the Roslynator cli, it does not find anything. Output:
|
@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. |
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 But the documentation could be improved to make this more clear, see #1241. |
Product and Version Used: 0.5.0
Steps to Reproduce:
csharp_project.csproj
:Test.cs
:Dockerfile
:docker build . --tag roslynator_test && docker run roslynator_test
Actual Behavior:
Expected Behavior:
It should work.
If I do the same with a similar tool, it works instead, so the problem is in Roslynator.
Output:
@josefpihrt we want to integrate it into MegaLinter but this issue is a stopper for us.
The text was updated successfully, but these errors were encountered: