roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

Version 0.3.3 of roslynator.dotnet.cli does not work with .Net6

Open ikuosaito1989 opened this issue 3 years ago • 2 comments
trafficstars

summary:

Version 0.3.3 of roslynator.dotnet.cli does not work with .Net6 Version 0.3.0 behaves like Expected Behavior(Works as expected)

Product and Version Used:

Roslynator.DotNet.Cli 0.3.3 dotnet sdk: 6.0.300

Steps to Reproduce:

dotnet roslynator analyze

Actual Behavior:

if (hoge != null && hoge.Any())
$ dotnet roslynator analyze
Load solution '***.sln'
Done loading solution '***.sln'
Analyze solution '***.sln'
Analyze 'hoge' 1/1
Done analyzing solution '***.sln' in 00:03.36

0 diagnostics found

Expected Behavior:

if (hoge != null && hoge.Any())
$ dotnet roslynator analyze
Load solution '***.sln'
Done loading solution '***.sln'
Analyze solution '***.sln'
Analyze 'hoge' 1/1
  hoge/hoge.cs(289,17): info RCS1146: Use conditional access.
Done analyzing solution '***.sln' in 00:04.48

1 RCS1146 Use conditional access.

1 diagnostic found

ikuosaito1989 avatar Aug 19 '22 09:08 ikuosaito1989

Hi,

Roslynator should work with .NET 6 (as configured here)

Can you run the command with -v diag to see if there is any other problem?

josefpihrt avatar Aug 22 '22 12:08 josefpihrt

command and extracted the log

Roslynator Version: 0.3.3.0
Roslynator Target Framework: .NET Core
Roslyn Version: 4.2.0.0
Available MSBuild locations:
  .NET Core SDK, Version: 3.1.100, Path: /usr/local/share/dotnet/sdk/3.1.100/
  .NET Core SDK, Version: 5.0.408, Path: /usr/local/share/dotnet/sdk/5.0.408/
  .NET Core SDK, Version: 6.0.302, Path: /usr/local/share/dotnet/sdk/6.0.302/
MSBuild location is '/usr/local/share/dotnet/sdk/6.0.302/'
Load solution '/Users/*.sln'
  Evaluate  00:00.33  *.csproj
  Build     00:00.13  *.csproj
  ファイル '/Users/*.csproj' の処理中に MSBuild が次のメッセージで失敗しました: /usr/local/share/dotnet/sdk/6.0.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets: (129, 5): "ResolveAppHosts" タスクが予期せずに失敗しました。
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (0x80131621)
File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
 ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>g__TryLoadAssembly|3(AssemblyName assemblyName)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>b__2(AssemblyLoadContext _, AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at NuGet.RuntimeModel.JsonRuntimeFormat.ReadRuntimeGraph(TextReader textReader)
   at NuGet.RuntimeModel.JsonRuntimeFormat.ReadRuntimeGraph(Stream stream)
   at NuGet.RuntimeModel.JsonRuntimeFormat.ReadRuntimeGraph(String filePath)
   at Microsoft.NET.Build.Tasks.RuntimeGraphCache.GetRuntimeGraph(String runtimeJsonPath)
   at Microsoft.NET.Build.Tasks.ResolveAppHosts.GetHostItem(String runtimeIdentifier, List`1 knownAppHostPacksForTargetFramework, List`1 packagesToDownload, String hostNameWithoutExtension, String itemName, Boolean isExecutable, Boolean errorIfNotFound)
   at Microsoft.NET.Build.Tasks.ResolveAppHosts.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)
  Evaluate  00:00.04  *.csproj
  Build     00:00.20  *.csproj
  Resolve   00:00.05  *.csproj (net6.0)
  一致するメタデータ参照が含まれないプロジェクト参照が見つかりました: /Users/*.csproj
  Resolve   00:00.44  *.csproj (net6.0)

Sorry the log is in Japanese. How can I reflect the locale value es? I have already set DOTNET_CLI_UI_LANGUAGE=en

ikuosaito1989 avatar Aug 23 '22 01:08 ikuosaito1989

I have exactly the same problem, including failure to load Newtonsoft.Json.

avysk avatar Oct 24 '22 07:10 avysk

And it is not better with 7.0 RC 2:

Resolve assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Culture=neutral, PublicKeyToken=null'
Unable to resolve assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Culture=neutral, PublicKeyToken=null'.
Resolve assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Culture=neutral, PublicKeyToken=null'
Unable to resolve assembly 'Microsoft.CodeAnalysis.NetAnalyzers, Culture=neutral, PublicKeyToken=null'.

avysk avatar Oct 24 '22 07:10 avysk

A new version of Roslynator command-line tool was released recently. It contains updated reference to Microsoft.Build.Locator.

Can you try it if it helps?

As for .NET 7: it's not supported yet. When the stable version of .NET 7.0 is released it will be supported by Roslynator.

josefpihrt avatar Nov 06 '22 13:11 josefpihrt

I no longer see this exception. I have another problem but it is in a separate issue. I did not try net 7 yet, which, according to my knowledge, was released.

avysk avatar Nov 29 '22 06:11 avysk

@JosefPihrt

A new version of Roslynator command-line tool was released recently. It contains updated reference to Microsoft.Build.Locator.

I can confirm that it works fine with version 0.5.0. Thanks for your support!

ikuosaito1989 avatar Mar 24 '23 08:03 ikuosaito1989