❔ Rosyln Analyzer with Nugget Package
Hello,
I have a project where i have developped custom Analyzer for SourceGenerator.
In this solution i have tests projects that use the SourceGeneratorProject like that
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
...
<ProjectReference Include="..\..\src\WinterTong.RestServices.SourceGenerator\WinterTong.RestServices.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
And the code is generated on obj/Debug/.netVersion/Generated/**
I have now published my project has nugget and I try to use it in a new solution.
So now I use PackageReference instead of ProjectReference.
But when i build nothing append in my Generated folder
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<PackageReference Include="ByTel.WinterTong.RestServices.SourceGenerator" Version="0.0.4" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
0 Error, 0 Warning.
It's weird. I'm using IIncrementalGenerator
and i search for custom attribute to know if i should Analyze or not2 Replies
I finally add this line on all SourceGenerator project.
<ItemGroup>
<None Include="$(OutputPath)$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
Now i can see the Analyzer but still not generating code 😢
UP with VS in diagnose mode for build info i got
1>CSC : warning CS8032: An instance of analyzer ByTel.WinterTong.RestServices.SourceGenerator.RestServicesSourceGenerator cannot be created from C:\Users\tgicquel.nuget\packages\bytel.wintertong.restservices.sourcegenerator\0.0.20\analyzers\dotnet\cs\Winter.RS.G.dll : Exception has been thrown by the target of an invocation..
1> 1 Warning(s)
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.