AutoActions for Skinny controllers–deploying at NuGet
First time I was thinking that is enough to do
dotnet pack
to make a Nuget package to deploy on NUGET. It was not. I realized that the generator was not starting at all! And it was not in the project Dependencies=>Analyzers .
Time to read more from https://github.com/dotnet/roslyn/blob/master/docs/features/source-generators.cookbook.md , I realized that I was wrong – for analyzers /source generators we need more. So I put
<!– Package the generator in the analyzer directory of the nuget package –>
<None Include=”$(OutputPath)\$(AssemblyName).dll” Pack=”true” PackagePath=”analyzers/dotnet/cs” Visible=”false” />
to include in the nuget package at analyzers.
After this, the next error was
CSC : warning CS8032: An instance of analyzer SkinnyControllersGenerator.AutoActionsGenerator cannot be created from C:\Users\Surface1\.nuget\packages\skinnycontrollersgenerator\2020.11.24.2135\analyzers\dotnet\cs\SkinnyControllersGenerator.dll : Exception has been thrown by the target of an invocation..
Most probably, this comes from the fact that the SkinnyControllersGenerator has a dependency from another Dll/Nuget, SkinnyControllersCommon . Time to read more from https://github.com/dotnet/roslyn/blob/master/docs/features/source-generators.cookbook.md . I figured that the example with Newtonsoft.JSON is to complicated for me, so I took the decision to just include the file AutoActionsAttribute as link.
And now it works! – see https://www.nuget.org/packages/SkinnyControllersGenerator/
Leave a Reply