dotnet / dotnet/sdk

Proposal: Exclude `CompilerGeneratedFilesOutputPath` from Compilation by Default

Open
#47,046 4 comments 1 reaction 1 assignee Claimed by @baronfel View on GitHub
Area-NetSDK untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

#### **Problem**
When `CompilerGeneratedFilesOutputPath` is set in csproj, the .NET SDK emits source generator output to disk. However, these files are **not excluded from compilation by default**, leading to errors when running `dotnet build` a second time.

Currently, developers must manually add:
```xml

```
Without this, builds fail due to duplicate type definitions: https://andrewlock.net/creating-a-source-generator-part-6-saving-source-generator-output-in-source-control/#excluding-emitted-files-from-the-compilation

#### **Proposal**
The .NET SDK should **automatically exclude** the `CompilerGeneratedFilesOutputPath` from compilation when it is set, preventing these errors.

Would love to hear thoughts on whether this can be supported natively!

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.