tunnelvisionlabs / ReferenceAssemblyAnnotator

IL weaver to add nullability annotations to .NET reference assemblies
MIT License
71 stars 8 forks source link

Include PackageDownload in targets #70

Closed jnm2 closed 4 years ago

jnm2 commented 4 years ago

I don't like adding the boilerplate PackageDownload line to every csproj. It would be nice to have this in the targets:

  <ItemGroup Condition="'$(AnnotatedReferenceAssemblyVersion)' != ''">
    <PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(AnnotatedReferenceAssemblyVersion)]" />
  </ItemGroup>

If control of the package name is desired, we could do this:

  <PropertyGroup Condition="'$(AnnotatedReferenceAssemblyPackageName)' != ''">
    <AnnotatedReferenceAssemblyPackageName>Microsoft.NETCore.App.Ref</AnnotatedReferenceAssemblyPackageName>
  </PropertyGroup>

  <ItemGroup Condition="'$(AnnotatedReferenceAssemblyVersion)' != ''">
    <PackageDownload Include="$(AnnotatedReferenceAssemblyPackageName)" Version="[$(AnnotatedReferenceAssemblyVersion)]" />
  </ItemGroup>
sharwell commented 4 years ago

This is likely not possible (it is certainly not possible for PackageReference, but I haven't tried with PackageDownload). NuGet does not include props/targets from packages when evaluating the dependency graph.

jnm2 commented 4 years ago

This makes sense. The package targets aren't available until after the restore phase and the PackageDownload item needs to be present before the restore phase.