Skip to content

Commit 4f6355e

Browse files
authored
Handle null ProjectFile in InvalidProjectFileException (#13179)
The internal InvalidProctFileException constructor accepts an existing InvalidProjectFileException object as a parameter. It passes the ProjectFile property from that passed in object to another constructor that then verifies that projectFile is not null. Whenever an InvalidProjectFileException object is passed in that has a null projectFile (which is possible via the public ctors), an ArgumentNullException gets thrown and hides real errors. The object gets passed to the internal ctor here: https://github.com/dotnet/msbuild/blob/8bd4d54903169f7e515f8a32e20190b340a295c9/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs#L923 Fix this by passing "MSBUILD" as a string in whenever projectFile is null. Fixes #13150
1 parent 3fbe376 commit 4f6355e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/Build/Errors/InvalidProjectFileException.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public InvalidProjectFileException(string message, Exception innerException)
7171
/// The assumption is that all the metadata for the outer exception comes from the inner exception, eg., they have the same error code.
7272
/// </summary>
7373
internal InvalidProjectFileException(string message, InvalidProjectFileException innerException)
74-
: this(innerException.ProjectFile, innerException.LineNumber, innerException.ColumnNumber, innerException.EndLineNumber, innerException.EndColumnNumber, message, innerException.ErrorSubcategory, innerException.ErrorCode, innerException.HelpKeyword)
74+
: this(innerException.ProjectFile ?? "MSBUILD", innerException.LineNumber, innerException.ColumnNumber, innerException.EndLineNumber, innerException.EndColumnNumber, message, innerException.ErrorSubcategory, innerException.ErrorCode, innerException.HelpKeyword)
7575
{
7676
}
7777

0 commit comments

Comments
 (0)