-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude generated files from compilation by default #77325
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't believe this is the best path forward here. Generally not in favor of a new property that replaces a single line of msbuild.
it is about overall experience. this uses default location (obj/somewhere/) which is excluded <PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup> with custom location <PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>mylocation</CompilerGeneratedFilesOutputPath>
</PropertyGroup> we have duplicate definition error. is that the intended experience? if so, quite strange! |
In this case though you're using a custom location which is part of the included paths searched for source files. My push back is why are you doing that? This is a documented location that the compiler searches for source files. There are plenty of other tasks in the sdk that generate code, or even content, and none of them are being pushed to be excluded in this way. |
Set ExcludeGeneratedFilesFromCompilation to true by default if not explicitly specified by updating Microsoft.CSharp.Core.targets to automatically exclude all .cs files in CompilerGeneratedFilesOutputPath.
This prevents duplicate type definitions and build errors when running dotnet build multiple times.
Fix dotnet/sdk#47046