C
C#2w ago
Szylek

Linking incremental generator to the consumer project

I have a problem where content generated by an IncrementalGenerator isn't available in the consumer project, no matter what I'm trying to do in both projects' files. Generator project: netstandard2.0 class library. Consumer project: net9.0 console app. Both projects are in the same solution. Will be able to provide necessary code later.
6 Replies
SleepWellPupper
Both project files and the build output of your test project would be useful.
Tvde1
Tvde12w ago
I think the fortune tellers are on holiday at the moment, so in order to help you we would like to see the projects and build output ☺️
Szylek
SzylekOP2w ago
Yeah, sorry, didn't have access to the project at the time. But already solved the problem by an accident lmao The consumer project was missing ReferenceOutputAssembly="false" in consumer .csproj And in the end files look like this: Generator:
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
</ItemGroup>
</Project>
Consumer:
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ToStringGenerator\ToStringGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
</ItemGroup>

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ToStringGenerator\ToStringGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
And thanks for quick response
SleepWellPupper
If you want to improve your debugging experience, add the 'IsRoslynComponent' property to your generator and set it to true.
Szylek
SzylekOP2w ago
ok, thx actually, is there a list of Roslyn-related project properties?
SleepWellPupper
I'm not sure there is.

Did you find this page helpful?