Skip to content

Instantly share code, notes, and snippets.

@dtwk2
Created March 23, 2020 11:31
Show Gist options
  • Save dtwk2/f873387222085f24c84ce249dcd4a499 to your computer and use it in GitHub Desktop.
Save dtwk2/f873387222085f24c84ce249dcd4a499 to your computer and use it in GitHub Desktop.
How to use private project references in nuget package from https://github.com/NuGet/Home/issues/3891
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net47</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" PrivateAssets="all" />
<ProjectReference Include="..\ClassLibrary3\ClassLibrary3.csproj" Condition="'$(TargetFramework)' == 'net47'" PrivateAssets="all" />
</ItemGroup>
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>
</Project>
@dtwk2
Copy link
Author

dtwk2 commented Mar 25, 2020

Alos this package will bundle private projects with nuget package

Teronis.MSBuild.Packaging.ProjectBuildInPackage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment