dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

Test runner use wrong configuration for build #3578

Open MikeVitik opened 4 years ago

MikeVitik commented 4 years ago

Steps to reproduce

  1. Unpack attached archive UnitTests.zip

  2. Open it in Visual Studio Code

  3. Restore projects nuget's and run the build task

  4. Open .\tests\UnitTest1.cs

  5. Try to run Test1

Result: Test doesn't run because of '.\lib\lib.csproj' project build in 'Debug' configuration not in 'TestDebug'. See .\lib\Class1.cs for more details I try to solve this problem using .\omnisharp.json config with:

{
    "msbuild": {
        "Configuration": "DebugTest"

    }
}

----- Running test method "tests.Tests.Test1" -----

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

lib -> d:\temp\UnitTests\lib\bin\Debug\netstandard2.0\lib.dll UnitTest1.cs(16,29): error CS0103: The name 'lib' does not exist in the current context [d:\temp\UnitTests\tests\tests.csproj]

Build FAILED.

UnitTest1.cs(16,29): error CS0103: The name 'lib' does not exist in the current context [d:\temp\UnitTests\tests\tests.csproj] 0 Warning(s) 1 Error(s)

Time Elapsed 00:00:02.24 -->

Environment data

.NET Core SDK (reflecting any global.json): Version: 3.1.101 Commit: b377529961

Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support): Version: 3.1.1 Commit: a1388f194c

.NET Core SDKs installed: 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.801 [C:\Program Files\dotnet\sdk] 2.2.101 [C:\Program Files\dotnet\sdk] 3.0.100-preview7-012821 [C:\Program Files\dotnet\sdk] 3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.101 [C:\Program Files\dotnet\sdk]

VS Code version: 1.42 C# Extension version: 1.21.11

berdon commented 4 years ago

Any chance this could see some action? There's no way to debug unit tests in non-debug build configurations. Nor is there any way to leverage a compile time constant to achieve the same thing because you can't supply any arguments used during the forced build that occurs prior to running a test.