0

A have a .NET Core project and i want to copy a specified NuGet reference (assembly.dll) to the build output because i'm using a dependency injection component that searches de bin folder for the types.

I know that i could use this, but it copies all the nugets when I only want a specific nuget package to be copied:

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>
Troy Turley
  • 659
  • 10
  • 28
Miguel Domingues
  • 440
  • 3
  • 11
  • Possible duplicate of [How to get .NET Core projects to copy NuGet references to build output?](https://stackoverflow.com/questions/43837638/how-to-get-net-core-projects-to-copy-nuget-references-to-build-output) – NightOwl888 Mar 16 '18 at 18:30
  • Do you control this DI component? there are new APIs ("DependencyContext") to scan the logical assembly closure of an application (based on the .deps.json file) instead of enumerating files on disk. – Martin Ullrich Mar 16 '18 at 22:11

1 Answers1

1

Assuming you're using Visual Studio... Project->Properties->Build Events

"Put this in the Post-build event command line:" box

copy "$(SolutionDir)assembly.dll" "$(TargetDir)"

Or add this to your project file:

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="copy &quot;$(SolutionDir)assembly.dll&quot; &quot;$(TargetDir)&quot;" />
  </Target>
Troy Turley
  • 659
  • 10
  • 28
  • That would work, though its not the perfect solution because I have to update the postbuild cmd every time the nuget is updated to a new version. – Miguel Domingues Mar 18 '18 at 10:52