Skip to content

[Bug]: Msbuild crashes when using cache extension with proxy targets pointing to original targets #9117

@jacdavis

Description

@jacdavis

Issue Description

While implementing build acceleration, I ran into an issue where msbuild is crashing. Csproj passes "Build" and 10 other targets related to scraping the outputgroup data ofr the DTE. These are the additional targets:
"BuiltProjectOutputGroup"
"BuiltProjectOutputGroupDependencies"
"DebugSymbolsProjectOutputGroup"
"DebugSymbolsProjectOutputGroupDependencies"
"DocumentationProjectOutputGroup"
"DocumentationProjectOutputGroupDependencies"
"SatelliteDllsProjectOutputGroup"
"SatelliteDllsProjectOutputGroupDependencies"
"SGenFilesOutputGroup"
"SGenFilesOutputGroupDependencies"

In speaking to David Federman, the design is I should be able to return these as proxies to themselves so msbuild will just execute them. However, when I do that, msbuild crashes because they are already added to the build result collection. Callstack is here:
Severity Code Description Project File Line Suppression State
Error This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT
https://aka.ms/msbuild/unhandled

Microsoft.Build.Framework.InternalErrorException: MSB0001: Internal MSBuild Error: Items already exist for target BuiltProjectOutputGroup.

at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Object[] args)
at Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(Boolean condition, String unformattedMessage, Object arg0)
at Microsoft.Build.Execution.BuildResult.AddResultsForTarget(String target, TargetResult result)
at Microsoft.Build.BackEnd.RequestBuilder.g__CopyTargetResultsFromProxyTargetsToRealTargets|68_0(BuildResult resultFromTargetBuilder)
at Microsoft.Build.BackEnd.RequestBuilder.d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Build.BackEnd.RequestBuilder.d__59.MoveNext() ClassLibrary1

Steps to Reproduce

  1. Create an msbuild cache extension and invoke that extension from csproj
  2. Create a new build result where the proxy targets match the existing targets.

Expected Behavior

This works

Actual Behavior

msbuild crashes

Analysis

See above

Versions & Configurations

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions