Filtering CopyLocalLockFileAssemblies
See original GitHub issueWhen you use CopyLocalLockFileAssemblies with a netcoreapp project, it copies shared framework assets too.
While you can use publish instead to copy without those assemblies, there are circumstances where its more practical and efficient to just have the single build step. In particular pack is driven by build output not publish output. Consider the case where I want to flatten dependencies in a nupkg (e.g. as currently required to package msbuild tasks).
One way to address this would be to just have a flag to apply the same filtering as publish to CopyLocalLockFileAssemblies.
Alternatively, I find myself wishing that I could just slap metadata on my package references to exclude their full closure from CopyLocal. ExcludeAssets=Runtime almost works, but if I have another sibling package that pulls in overlapping assets in its closure, they get re-included.
In the msbuild task scenario, I really want to say “copy everything that is not in the closure of Microsoft.NETCore.App, Microsoft.Build.Framework, or Microsoft.Build.Utilities.Core”
I managed to get close enough to that with this workaround:
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="15.1.548" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.548" ExcludeAssets="Runtime" />
</ItemGroup>
<!-- Remove files from copy local that would not be published as they are provided by the platform package -->
<Target Name="FilterCopyLocal" DependsOnTargets="RunResolvePublishAssemblies" BeforeTargets="ResolveLockFileCopyLocalProjectDeps">
<ItemGroup>
<_CopyLocalButNotPublished Include="@(AllCopyLocalItems)" Exclude="@(ResolvedAssembliesToPublish)" />
<AllCopyLocalItems Remove="@(_CopyLocalButNotPublished)" />
</ItemGroup>
</Target>
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
With a 3.0 SDK (including preview7 that came out today), we’re now copying the assets locally for build like we would for a publish. It should happen automatically (can be opted out of with setting
CopyLocalLockFileAssemblies
tofalse
).@Seabizkit I haven’t worked on this in a long time and I’ve forgotten all the details. I think you might be better off filing a new issue describing what you want to achieve and what is stopping you so that the current team can help you.