-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
Let's say that my analyzer or source generator depends on the GraphQL
NuGet:
<ItemGroup>
<PackageReference Include="GraphQL" Version="4.7.1" GeneratePathProperty="true" PrivateAssets="all" />
</ItemGroup>
This will fail, because MSBuild won't automatically include GraphQL's DLL's, so I need to do this:
<!-- See https://github.com/dotnet/roslyn-sdk/blob/0313c80ed950ac4f4eef11bb2e1c6d1009b328c4/samples/CSharp/SourceGenerators/SourceGeneratorSamples/SourceGeneratorSamples.csproj#L13-L30
and https://github.com/dotnet/roslyn/discussions/47517#discussioncomment-64145 -->
<PropertyGroup>
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
</PropertyGroup>
<Target Name="GetDependencyTargetPaths">
<!-- Manually include the DLL of each NuGet package that this analyzer uses. -->
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PKGGraphQL)\lib\netstandard2.0\GraphQL.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>
I'd like to request that when an analyzer/source-generator references a NuGet, MSBuild automatically hooks up the NuGet's DLL's 🙂
This seems to have been a source of confusion for many! See all of the comments at dotnet/roslyn#47517 🙂
P.S.
Not sure if MSBuild is the correct place to post this?
altso, ptasev, dferretti, cedmoh, vpenades and 7 more