question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filtering CopyLocalLockFileAssemblies

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
peterhuenecommented, Jul 24, 2019

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 to false).

0reactions
nguerreracommented, Mar 3, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Filter CopyLocalLockFileAssemblies output
I set CopyLocalLockFileAssemblies to true and want to filter the output. So I used the following code: <Target Name="FilterCopyLocalItems" ...
Read more >
Developers - Filtering CopyLocalLockFileAssemblies -
When you use CopyLocalLockFileAssemblies with a netcoreapp project, it copies shared framework assets too. While you can use publish instead ...
Read more >
Merging DLLs in the new csproj project format (excluding ...
Let me start with this statement: It's not supported to use ILMerge (or any other tool) for merging assemblies for CDS. But it's...
Read more >
MSBuild reference for .NET SDK projects
The CopyLocalLockFileAssemblies property is useful for plugin projects that have dependencies on other libraries.
Read more >
[Solved]-How do I get .NET Core projects to copy NuGet ...
Coding example for the question How do I get .NET Core projects to copy NuGet references to the build output?-.net-core.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found