dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.05k forks source link

[Bug]: Microsoft.NET.Sdk.targets(176,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly. #30755

Open abatishchev opened 1 year ago

abatishchev commented 1 year ago

Issue Description

ADO build failed unexpectedly with a generic NRE exception:

##[error]C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(176,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.NET.Build.Tasks.ReferenceInfo.GetVersion(ITaskItem referencePath)
   at Microsoft.NET.Build.Tasks.ReferenceInfo.CreateReferenceInfo(ITaskItem referencePath)
   at Microsoft.NET.Build.Tasks.ReferenceInfo.CreateReferenceInfos(IEnumerable`1 referencePaths)
   at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
   at Microsoft.NET.Build.Tasks.GenerateDepsFile.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Steps to Reproduce

n/a

Expected Behavior

Readable error describing the issue is outputted

Actual Behavior

NullReferenceExceptionis is outputted

Analysis

No response

Versions & Configurations

ADO task:

Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.216.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli

.NET SDK:

SDK Version: 6.0.402

MSBuild:

17.3.1+2badb37d1
abatishchev commented 1 year ago

By looking at https://github.com/dotnet/sdk/blob/0f2d02b78540d3b3d5c6455aa0bfde2154b714a1/src/Tasks/Microsoft.NET.Build.Tasks/ReferenceInfo.cs#L172-L194, I'm not sure what could fail with the NRE. Given the referencePath was not null, since it would fail sooner, down the stack at ReferenceInfo.CreateReferenceInfo().

abatishchev commented 1 year ago

The ticket probably belongs to the SDK repo, please transfer it over if that's the case.

abatishchev commented 1 year ago

@joeloff hi, do you know if this issue can be investigated?