Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project references support #15

Open
valchetski opened this issue Sep 28, 2024 · 2 comments
Open

Project references support #15

valchetski opened this issue Sep 28, 2024 · 2 comments

Comments

@valchetski
Copy link

I've tried to use your library as suggested in RicoSuter/NJsonSchema#1726.
At first, amazing library 🙂. It works like a charm for transient NuGet packages.
However, I have one question and one issue with project references

Question

Does it support the automatic inclusion of referenced projects (also transient references) DLLs into the NuGet package?
For example, is it possible to avoid these lines and have these DLLs included automatically?

<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(OutputPath)\NJsonSchema.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(OutputPath)\NJsonSchema.Annotations.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(OutputPath)\NJsonSchema.CodeGeneration.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(OutputPath)\NJsonSchema.CodeGeneration.CSharp.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />

And avoid these for the case when Source Generator is used as project reference itself:

<PropertyGroup>
  <GetTargetPathDependsOn>
      $(GetTargetPathDependsOn);GetDependencyTargetPaths
  </GetTargetPathDependsOn>
</PropertyGroup>

<Target Name="GetDependencyTargetPaths">
  <ItemGroup>
      <TargetPathWithTargetPlatformMoniker Include="$(OutputPath)\NJsonSchema.dll" IncludeRuntimeDependency="false" />
      <TargetPathWithTargetPlatformMoniker Include="$(OutputPath)\NJsonSchema.Annotations.dll" IncludeRuntimeDependency="false" />
      <TargetPathWithTargetPlatformMoniker Include="$(OutputPath)\NJsonSchema.CodeGeneration.dll" IncludeRuntimeDependency="false" />
      <TargetPathWithTargetPlatformMoniker Include="$(OutputPath)\NJsonSchema.CodeGeneration.CSharp.dll" IncludeRuntimeDependency="false" />
  </ItemGroup>
</Target>

Issue

It appears that it somehow treats all project references as dependent NuGet packages.

Try to generate a NuGet package for the NJsonSchema.SourceGenerators.CSharp project from https://github.com/valchetski/NJsonSchema/tree/source-generator-h-generators
Then try to install it and see that it gonna install all the packages.
image

This is something I would like to disable. Or at least have it configurable.

If you do the same from https://github.com/valchetski/NJsonSchema/tree/source-generator branch (H.Generators.Extensions library is not installed there) then it'll install the bare minimum which is what I need:
image
Thanks in advance!

@HavenDV
Copy link
Owner

HavenDV commented Sep 28, 2024

https://github.com/HavenDV/H.Generators.Extensions/blob/main/src/libs/H.Generators.Extensions/build/H.Generators.Extensions.props
All the magic happens here. I'm not sure if you don't intersect with this file, I would try to remove GetDependencyTargetPaths/GetTargetPathDependsOn in your code and try to trust it completely.
But I haven't tried testing this configuration when there is a non private package like Newtonsoft.Json here

I also tried releasing a new version of H.NSwag.Generator and it seems to still work correctly -
image

I also don't see any extra dependencies in the .nuspec file

@HavenDV
Copy link
Owner

HavenDV commented Sep 28, 2024

The main problem with dependency code via PKG is transitive dependency version hell, because packages almost always use a non-latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants