dotnet / dotnet/msbuild

Crash loading task with unresolved .NET property type from ExtensionEngine.dll

Open
#13,203 0 comments 1 reaction 0 assignees View on GitHub
bug internal-team-onboarding Priority:2 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

When a task (such as those in the current canary version of VSSDK in `Microsoft.VisualStudio.Sdk.BuildTasks.17.0.dll`) defines a .NET property of a type defined in another DLL (in this instance `PkgDefManagementFlags` from `Microsoft.VisualStudio.ExtensionEngine.dll`), MSBuild fails to load the property type unless all properties can be loaded (here, if `ExtensionEngine.dll` is present beside the task assembly). If the type is not resolved, MSBuild crashes instead of gracefully handling the missing type.

### Steps to Reproduce

See internal bug https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2701081, since the known repro requires Canary-channel VS.

### Expected Behavior

```
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 [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : System.NullReferenceException: Object reference not set to an instance of an object. [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at Microsoft.Build.Execution.ReflectableTaskPropertyInfo..ctor(TaskPropertyInfo taskPropertyInfo, Type taskType) [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at Microsoft.Build.Execution.TaskFactoryWrapper.PopulatePropertyInfo() [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at System.Lazy`1.CreateValue() [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at System.Lazy`1.LazyInitValue() [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at Microsoft.Build.BackEnd.TaskExecutionHost.GetNamesOfPropertiesWithRequiredAttribute() [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at Microsoft.Build.BackEnd.TaskExecutionHost.SetTaskParameters(IDictionary`2 parameters) [Q:\play\devdiv2701081\Test.csproj]
MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() [Q:\play\devdiv2701081\Test.csproj]
```

### Actual Behavior

MSBuild crashes when inspecting a property type that cannot be loaded due to a missing dependency assembly (ExtensionEngine.dll). The crash occurs slightly later in inspection because exception-handling logic leaves a null in a list, resulting in failure rather than gracefully ignoring the missing property.

### Analysis

_No response_

### Versions & Configurations

Canary channel, `18.5.0-preview-26080-04+8004741e5`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.