Reputation: 23
I have set up one Roslyn analyzer project that is reading properly the (external and internal) namespaces from Symbol (open solution in workspace -> read documents -> read classes -> read class symbol); however, when I created another xUnit project for adding some unit tests, I was not able to read anymore the namespaces that are external to the project (e.g. Microsoft.AspNetCore.Mvc.****).
Does someone know why is this happening? I also tried to run this same project (that was working) in a different machine and it was not reading the external namespaces neither. I have included the exact same packages in both projects but it is simply not working and showing ErrorTypeSymbol for symbols that have external namespaces.
Note: I open the Solution in the Workspace in the same way on both projects...
Edit: The error message is "This program location is thought to be unreachable.".
Edit 2: It seems like Microsoft.NET.Test.Sdk package is causing the problem and after checking in the Workspace.Diagnostics it shows the following error:
[Failure] Msbuild failed when processing the file '/home/username/RiderProjects/SampleApi/SampleApi/SampleApi.csproj' with message: /usr/share/dotnet/sdk/5.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets: (89, 5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.Frameworks, Version=5.11.1.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'NuGet.Frameworks, Version=5.11.1.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.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)
This is the .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Upvotes: 1
Views: 228
Reputation: 2221
Downgrade to 16.2.0 works fine. But it is not a good "solution".
I created an issue: https://github.com/microsoft/vstest/issues/4212
Upvotes: 0