dotnet / dotnet/msbuild

UpdateManifest task throws NullReferenceException when ApplicationManifest path is too long

Open
#3,805 3 comments 0 reactions 0 assignees View on GitHub
Area: Debuggability Area: Tasks triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

This was reported as https://developercommunity.visualstudio.com/content/problem/312243/the-updatemanifest-task-failed-unexpectedly.html.

### Steps to reproduce

Call the `UpdateManifest` task with a path for `ApplicationManifest` that is longer than `MAX_PATH` (possibly even only before collapsing `..` path elements).

[UpdateManifest_LongPaths.zip](https://github.com/Microsoft/msbuild/files/2424807/UpdateManifest_LongPaths.zip)

```
msbuild UpdateManifest_LongPaths.proj
```

### Expected behavior

Successful build (that's probably blocked by #53) or a clear error.

### Actual behavior

```
Microsoft (R) Build Engine version 15.9.14-preview+gae560092f5 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 9/27/2018 10:47:10 AM.
Project "s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj" on node 1 (default targets).
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: The "UpdateManifest" task failed unexpectedly.
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.Tasks.Deployment.ManifestUtilities.Manifest.UpdateEntryPoint(String inputPath, String outputPath, String updatedApplicationPath, String applicationManifestPath, String targetFrameworkVersion)
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.Tasks.UpdateManifest.Execute()
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
Done Building Project "s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj" (default targets) -- FAILED.

Build FAILED.

"s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj" (default target) (1) ->
(X target) ->
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: The "UpdateManifest" task failed unexpectedly.
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.Tasks.Deployment.ManifestUtilities.Manifest.UpdateEntryPoint(String inputPath, String outputPath, String updatedApplicationPath, String applicationManifestPath, String targetFrameworkVersion)
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.Tasks.UpdateManifest.Execute()
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
s:\repro\UpdateManifest_LongPaths\UpdateManifest_LongPaths.proj(3,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.11
```

Debugging, the problem is a null return from

https://github.com/Microsoft/msbuild/blob/90506c8f6c5e4b82a09bafa6ae62a41e9e7367bb/src/Tasks/ManifestUtil/Manifest.cs#L367

causing the NRE at

https://github.com/Microsoft/msbuild/blob/90506c8f6c5e4b82a09bafa6ae62a41e9e7367bb/src/Tasks/ManifestUtil/Manifest.cs#L394

The return is null because the exists check returns false (due to path-too-long)

https://github.com/Microsoft/msbuild/blob/90506c8f6c5e4b82a09bafa6ae62a41e9e7367bb/src/Tasks/ManifestUtil/AssemblyIdentity.cs#L285-L297

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.