microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
226 stars 11 forks source link

NUnit tests not being discovered for project on .Net 8 #772

Open jrbye opened 10 months ago

jrbye commented 10 months ago

Describe the Issue

I have a solution containing 6 test projects using SpecFlow and NUnit. Everything is using .Net 8. When I build I get the following logs once per Project:

2023-11-30 08:49:12.722 [error] (c:\Users\USER\source\repos\Automation\APIAutomation\APIAutomation.csproj): SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath) at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable1& errors, IEnumerable1& warnings)"" 2023-11-30 08:49:12.789 [error] Failed to load project 'c:\Users\USER\source\repos\Automation\APIAutomation\APIAutomation.csproj'. One or more errors occurred. (SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath) at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable1& errors, IEnumerable1& warnings)"" c:\Users\USER\source\repos\Automation\APIAutomation\APIAutomation.csproj)

The tests are not detected. I have deleted the workspaceStorage folder and restarted VSCode and the folder was recreated.

Steps To Reproduce

1.) Update a project to .Net 8.0 2.) Open project in VSCode and build it

Expected Behavior

The tests should snow up in the tests pane.

Environment Information

Latest VS Code Latest C# Dev Kit Extension (Even tried pre-release version) Windows 11

github-actions[bot] commented 6 months ago

This issue has been marked as stale after 14 days of inactivity. @[ @ @], could you please take a look?

Michael-Eng commented 5 months ago

@jrbye going through our older bugs. I think we've fixed an issue in this area when we added .NET8 support. Can you confirm if this is working for you now with the latest C# Dev Kit?

jrbye commented 5 months ago

@jrbye going through our older bugs. I think we've fixed an issue in this area when we added .NET8 support. Can you confirm if this is working for you now with the latest C# Dev Kit?

@Michael-Eng I am still seeing errors in VS Code

2024-04-26 16:48:26.668 [error] Failed to load project 'c:\Users\user\source\repos\solutionFolder\projectFolder\projectName.csproj'. One or more errors occurred. (SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath) at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable1& errors, IEnumerable1& warnings)"" c:\Users\user\source\repos\solutionFolder\projectFolder\projectName.csproj) 2024-04-26 16:48:26.692 [info] Project system initialization finished. 0 project(s) are loaded, and 7 failed to load.`

I am seeing this for every project. The tests are working is Visual Studio.

Michael-Eng commented 2 months ago

Going through our bugs, @jrbye I think this is an issue with .NET8 install on your machine.

it's not clear what platform/OS you are running on but in general, dotnet.exe needs to be on your path and running dotnet.exe --list-sdks

should list the .NET8 SDK for the same architecture of your extension in C# Dev Kit. Can you confirm if this issue still happens if it shows up when you list the sdks with dotnet.exe?

lifengl commented 2 months ago

Hey, @jrbye :

this is a very old thread. There was some problems in CDK with .NET 8 SDK, which should have been resolved. Can you try the recent version of the extension, and verify whether you still run into this problem?

jrbye commented 2 months ago

Hey, @jrbye :

this is a very old thread. There was some problems in CDK with .NET 8 SDK, which should have been resolved. Can you try the recent version of the extension, and verify whether you still run into this problem?

Everything is up to day and I am seeing the same exact errors in the Output Pane.

"2024-07-30 14:57:18.986 [info] Project system initialization finished. 0 project(s) are loaded, and 7 failed to load."