Skip to content

Feature request: allow -pp to produce some output even in presence of import and schema errors #6209

@ghost

Description

Issue Description

The -pp or -preprocess will produce no output if the project experiences schema or import errors. In the past, this was acceptable as you could usually just fix the error in question. However, the new PackageReference and Sdk mechanisms often result in a situation where one error in the project will cause package restore to fail, but if that error is not syntactic or schematic, the only diagnostics reported by msbuild will be for the failed Sdk or PackageReference import. This makes debugging the /t:restore target very difficult, as we have no way to see what the project looks like to msbuild when it runs the restore target.

This motivates a need for -pp to function with incomplete projects -- where either the Imports fail, or where errors are caused by incorrect property values (e.g. UsingTask can fail with syntax errors if the task factory value is set wrong, due to improperly initialized properties).

Steps to Reproduce

  1. Create a new C# project, e.g. dotnet new console
  2. Add the following to the project:
    <ItemGroup>
      <PackageReference Include="Microsoft.NoSuchProject" Version="1.0.0" GeneratePackagePath="true" />
    </ItemGroup>
    <Import Project="$(PkgMicrosoft_NoSuchProject)" />
    
  3. dotnet /pp

Expected Behavior

Syntax errors, and partial result of preprocessing (at least up until the first error. Preferably preprocessed exactly as the /t:restore project would see the project.

Actual Behavior

No output at all.

Analysis

n/a

Versions & Configurations

C:\scratch\repro>dotnet --version
6.0.100-preview.1.21103.13

C:\scratch\repro>ver

Microsoft Windows [Version 10.0.19042.804]

Attach a binlog

n/a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions