Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Why are some of a dependent project's dependencies not being copied to bin directory?

$
0
0

I have an application (console) which targets .NET 4.7 using MSVC 2019 and which references a lot of NuGet packages.

When I build, those packages end up in the bin/Debug (or bin/Release) folder -- so the application can use them at run-time, which is good/expected.

Then I want to unit-test it. So I create a *.Tests project, in the same solution, which references the application project. After a rebuild, some but not all of the application's packages are in the test project's bin/Debug folder. The test project therefore fails to load various application classes (because the packages they depend on aren't present at run-time).

  • Why are some of the packages missing?
  • Why is it only some of them?
  • How to correct it?

I can correct it by declaring that the test project itself depends directly on all the same packages as the application under test. But my impression was that shouldn't be necessary.


For reference, here's an example of an exception due to a missing reference:

System.TypeInitializationException  HResult=0x80131534  Message=The type initializer for 'Foo.Tests.MyClass' threw an exception.Inner Exception 1:FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.

Here are the files present in the Test project's bin/Debug directory.

The Test project depends on nothing except the application under test,so all these result are here because they're dependencies of the application under test.

Microsoft.Bcl.AsyncInterfaces.dllMicrosoft.Bcl.AsyncInterfaces.xmlMicrosoft.Extensions.DependencyInjection.Abstractions.dllMicrosoft.Extensions.DependencyInjection.Abstractions.xmlMicrosoft.Extensions.Hosting.Abstractions.dllMicrosoft.Extensions.Hosting.Abstractions.xmlMicrosoft.Extensions.Hosting.dllMicrosoft.Extensions.Hosting.xmlMicrosoft.Extensions.Logging.Abstractions.dllMicrosoft.Extensions.Logging.Abstractions.xmlMicrosoft.Extensions.Logging.dllMicrosoft.Extensions.Logging.xmlMicrosoft.Extensions.Options.dllMicrosoft.Extensions.Options.xmlnetstandard.dllNewtonsoft.Json.dllNewtonsoft.Json.xmlNLog.configNLog.dllNLog.Extensions.Logging.dllNLog.Extensions.Logging.xmlNLog.xmlSystem.Data.SQLite.dllSystem.Data.SQLite.xmlSystem.Threading.Tasks.Extensions.dllSystem.Threading.Tasks.Extensions.xmlTopshelf.dllTopshelf.xml

Here is the much longer list of files which are present in the bin/Debug folder of the application under test.

Autofac.Configuration.dllAutofac.Configuration.pdbAutofac.Configuration.xmlAutofac.dllAutofac.pdbAutofac.xmlMicrosoft.Bcl.AsyncInterfaces.dllMicrosoft.Bcl.AsyncInterfaces.xmlMicrosoft.Extensions.Configuration.Abstractions.dllMicrosoft.Extensions.Configuration.Abstractions.xmlMicrosoft.Extensions.Configuration.Binder.dllMicrosoft.Extensions.Configuration.Binder.xmlMicrosoft.Extensions.Configuration.CommandLine.dllMicrosoft.Extensions.Configuration.CommandLine.xmlMicrosoft.Extensions.Configuration.dllMicrosoft.Extensions.Configuration.EnvironmentVariables.dllMicrosoft.Extensions.Configuration.EnvironmentVariables.xmlMicrosoft.Extensions.Configuration.FileExtensions.dllMicrosoft.Extensions.Configuration.FileExtensions.xmlMicrosoft.Extensions.Configuration.Json.dllMicrosoft.Extensions.Configuration.Json.xmlMicrosoft.Extensions.Configuration.UserSecrets.dllMicrosoft.Extensions.Configuration.UserSecrets.xmlMicrosoft.Extensions.Configuration.xmlMicrosoft.Extensions.DependencyInjection.Abstractions.dllMicrosoft.Extensions.DependencyInjection.Abstractions.xmlMicrosoft.Extensions.DependencyInjection.dllMicrosoft.Extensions.DependencyInjection.xmlMicrosoft.Extensions.FileProviders.Abstractions.dllMicrosoft.Extensions.FileProviders.Abstractions.xmlMicrosoft.Extensions.FileProviders.Physical.dllMicrosoft.Extensions.FileProviders.Physical.xmlMicrosoft.Extensions.FileSystemGlobbing.dllMicrosoft.Extensions.FileSystemGlobbing.xmlMicrosoft.Extensions.Hosting.Abstractions.dllMicrosoft.Extensions.Hosting.Abstractions.xmlMicrosoft.Extensions.Hosting.dllMicrosoft.Extensions.Hosting.xmlMicrosoft.Extensions.Logging.Abstractions.dllMicrosoft.Extensions.Logging.Abstractions.xmlMicrosoft.Extensions.Logging.Configuration.dllMicrosoft.Extensions.Logging.Configuration.xmlMicrosoft.Extensions.Logging.Console.dllMicrosoft.Extensions.Logging.Console.xmlMicrosoft.Extensions.Logging.Debug.dllMicrosoft.Extensions.Logging.Debug.xmlMicrosoft.Extensions.Logging.dllMicrosoft.Extensions.Logging.EventLog.dllMicrosoft.Extensions.Logging.EventLog.xmlMicrosoft.Extensions.Logging.EventSource.dllMicrosoft.Extensions.Logging.EventSource.xmlMicrosoft.Extensions.Logging.xmlMicrosoft.Extensions.Options.ConfigurationExtensions.dllMicrosoft.Extensions.Options.ConfigurationExtensions.xmlMicrosoft.Extensions.Options.dllMicrosoft.Extensions.Options.xmlMicrosoft.Extensions.Primitives.dllMicrosoft.Extensions.Primitives.xmlMicrosoft.Win32.Primitives.dllnetstandard.dllNewtonsoft.Json.dllNewtonsoft.Json.xmlNLog.configNLog.dllNLog.Extensions.Logging.dllNLog.Extensions.Logging.xmlNLog.xmlSystem.AppContext.dllSystem.Buffers.dllSystem.Buffers.xmlSystem.Collections.Concurrent.dllSystem.Collections.dllSystem.Collections.NonGeneric.dllSystem.Collections.Specialized.dllSystem.ComponentModel.Annotations.dllSystem.ComponentModel.dllSystem.ComponentModel.EventBasedAsync.dllSystem.ComponentModel.Primitives.dllSystem.ComponentModel.TypeConverter.dllSystem.Console.dllSystem.Data.Common.dllSystem.Data.SQLite.dllSystem.Data.SQLite.xmlSystem.Diagnostics.Contracts.dllSystem.Diagnostics.Debug.dllSystem.Diagnostics.EventLog.dllSystem.Diagnostics.EventLog.xmlSystem.Diagnostics.FileVersionInfo.dllSystem.Diagnostics.Process.dllSystem.Diagnostics.StackTrace.dllSystem.Diagnostics.TextWriterTraceListener.dllSystem.Diagnostics.Tools.dllSystem.Diagnostics.TraceSource.dllSystem.Diagnostics.Tracing.dllSystem.Drawing.Primitives.dllSystem.Dynamic.Runtime.dllSystem.Globalization.Calendars.dllSystem.Globalization.dllSystem.Globalization.Extensions.dllSystem.IO.Compression.dllSystem.IO.Compression.ZipFile.dllSystem.IO.dllSystem.IO.FileSystem.dllSystem.IO.FileSystem.DriveInfo.dllSystem.IO.FileSystem.Primitives.dllSystem.IO.FileSystem.Watcher.dllSystem.IO.IsolatedStorage.dllSystem.IO.MemoryMappedFiles.dllSystem.IO.Pipes.dllSystem.IO.UnmanagedMemoryStream.dllSystem.Linq.dllSystem.Linq.Expressions.dllSystem.Linq.Parallel.dllSystem.Linq.Queryable.dllSystem.Memory.dllSystem.Memory.xmlSystem.Net.Http.dllSystem.Net.NameResolution.dllSystem.Net.NetworkInformation.dllSystem.Net.Ping.dllSystem.Net.Primitives.dllSystem.Net.Requests.dllSystem.Net.Security.dllSystem.Net.Sockets.dllSystem.Net.WebHeaderCollection.dllSystem.Net.WebSockets.Client.dllSystem.Net.WebSockets.dllSystem.Numerics.Vectors.dllSystem.Numerics.Vectors.xmlSystem.ObjectModel.dllSystem.Reflection.dllSystem.Reflection.Extensions.dllSystem.Reflection.Primitives.dllSystem.Resources.Reader.dllSystem.Resources.ResourceManager.dllSystem.Resources.Writer.dllSystem.Runtime.CompilerServices.Unsafe.dllSystem.Runtime.CompilerServices.Unsafe.xmlSystem.Runtime.CompilerServices.VisualC.dllSystem.Runtime.dllSystem.Runtime.Extensions.dllSystem.Runtime.Handles.dllSystem.Runtime.InteropServices.dllSystem.Runtime.InteropServices.RuntimeInformation.dllSystem.Runtime.Numerics.dllSystem.Runtime.Serialization.Formatters.dllSystem.Runtime.Serialization.Json.dllSystem.Runtime.Serialization.Primitives.dllSystem.Runtime.Serialization.Xml.dllSystem.Security.Claims.dllSystem.Security.Cryptography.Algorithms.dllSystem.Security.Cryptography.Csp.dllSystem.Security.Cryptography.Encoding.dllSystem.Security.Cryptography.Primitives.dllSystem.Security.Cryptography.X509Certificates.dllSystem.Security.Principal.dllSystem.Security.Principal.Windows.dllSystem.Security.Principal.Windows.xmlSystem.Security.SecureString.dllSystem.Text.Encoding.dllSystem.Text.Encoding.Extensions.dllSystem.Text.Encodings.Web.dllSystem.Text.Encodings.Web.xmlSystem.Text.Json.dllSystem.Text.Json.xmlSystem.Text.RegularExpressions.dllSystem.Threading.dllSystem.Threading.Overlapped.dllSystem.Threading.Tasks.dllSystem.Threading.Tasks.Extensions.dllSystem.Threading.Tasks.Extensions.xmlSystem.Threading.Tasks.Parallel.dllSystem.Threading.Thread.dllSystem.Threading.ThreadPool.dllSystem.Threading.Timer.dllSystem.ValueTuple.dllSystem.ValueTuple.xmlSystem.Xml.ReaderWriter.dllSystem.Xml.XDocument.dllSystem.Xml.XmlDocument.dllSystem.Xml.XmlSerializer.dllSystem.Xml.XPath.dllSystem.Xml.XPath.XDocument.dllTopshelf.dllTopshelf.xml

Here's the difference, i.e. the files which are present in one but not in the other.

Autofac.Configuration.dllAutofac.Configuration.pdbAutofac.Configuration.xmlAutofac.dllAutofac.pdbAutofac.xmlMicrosoft.Extensions.Configuration.Abstractions.dllMicrosoft.Extensions.Configuration.Abstractions.xmlMicrosoft.Extensions.Configuration.Binder.dllMicrosoft.Extensions.Configuration.Binder.xmlMicrosoft.Extensions.Configuration.CommandLine.dllMicrosoft.Extensions.Configuration.CommandLine.xmlMicrosoft.Extensions.Configuration.dllMicrosoft.Extensions.Configuration.EnvironmentVariables.dllMicrosoft.Extensions.Configuration.EnvironmentVariables.xmlMicrosoft.Extensions.Configuration.FileExtensions.dllMicrosoft.Extensions.Configuration.FileExtensions.xmlMicrosoft.Extensions.Configuration.Json.dllMicrosoft.Extensions.Configuration.Json.xmlMicrosoft.Extensions.Configuration.UserSecrets.dllMicrosoft.Extensions.Configuration.UserSecrets.xmlMicrosoft.Extensions.Configuration.xmlMicrosoft.Extensions.DependencyInjection.dllMicrosoft.Extensions.DependencyInjection.xmlMicrosoft.Extensions.FileProviders.Abstractions.dllMicrosoft.Extensions.FileProviders.Abstractions.xmlMicrosoft.Extensions.FileProviders.Physical.dllMicrosoft.Extensions.FileProviders.Physical.xmlMicrosoft.Extensions.FileSystemGlobbing.dllMicrosoft.Extensions.FileSystemGlobbing.xmlMicrosoft.Extensions.Logging.Configuration.dllMicrosoft.Extensions.Logging.Configuration.xmlMicrosoft.Extensions.Logging.Console.dllMicrosoft.Extensions.Logging.Console.xmlMicrosoft.Extensions.Logging.Debug.dllMicrosoft.Extensions.Logging.Debug.xmlMicrosoft.Extensions.Logging.EventLog.dllMicrosoft.Extensions.Logging.EventLog.xmlMicrosoft.Extensions.Logging.EventSource.dllMicrosoft.Extensions.Logging.EventSource.xmlMicrosoft.Extensions.Options.ConfigurationExtensions.dllMicrosoft.Extensions.Options.ConfigurationExtensions.xmlMicrosoft.Extensions.Primitives.dllMicrosoft.Extensions.Primitives.xmlMicrosoft.Win32.Primitives.dllSystem.AppContext.dllSystem.Buffers.dllSystem.Buffers.xmlSystem.Collections.Concurrent.dllSystem.Collections.dllSystem.Collections.NonGeneric.dllSystem.Collections.Specialized.dllSystem.ComponentModel.Annotations.dllSystem.ComponentModel.dllSystem.ComponentModel.EventBasedAsync.dllSystem.ComponentModel.Primitives.dllSystem.ComponentModel.TypeConverter.dllSystem.Console.dllSystem.Data.Common.dllSystem.Diagnostics.Contracts.dllSystem.Diagnostics.Debug.dllSystem.Diagnostics.EventLog.dllSystem.Diagnostics.EventLog.xmlSystem.Diagnostics.FileVersionInfo.dllSystem.Diagnostics.Process.dllSystem.Diagnostics.StackTrace.dllSystem.Diagnostics.TextWriterTraceListener.dllSystem.Diagnostics.Tools.dllSystem.Diagnostics.TraceSource.dllSystem.Diagnostics.Tracing.dllSystem.Drawing.Primitives.dllSystem.Dynamic.Runtime.dllSystem.Globalization.Calendars.dllSystem.Globalization.dllSystem.Globalization.Extensions.dllSystem.IO.Compression.dllSystem.IO.Compression.ZipFile.dllSystem.IO.dllSystem.IO.FileSystem.dllSystem.IO.FileSystem.DriveInfo.dllSystem.IO.FileSystem.Primitives.dllSystem.IO.FileSystem.Watcher.dllSystem.IO.IsolatedStorage.dllSystem.IO.MemoryMappedFiles.dllSystem.IO.Pipes.dllSystem.IO.UnmanagedMemoryStream.dllSystem.Linq.dllSystem.Linq.Expressions.dllSystem.Linq.Parallel.dllSystem.Linq.Queryable.dllSystem.Memory.dllSystem.Memory.xmlSystem.Net.Http.dllSystem.Net.NameResolution.dllSystem.Net.NetworkInformation.dllSystem.Net.Ping.dllSystem.Net.Primitives.dllSystem.Net.Requests.dllSystem.Net.Security.dllSystem.Net.Sockets.dllSystem.Net.WebHeaderCollection.dllSystem.Net.WebSockets.Client.dllSystem.Net.WebSockets.dllSystem.Numerics.Vectors.dllSystem.Numerics.Vectors.xmlSystem.ObjectModel.dllSystem.Reflection.dllSystem.Reflection.Extensions.dllSystem.Reflection.Primitives.dllSystem.Resources.Reader.dllSystem.Resources.ResourceManager.dllSystem.Resources.Writer.dllSystem.Runtime.CompilerServices.Unsafe.dllSystem.Runtime.CompilerServices.Unsafe.xmlSystem.Runtime.CompilerServices.VisualC.dllSystem.Runtime.dllSystem.Runtime.Extensions.dllSystem.Runtime.Handles.dllSystem.Runtime.InteropServices.dllSystem.Runtime.InteropServices.RuntimeInformation.dllSystem.Runtime.Numerics.dllSystem.Runtime.Serialization.Formatters.dllSystem.Runtime.Serialization.Json.dllSystem.Runtime.Serialization.Primitives.dllSystem.Runtime.Serialization.Xml.dllSystem.Security.Claims.dllSystem.Security.Cryptography.Algorithms.dllSystem.Security.Cryptography.Csp.dllSystem.Security.Cryptography.Encoding.dllSystem.Security.Cryptography.Primitives.dllSystem.Security.Cryptography.X509Certificates.dllSystem.Security.Principal.dllSystem.Security.Principal.Windows.dllSystem.Security.Principal.Windows.xmlSystem.Security.SecureString.dllSystem.Text.Encoding.dllSystem.Text.Encoding.Extensions.dllSystem.Text.Encodings.Web.dllSystem.Text.Encodings.Web.xmlSystem.Text.Json.dllSystem.Text.Json.xmlSystem.Text.RegularExpressions.dllSystem.Threading.dllSystem.Threading.Overlapped.dllSystem.Threading.Tasks.dllSystem.Threading.Tasks.Parallel.dllSystem.Threading.Thread.dllSystem.Threading.ThreadPool.dllSystem.Threading.Timer.dllSystem.ValueTuple.dllSystem.ValueTuple.xmlSystem.Xml.ReaderWriter.dllSystem.Xml.XDocument.dllSystem.Xml.XmlDocument.dllSystem.Xml.XmlSerializer.dllSystem.Xml.XPath.dllSystem.Xml.XPath.XDocument.dll

Viewing all articles
Browse latest Browse all 3067

Trending Articles