dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.17k stars 1.34k forks source link

Preprocessing invalid file fails to display errors #3971

Open bergbria opened 5 years ago

bergbria commented 5 years ago

Steps to reproduce

Project file (DotNetCoreTestApp.csproj)

INVALID XML FILE
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

</Project>

Directory contents:

/
- DotNetCoreTestApp.csproj

Command line

dotnet msbuild /pp:msbuild.xml DotNetCoreTestApp.csproj

Expected behavior

The command should print an error message to stderror or stdout.

Actual behavior

No output is printed at all. The output file is created but empty. Exit code is 1. For comparison, this is the output from an older version of msbuild.exe:

DotNetCoreTestApp.csproj(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

Environment data

dotnet msbuild /version output: Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

15.9.20.62856

rainersigwald commented 5 years ago

Looks like full-framework MSBuild does the same thing:

s:\msbuild>msbuild build.cmd /pp:out

s:\msbuild>echo %ERRORLEVEL%
1

and it's regressed since 4.5:

s:\msbuild>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe build.cmd /pp:out
s:\msbuild\build.cmd(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line
 1, position 1.