dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

[Bug]: NRE in at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__44.MoveNext() #10180

Closed Evangelink closed 5 months ago

Evangelink commented 5 months ago

Issue Description

MSBUILD : error : This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices .UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj] MSBUILD : error : System.NullReferenceException: Object reference not set to an instance of an object. [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices. UnitTests.csproj] MSBUILD : error : at Microsoft.Build.BackEnd.TargetEntry.d44.MoveNext() [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.cspro j] MSBUILD : error : --- End of stack trace from previous location where exception was thrown --- [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.cs proj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests .csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.Platf ormServices.UnitTests.csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj ] MSBUILD : error : at Microsoft.Build.BackEnd.TargetBuilder.d23.MoveNext() [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTest s.csproj] MSBUILD : error : --- End of stack trace from previous location where exception was thrown --- [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.cs proj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests .csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.Platf ormServices.UnitTests.csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj ] MSBUILD : error : at Microsoft.Build.BackEnd.TargetBuilder.d10.MoveNext() [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.cspr oj] MSBUILD : error : --- End of stack trace from previous location where exception was thrown --- [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.cs proj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests .csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.Platf ormServices.UnitTests.csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj ] MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.d67.MoveNext() [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csp roj] MSBUILD : error : --- End of stack trace from previous location where exception was thrown --- [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.cs proj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests .csproj] MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.Platf ormServices.UnitTests.csproj] MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.d__58.MoveNext() [C:\src\testfx\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTest s.csproj]

Steps to Reproduce

Checkout https://github.com/microsoft/testfx/pull/2973 and run .\Build.cmd /p:NuGetInteractive=true -pack -test -integrationTest

Expected Behavior

No error

Actual Behavior

NRE

Analysis

No response

Versions & Configurations

No response

ladipro commented 5 months ago

@Evangelink can you please add the version of MSBuild where you're hitting this? Preferably including the commit hash.

Evangelink commented 5 months ago

I am using arcade on MSTest repo:

From binlog: MSBuild version = "17.11.0-preview-24273-01+147ecadd1"

ladipro commented 5 months ago

Thank you. This is likely related to #10102. I have recently hit the ItemBucket.Initialize was not properly called assert when running debug MSBuild, which I believe is the same issue, but couldn't reproduce it consistently.

ladipro commented 5 months ago

Simple repro:

<Project>

    <ItemGroup>
        <Example Include="Item1">
            <Color>Blue</Color>
        </Example>
        <Example Include="Item2">
            <Color>Red</Color>
        </Example>
    </ItemGroup>

    <Target Name="Build"
        Inputs="@(Example)"
        Outputs="%(Color)\MyFile.txt">
        <NonExistentTask
            Text = "@(Example)"
            Output = "%(Color)\MyFile.txt"/>
    </Target>

</Project>