dotnet/roslyn-sdk

AdditionalFiles are not being recognised by Source Generator

goldytech opened this issue · 0 comments

I was trying to replicate the CsvGenerator example in my project/
My project which consumes the generator targets .NET 6 (SDK version 6.0.401) on Rider in MacOS

Here is the csproj file of the same

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net6.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
        <CompilerGeneratedFilesOutputPath>GeneratedFiles</CompilerGeneratedFilesOutputPath>
    </PropertyGroup>

    <ItemGroup>
      <ProjectReference Include="..\HelloLib\HelloLib.csproj" />
        <Compile Remove="$(CompilerGeneratedFilesOutputPath)/**/*.cs" />
        <ProjectReference Include="..\MyGenerator\MyGenerator.csproj" OutputItemType="Analyzer"  />  
    </ItemGroup>
    <ItemGroup>
        <AdditionalFiles Include="vehicles.csv" CsvLoadType="Startup" CacheObjects="true" />
    </ItemGroup>
    <Import Project="..\MyGenerator\CsvGenerator.props" />
</Project>

When I build the project the source generator doesn't work and newly generated C# files don't get created.

The sample project is located here

Kindly help.