Skip to content

Add test coverage for NetCoreSdkRoot fallback logic in TaskHostFactory#13178

Closed
Copilot wants to merge 2 commits into
NetCoreSdkRootfrom
copilot/sub-pr-13176
Closed

Add test coverage for NetCoreSdkRoot fallback logic in TaskHostFactory#13178
Copilot wants to merge 2 commits into
NetCoreSdkRootfrom
copilot/sub-pr-13176

Add test coverage for NetCoreSdkRoot fallback scenarios

4e970c1
Select commit
Loading
Failed to load commit list.
Azure Pipelines / msbuild-pr failed Feb 2, 2026 in 48m 52s

Build #20260202.46 had test failures

Details

Tests

  • Failed: 10 (0.02%)
  • Passed: 58,319 (97.78%)
  • Other: 1,315 (2.20%)
  • Total: 59,644

Annotations

Check failure on line 0 in VSTest

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

VSTest#L0

VSTest(0,0): error : (NETCORE_ENGINEERING_TELEMETRY=Build) Tests failed: D:\a\1\s\artifacts\TestResults\Debug\Microsoft.Build.Engine.UnitTests_net472_x86.html [net472|x86]

Check failure on line 0 in VSTest

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

VSTest#L0

VSTest(0,0): error : (NETCORE_ENGINEERING_TELEMETRY=Build) Tests failed: D:\a\1\s\artifacts\TestResults\Debug\Microsoft.Build.Engine.UnitTests_net472_x86.html [net472|x86]

Check failure on line 0 in VSTest

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

VSTest#L0

VSTest(0,0): error : (NETCORE_ENGINEERING_TELEMETRY=Build) Tests failed: D:\a\_work\1\s\artifacts\TestResults\Release\Microsoft.Build.Engine.UnitTests_net472_x86.html [net472|x86]

Check failure on line 1 in Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithRuntimeIdentifierGraphPath_FallsBackToRIDGraph

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithRuntimeIdentifierGraphPath_FallsBackToRIDGraph

Shouldly.ShouldAssertException : testTaskOutput.ShouldContain($"The task is executed in process: dotnet");
            testTaskOutput.ShouldContain($"Process path: {dotnetPath}", customMessage: testTaskOutput);
            testTaskOutput.ShouldContain("RIDGraphFallback test");
        }

        [WindowsFullFrameworkOnlyFact]
        public void NetTaskHost_WithNoSDKProperties_StillSucceeds()
        {
            using TestEnvironment env = TestEnvironment.Create(_output);

            string testProjectPath = Path.Combine(TestAssetsRootPath, "ExampleNetTask", "TestNoSDKProperties", "TestNoSDKProperties.csproj");

            string testTaskOutput = RunnerUtilities.ExecBootstrapedMSBuild($"{testProjectPath} -restore -v:n", out bool successTestTask);

            if (!successTestTask)
            {
                _output.WriteLine(testTaskOutput);
            }

            // The task should still succeed even without SDK properties
            // This tests the scenario where the fallback returns original parameters
            successTestTask
    should be
True
    but was
False
Raw output
   at Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithRuntimeIdentifierGraphPath_FallsBackToRIDGraph() in D:\a\_work\1\s\src\Build.UnitTests\NetTaskHost_E2E_Tests.cs:line 204

Check failure on line 1 in Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithRIDGraphPathAtRoot_HandlesEdgeCase

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithRIDGraphPathAtRoot_HandlesEdgeCase

Shouldly.ShouldAssertException : Shouldly uses your source code to generate its great error messages, build your test project with full debug information to get better error messages
The provided expression
    should be
True
    but was
False
Raw output
   at Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithRIDGraphPathAtRoot_HandlesEdgeCase() in D:\a\_work\1\s\src\Build.UnitTests\NetTaskHost_E2E_Tests.cs:line 247

Check failure on line 1 in Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithNetCoreSdkRootSet_UsesNetCoreSdkRootDirectly

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithNetCoreSdkRootSet_UsesNetCoreSdkRootDirectly

Shouldly.ShouldAssertException : testTaskOutput.ShouldContain($"The task is executed in process: dotnet");
            testTaskOutput.ShouldContain($"Process path: {dotnetPath}", customMessage: testTaskOutput);
            testTaskOutput.ShouldContain("NetCoreSdkRoot test:");
        }

        [WindowsFullFrameworkOnlyFact]
        public void NetTaskHost_WithRuntimeIdentifierGraphPath_FallsBackToRIDGraph()
        {
            using TestEnvironment env = TestEnvironment.Create(_output);
            var dotnetPath = env.GetEnvironmentVariable("DOTNET_ROOT");

            string testProjectPath = Path.Combine(TestAssetsRootPath, "ExampleNetTask", "TestRIDGraphFallback", "TestRIDGraphFallback.csproj");

            string testTaskOutput = RunnerUtilities.ExecBootstrapedMSBuild($"{testProjectPath} -restore -v:n", out bool successTestTask);

            if (!successTestTask)
            {
                _output.WriteLine(testTaskOutput);
            }

            successTestTask
    should be
True
    but was
False
Raw output
   at Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithNetCoreSdkRootSet_UsesNetCoreSdkRootDirectly() in D:\a\_work\1\s\src\Build.UnitTests\NetTaskHost_E2E_Tests.cs:line 182

Check failure on line 1 in Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithNetCoreSdkRootSet_UsesNetCoreSdkRootDirectly

See this annotation in the file changed.

@azure-pipelines azure-pipelines / msbuild-pr

Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithNetCoreSdkRootSet_UsesNetCoreSdkRootDirectly

Shouldly.ShouldAssertException : successTestTask
    should be
True
    but was
False
Raw output
   at Microsoft.Build.Engine.UnitTests.NetTaskHost_E2E_Tests.NetTaskHost_WithNetCoreSdkRootSet_UsesNetCoreSdkRootDirectly() in D:\a\1\s\src\Build.UnitTests\NetTaskHost_E2E_Tests.cs:line 182