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.21k stars 1.35k forks source link

CombineTargetFrameworkInfoProperties fails with ArgumentNullException #8320

Closed marek-safar closed 1 year ago

marek-safar commented 1 year ago

Extracted from https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_apis/build/builds/141116/logs/19

2023-01-18T13:41:58.9010353Z Msbuild failed when processing the file '/home/vsts/work/1/s/src/linker/Mono.Linker.csproj' with message: /home/vsts/work/1/s/.dotnet/sdk/8.0.100-alpha.1.23061.8/Microsoft.Common.CurrentVersion.targets: (1951, 5): The "CombineTargetFrameworkInfoProperties" task failed unexpectedly.
2023-01-18T13:41:58.9011595Z System.ArgumentNullException: Value cannot be null. (Parameter 'value')
2023-01-18T13:41:58.9012203Z    at System.ArgumentNullException.Throw(String paramName)
2023-01-18T13:41:58.9012847Z    at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
2023-01-18T13:41:58.9013426Z    at System.Xml.Linq.XAttribute..ctor(XName name, Object value)
2023-01-18T13:41:58.9013984Z    at Microsoft.Build.Tasks.CombineTargetFrameworkInfoProperties.Execute()
2023-01-18T13:41:58.9017422Z    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2023-01-18T13:41:58.9018081Z    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
AR-May commented 1 year ago

We should at least improve the diagnosability and the error message. As for the actual error, @marek-safar do you see this issue still in the CI? Unfortunately, the link was expired, and we are unable to check the logs.

marek-safar commented 1 year ago

The stack trace was extracted from CI builds that were failing in case the log was removed.

The implementation has disabled nullable warnings and for the utility type too otherwise it'd be obvious what's wrong. However, it's still clear that CombineTargetFrameworkInfoProperties is not handling null case of RootElementName.

rainersigwald commented 1 year ago

@AR-May was saying that there are two problems:

  1. The task fails with an unhandled exception instead of gracefully erroring in the case where it's in a mode that requires a set RootElementName.
  2. Something in your build caused that to be the case.

We can fix the former with information we have, but would be willing to look into the latter--if we can get a repro or more information.

marek-safar commented 1 year ago

I don't have any way to reproduce the error was just reporting CI failure happening with official build

rainersigwald commented 1 year ago

Ok, then let's use this bug to track improving the debuggability of this situation.