Skip to content

UpdateManifest task throws NullReferenceException when ApplicationManifest path is too long #3805

Open
@rainersigwald

Description

@rainersigwald

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

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.<ExecuteInstantiatedTask>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.<ExecuteInstantiatedTask>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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Area: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions