By default, Roslyn source generators (including Facet) output generated files to the obj/Generated/ folder, which is hidden from the Solution Explorer. However, you can configure where generated files are written using standard MSBuild properties.
To make generated files visible in your project and control where they are output, add the following properties to your .csproj file:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>Place generated files in a Generated folder within your project:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<!-- Exclude from compilation to avoid duplicate definitions -->
<ItemGroup>
<Compile Remove="Generated\**" />
<!-- Keep them visible in Solution Explorer -->
<None Include="Generated\**" />
</ItemGroup>This configuration:
- Makes generated files visible in Solution Explorer
- Allows you to browse and inspect generated code
- Excludes them from compilation (they're already compiled as generated files)
- Useful for debugging and understanding what code is being generated
Keep generated files in the obj folder but make them visible:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>This is what Facet's test projects use internally.
Generate files in a separate shared project:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>..\MySharedProject\Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>Important: When outputting to a shared project, ensure the types being generated are partial so they can be merged with the declarations in your source project.
With the default configuration, generated files are organized by generator:
Generated/
├── Facet/
│ ├── Facet.Generators.FacetGenerator/
│ │ ├── UserDto.g.cs
│ │ ├── ProductDto.g.cs
│ │ └── ...
│ ├── Facet.Generators.FlattenGenerator/
│ │ └── ...
│ └── Facet.Generators.GenerateDtosGenerator/
│ └── ...
└── OtherGenerator/
└── ...
- Debugging: Easier to see what code is being generated and debug issues
- Learning: Understand how Facet generates code by inspecting the output
- Code Reviews: Include generated files in code reviews if needed
- Documentation: Auto-generated code serves as documentation
- Do NOT manually edit generated files - they will be overwritten on the next build
- Generated files are recreated on every build based on your source code and attributes
- Do NOT commit generated files to source control unless you have a specific reason (add to
.gitignore) - When placing files in the project folder, always exclude them from compilation using
<Compile Remove="Generated\**" />
If you choose to make generated files visible in your project, add this to your .gitignore:
# Facet generated files
Generated/
**/Generated/If you see errors about duplicate type definitions, ensure you've excluded the Generated folder from compilation:
<ItemGroup>
<Compile Remove="Generated\**" />
</ItemGroup>- Clean and rebuild your solution
- Verify
EmitCompilerGeneratedFilesis set totrue - Check the output path exists and is accessible
- Ensure you're using a recent .NET SDK (6.0+)
Emitting generated files to disk has minimal performance impact. However, if you have thousands of generated files and are using source control, consider:
- Keeping them in the
objfolder (default) - Adding the output directory to
.gitignore