3

Visual Studio 2019 16.10.0 .Net 5

I've made a nuget package for company internal use. In this package, i references Microsoft.Extensions.Hosting.WindowsServices which references many other packages:

References of Microsoft.Extensions.Hosting.WindowsServices

When i now use this nuget package in another project, then only my assembly (and few others) are copied to output folder, but many of the referenced assemblies are missing, like:

  • Microsoft.Extensions.Configuration.CommandLine.dll
  • Microsoft.Extensions.Configuration.UserSecrets.dll
  • Microsoft.Extensions.DependencyInjection.dll
  • Microsoft.Extensions.Logging.*

In the project, that i've build, there is CopyLocalLockFileAssemblies=true. What can i do, to copy the missing assemblies to output folder (without xcopy in PostBuild)?

Freak78
  • 121
  • 9
  • the project that you're building in the example (that isn't including transitive dependencies in the output): is this a *library* project, or an *application* project? – Marc Gravell Sep 10 '21 at 15:07
  • The project, that builds to the output folder is a library project, but the project that creates the nuget package is an application project and includes the *.exe in the contentFiles folder of the nuget package. – Freak78 Sep 10 '21 at 15:26
  • what real issues do you have with that? Any runtime errors? Why it's bothering you? – AndrewSilver Sep 10 '21 at 16:47
  • 1
    The error message on starting the executable is: Could not load file or assembly Microsoft.Extensions.Configuration.CommandLine.dll – Freak78 Sep 10 '21 at 19:40
  • 1
    Library projects do not fully explode transitive dependencies in terms.of build output. Try with an application build; that's when it becomes interesting. – Marc Gravell Sep 10 '21 at 20:10
  • @Marc Gravell thx for the hint. That helps me. – Freak78 Sep 11 '21 at 06:53
  • How did you fix this? – Rye bread Nov 23 '22 at 11:41
  • @Ryebread In the future, we will build only libraries as NuGet packages and create executables in the conrete customer project. – Freak78 Nov 24 '22 at 12:33
  • does anyone have an idea, on how to actually fix this as an application? Especially unit test projects need to stay a library project, but on the otherhand need transitive dependencies like configuration files or test data. – Anoni2 Feb 14 '23 at 02:33

0 Answers0