HavenDV / H.Generators.Extensions

A set of extensions to simplify the code of generators
MIT License
11 stars 3 forks source link

`pack --no-build` does not invoke `AddGenerationTimeReferences` #8

Open trejjam opened 1 year ago

trejjam commented 1 year ago

Hi, I found out, that if your build pipeline consists of separate commands like:

Then produced .nupkg does not contain the required dependencies. The workaround is similar code in .csproj:

  <ItemGroup>
    <PackageReference Include="H.Generators.Extensions" Version="1.19.0" PrivateAssets="all" GeneratePathProperty="true" />
  </ItemGroup>

  <PropertyGroup>
    <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddAnalyzerDependenciesToOutput</TargetsForTfmSpecificContentInPackage>
  </PropertyGroup>

  <Target Name="_AddAnalyzerDependenciesToOutput">
    <ItemGroup>
      <TfmSpecificPackageFile Include="$(PkgH_Generators_Extensions)\lib\netstandard2.0\H.Generators.Extensions.dll" PackagePath="analyzers/dotnet/cs" />
    </ItemGroup>
  </Target>

But I hope it can be solved in a better way in src/libs/H.Generators.Extensions/build/H.Generators.Extensions.props, but I do not know which msbuild target is suitable for that

HavenDV commented 1 year ago

Thank you for the issue, but I'm not sure if it will work for this case, because it's unlikely that the ResolveReferences target is called, which calculates the required dependencies. But in any case it requires testing