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
221 stars 10 forks source link

[BUG] After creating a C# test project (xunit, nunit), the project will no longer build #1169

Open scaredcr6w opened 3 months ago

scaredcr6w commented 3 months ago

Describe the Issue

After adding any type of test project (xunit, nunit) the project will no longer build and the following errors are showing up:

dotnet build ../vscode bug/TestProject1/TestProject1.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary MSBuild version 17.9.8+b34f75857 for .NET Determining projects to restore... All projects are up-to-date for restore. ../vscode bug/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/obj/Debug/net8.0/vscode bug.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [../vscode bug/vscode bug.csproj] ../vscode bug/TestProject1/obj/Debug/net8.0/TestProject1.GlobalUsings.g.cs(9,22): error CS0400: The type or namespace name 'Xunit' could not be found in the global namespace (are you missing an assembly reference?) [../vscode bug/vscode bug.csproj] ../vscode bug/TestProject1/UnitTest1.cs(6,6): error CS0246: The type or namespace name 'FactAttribute' could not be found (are you missing a using directive or an assembly reference?) [../vscode bug/vscode bug.csproj] ../vscode bug/TestProject1/UnitTest1.cs(6,6): error CS0246: The type or namespace name 'Fact' could not be found (are you missing a using directive or an assembly reference?) [../vscode bug/vscode bug.csproj]

Steps To Reproduce

  1. Create a console application using 'dotnet new console --use-program-main'
  2. To the solution, add a new xunit test project
  3. Use 'dotnet build'

Expected Behavior

No response

Environment Information

Sleepwalker423 commented 3 months ago

Same exact issue here.

ocallesp commented 2 months ago

Which version of C# Dev Kit extension are you using ?

scaredcr6w commented 2 months ago

Which version of C# Dev Kit extension are you using ?

I'm using 1.7.27

ocallesp commented 2 months ago

Using VSCode to created and build.

On macOS, when using C# Dev Kit version 1.8.6 (pre-release) I found that creating a simple standalone xUnit project initializes the project system provider, but it fails to detect any containers or projects (DLLs)

That is not the case for nunit and mstest

with C# Dev Kit version 1.7.27 the standalone simple mstest/xunit/nunit work

ocallesp commented 2 months ago

@scaredcr6w could you please share a project that reproduces the issue ?

scaredcr6w commented 2 months ago

https://github.com/scaredcr6w/csharpTestsBug