Skip to content

fix: source generator no se carga desde NuGet — DLL no esta en analyzers/dotnet/cs #12

Closed

Description

@cl2raul66

Contexto

Sub-issue de #11. Los proyectos generados por las plantillas (easywinapp, simpleeasywinapp) usan PackageReference para referenciar el generador. Al compilar, el source generator no se carga y falla:

error CS1061: "IBehaviorBuilder" no contiene una definicion para "BtnIncrement"

src/Sample funciona porque usa ProjectReference (carga el DLL directamente desde bin/Debug/, sin pasar por NuGet).

Causa raíz

El nupkg RandAMediaLabGroup.EasyWindowsApplication.Generators solo contiene:

lib/netstandard2.0/EasyWindowsApplication.Generators.dll

NuGet/MSBuild espera analyzers/generators en:

analyzers/dotnet/cs/EasyWindowsApplication.Generators.dll

Sin esa ruta, el generador no se carga.

Solución

Archivo: src/EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj

1. PropertyGroup — agregar IncludeBuildOutput=false

<IncludeBuildOutput>false</IncludeBuildOutput>

Evita que el DLL vaya a lib/netstandard2.0/.

2. Nuevo ItemGroup — colocar DLL en analyzers/dotnet/cs

<ItemGroup>
    <None Include="$(TargetPath)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

Referencia

Analyzer NuGet formats — Microsoft Learn

Verificación

  1. dotnet pack del generador — inspeccionar nupkg: debe contener analyzers/dotnet/cs/EasyWindowsApplication.Generators.dll
  2. Instalar en proyecto externo vía PackageReference + OutputItemType="Analyzer"
  3. Confirmar que el source generator carga y genera código
  4. dotnet build src\EasyWindowsApplication.slnx — Sample sigue compilando

Archivos afectados

  • src/EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions