C
C#4mo ago
jooty

Generated files are not being emitted

I have a source generator which I know is functioning. Viewing the assembly in JetBrains Rider, I can see that all the generated files are present within the assembly and are still there beyond cache resets and rebuilds. I'm trying to view the generated files within VSCode, which to my understanding currently isn't possible to view the direct assembly as in Rider. As an alternative, I want them to emit to a certain directory and have my compiler just ignore them for builds. As of now, I see the "Generated" directory appear on builds. However, it is completely empty. These are the settings I have present on my consumer project (as in, the one referencing the source generator).
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<Target Name="CleanSourceGeneratedFiles" BeforeTargets="BeforeBuild"
DependsOnTargets="$(BeforeBuildDependsOn)">
<RemoveDir Directories="Generated" />
</Target>

<ItemGroup>
<Compile Remove="$(CompilerGeneratedFilesOutputPath)/*.cs" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<Target Name="CleanSourceGeneratedFiles" BeforeTargets="BeforeBuild"
DependsOnTargets="$(BeforeBuildDependsOn)">
<RemoveDir Directories="Generated" />
</Target>

<ItemGroup>
<Compile Remove="$(CompilerGeneratedFilesOutputPath)/*.cs" />
</ItemGroup>
What am I missing here?
2 Replies
Anton
Anton4mo ago
they're in obj/Generated
jooty
jootyOP4mo ago
they're not. in fact, no matter what I set the path to, i see a Generated directory being created but it is never populated
Want results from more Discord servers?
Add your server