Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on How to find out which packages target .NET 3.1 in a .NET 5 application?

Parent

How to find out which packages target .NET 3.1 in a .NET 5 application?

+6
−0

After upgrading a Web application from ASP.NET Core 3.1 to ASP.NET Core 5.0, it worked fine on an existing server.

However, when deployed on a server that had only .NET 5.0 installed, the application pool crashed and said (as a logged event) that .NET Core 3.1 is missing.

Clearly, some packages were not fully upgraded. The target framework is 5.0 for all projects and all Microsoft.* NuGet packages are using 5.* versions (e.g. EntityFramework).

I am wondering how can I find which packages (or other settings?) still require .NET 3.1.

I found dotnet list package for listing all solution packages and tried the following:

dotnet list Ubisoft.PtbNext.sln package --include-transitive --outdated --highest-minor

which provided all packages, including the "transitive" ones:

The following sources were used:
   https://api.nuget.org/v3/index.json
   https://artifactory.Foo.org/api/nuget/nuget/
   C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

Project `Foo.Bar.WebApi` has the following updates to its packages
   [net5.0]: 
   Top-level Package                                                        Requested   Resolved   Latest
   > Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore                   5.0.5       5.0.5      5.0.6 
   > Microsoft.AspNetCore.Mvc.NewtonsoftJson                                5.0.5       5.0.5      5.0.6 
   > Microsoft.AspNetCore.SpaServices.Extensions                            5.0.5       5.0.5      5.0.6 
   > Microsoft.EntityFrameworkCore                                          5.0.5       5.0.5      5.0.6 
   > Microsoft.EntityFrameworkCore.Tools                                    5.0.5       5.0.5      5.0.6 
   > Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore      5.0.5       5.0.5      5.0.6 
   > Microsoft.Identity.Web                                                 1.9.1       1.9.1      1.12.0
   > NLog.Schema                                                            4.7.9       4.7.9      4.7.10
   > NLog.WindowsIdentity                                                   4.7.9       4.7.9      4.7.10
   > Swashbuckle.AspNetCore                                                 6.1.3       6.1.3      6.1.4 

   Transitive Package                                                                   Resolved   Latest                  
   > Azure.Core                                                                         1.4.1      1.14.0                  
   > Azure.Identity                                                                     1.2.3      1.4.0                   
   > FluentValidation                                                                   10.0.4     10.2.2                  
   > FluentValidation.DependencyInjectionExtensions                                     10.0.4     10.2.2                  
   > Humanizer.Core                                                                     2.8.26     2.10.1                  
   > Microsoft.AspNet.WebApi.Client                                                     5.2.4      5.2.7                   
   > Microsoft.AspNetCore.Authentication.JwtBearer                                      5.0.0      5.0.6                   
   > Microsoft.AspNetCore.Authentication.OpenIdConnect                                  5.0.0      5.0.6                   
   > Microsoft.AspNetCore.JsonPatch                                                     5.0.5      5.0.6                   
   > Microsoft.Bcl.AsyncInterfaces                                                      1.0.0      1.1.1                   
   > Microsoft.Data.SqlClient                                                           2.0.1      2.1.3                   
   > Microsoft.Data.SqlClient.SNI.runtime                                               2.0.1      2.1.1                   
   > Microsoft.EntityFrameworkCore.Abstractions                                         5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Analyzers                                            5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Design                                               5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.InMemory                                             5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Relational                                           5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.SqlServer                                            5.0.5      5.0.6                   
   > Microsoft.Extensions.ApiDescription.Server                                         3.0.0      3.1.15                  
   > Microsoft.Extensions.Diagnostics.HealthChecks                                      5.0.5      5.0.6                   
   > Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions                         5.0.5      5.0.6                   
   > Microsoft.Extensions.Primitives                                                    5.0.0      5.0.1                   
   > Microsoft.Identity.Client                                                          4.29.0     4.31.0                  
   > Microsoft.Identity.Client.Extensions.Msal                                          2.12.0     2.18.4                  
   > Microsoft.IdentityModel.JsonWebTokens                                              6.10.1     6.11.1                  
   > Microsoft.IdentityModel.Logging                                                    6.10.1     6.11.1                  
   > Microsoft.IdentityModel.Protocols                                                  6.10.1     6.11.1                  
   > Microsoft.IdentityModel.Protocols.OpenIdConnect                                    6.10.1     6.11.1                  
   > Microsoft.IdentityModel.Tokens                                                     6.10.1     6.11.1                  
   > Microsoft.Net.Http.Headers                                                         2.2.0      2.2.8                   
   > Microsoft.NETCore.Platforms                                                        5.0.0      5.0.2                   
   > Microsoft.NETCore.Targets                                                          1.1.0      1.1.4                   
   > NLog                                                                               4.7.9      4.7.10                  
   > RabbitMQ.Client                                                                    5.0.1      5.2.0                   
   > runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl           4.3.0      4.3.3                   
   > runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl          4.3.0      4.3.3                   
   > runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl          4.3.0      4.3.3                   
   > runtime.native.System                                                              4.3.0      4.3.1                   
   > runtime.native.System.IO.Compression                                               4.3.0      4.3.2                   
   > runtime.native.System.Net.Http                                                     4.3.0      4.3.1                   
   > runtime.native.System.Net.Security                                                 4.3.0      4.3.1                   
   > runtime.native.System.Security.Cryptography.Apple                                  4.3.0      4.3.1                   
   > runtime.native.System.Security.Cryptography.OpenSsl                                4.3.0      4.3.3                   
   > runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl      4.3.0      4.3.3                   
   > runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl      4.3.0      4.3.3                   
   > runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple            4.3.0      4.3.1                   
   > runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl          4.3.0      4.3.3                   
   > runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl             4.3.0      4.3.3                   
   > runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl       4.3.0      4.3.3                   
   > runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl       4.3.0      4.3.3                   
   > runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl       4.3.0      4.3.3                   
   > Swashbuckle.AspNetCore.Swagger                                                     6.1.3      6.1.4                   
   > Swashbuckle.AspNetCore.SwaggerGen                                                  6.1.3      6.1.4                   
   > Swashbuckle.AspNetCore.SwaggerUI                                                   6.1.3      6.1.4                   
   > System.Buffers                                                                     4.5.0      4.5.1                   
   > System.Console                                                                     4.3.0      4.3.1                   
   > System.Drawing.Common                                                              5.0.0      5.0.2                   
   > System.IdentityModel.Tokens.Jwt                                                    6.10.1     6.11.1                  
   > System.IO.Pipelines                                                                4.5.2      4.7.4                   
   > System.Linq.Dynamic.Core                                                           1.2.9      1.2.10                  
   > System.Memory                                                                      4.5.3      4.5.4                   
   > System.Net.Http                                                                    4.3.0      4.3.4                   
   > System.Net.Primitives                                                              4.3.0      4.3.1                   
   > System.Net.Security                                                                4.3.0      4.3.2                   
   > System.Reflection.Emit.ILGeneration                                                4.3.0      4.7.0                   
   > System.Reflection.Emit.Lightweight                                                 4.3.0      4.7.0                   
   > System.Reflection.TypeExtensions                                                   4.3.0      4.7.0                   
   > System.Runtime                                                                     4.3.0      4.3.1                   
   > System.Runtime.CompilerServices.Unsafe                                             4.5.1      4.7.1                   
   > System.Runtime.Extensions                                                          4.3.0      4.3.1                   
   > System.Security.Cryptography.Algorithms                                            4.3.0      4.3.1                   
   > System.Security.Cryptography.Cng                                                   4.5.0      4.7.0                   
   > System.Security.Cryptography.OpenSsl                                               4.3.0      4.7.0                   
   > System.Security.Cryptography.Pkcs                                                  4.5.0      4.7.0                   
   > System.Security.Cryptography.X509Certificates                                      4.3.0      4.3.2                   
   > System.Security.Cryptography.Xml                                                   4.5.0      4.7.0                   
   > System.Text.Encoding.CodePages                                                     4.7.0      4.7.1                   
   > System.Text.RegularExpressions                                                     4.3.0      4.3.1                   
   > System.Threading.Tasks.Extensions                                                  4.5.2      4.5.4                   
   > System.Xml.ReaderWriter                                                            4.3.0      4.3.1                   
   > Foo.Bar.ODataNuget                                                           1.0.0.19   1.0.0.23                

Project `Foo.Bar.Application` has the following updates to its packages
   [net5.0]: 
   Top-level Package                                     Requested   Resolved   Latest
   > FluentValidation.DependencyInjectionExtensions      10.0.4      10.0.4     10.2.2
   > Microsoft.EntityFrameworkCore                       5.0.5       5.0.5      5.0.6 
   > System.Linq.Dynamic.Core                            1.2.9       1.2.9      1.2.10

   Transitive Package                                Resolved   Latest                  
   > FluentValidation                                10.0.4     10.2.2                  
   > Microsoft.EntityFrameworkCore.Abstractions      5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Analyzers         5.0.5      5.0.6                   
   > Microsoft.Extensions.Primitives                 5.0.0      5.0.1                   
   > Microsoft.Net.Http.Headers                      2.2.0      2.2.8                   
   > NLog                                            4.7.9      4.7.10                  
   > System.Buffers                                  4.5.0      4.5.1                   
   > System.Text.Encodings.Web                       4.5.0      4.7.2                   
   > Foo.Bar.Common                          1.0.0      Not found at the sources
   > Foo.Bar.Domain                          1.0.0      Not found at the sources

Project `Foo.Bar.Domain` has the following updates to its packages
   [net5.0]: 
   Top-level Package                                     Requested   Resolved   Latest
   > FluentValidation.DependencyInjectionExtensions      10.0.4      10.0.4     10.2.2

   Transitive Package                                Resolved   Latest                  
   > FluentValidation                                10.0.4     10.2.2                  
   > Microsoft.EntityFrameworkCore                   5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Abstractions      5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Analyzers         5.0.5      5.0.6                   
   > Microsoft.Extensions.Primitives                 5.0.0      5.0.1                   
   > Microsoft.Net.Http.Headers                      2.2.0      2.2.8                   
   > NLog                                            4.7.9      4.7.10                  
   > System.Buffers                                  4.5.0      4.5.1                   
   > System.Text.Encodings.Web                       4.5.0      4.7.2                   
   > Foo.Bar.Common                          1.0.0      Not found at the sources

Project `Foo.Bar.Infrastructure` has the following updates to its packages
   [net5.0]: 
   Top-level Package                              Requested   Resolved   Latest  
   > Microsoft.EntityFrameworkCore                5.0.5       5.0.5      5.0.6   
   > Microsoft.EntityFrameworkCore.InMemory       5.0.5       5.0.5      5.0.6   
   > Microsoft.EntityFrameworkCore.SqlServer      5.0.5       5.0.5      5.0.6   
   > Microsoft.EntityFrameworkCore.Tools          5.0.5       5.0.5      5.0.6   
   > NLog                                         4.7.9       4.7.9      4.7.10  
   > Foo.Bar.ODataNuget                     1.0.0.19    1.0.0.19   1.0.0.23

   Transitive Package                                                                   Resolved   Latest                  
   > FluentValidation                                                                   10.0.4     10.2.2                  
   > FluentValidation.DependencyInjectionExtensions                                     10.0.4     10.2.2                  
   > Humanizer.Core                                                                     2.8.26     2.10.1                  
   > Microsoft.AspNet.WebApi.Client                                                     5.2.4      5.2.7                   
   > Microsoft.Data.SqlClient                                                           2.0.1      2.1.3                   
   > Microsoft.Data.SqlClient.SNI.runtime                                               2.0.1      2.1.1                   
   > Microsoft.EntityFrameworkCore.Abstractions                                         5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Analyzers                                            5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Design                                               5.0.5      5.0.6                   
   > Microsoft.EntityFrameworkCore.Relational                                           5.0.5      5.0.6                   
   > Microsoft.Extensions.Primitives                                                    5.0.0      5.0.1                   
   > Microsoft.Identity.Client                                                          4.14.0     4.31.0                  
   > Microsoft.Net.Http.Headers                                                         2.2.0      2.2.8                   
   > Microsoft.NETCore.Platforms                                                        5.0.0      5.0.2                   
   > Microsoft.NETCore.Targets                                                          1.1.3      1.1.4                   
   > Newtonsoft.Json.Bson                                                               1.0.1      1.0.2                   
   > RabbitMQ.Client                                                                    5.0.1      5.2.0                   
   > runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl           4.3.0      4.3.3                   
   > runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl          4.3.0      4.3.3                   
   > runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl          4.3.0      4.3.3                   
   > runtime.native.System                                                              4.3.0      4.3.1                   
   > runtime.native.System.IO.Compression                                               4.3.0      4.3.2                   
   > runtime.native.System.Net.Http                                                     4.3.0      4.3.1                   
   > runtime.native.System.Net.Security                                                 4.3.0      4.3.1                   
   > runtime.native.System.Security.Cryptography.Apple                                  4.3.0      4.3.1                   
   > runtime.native.System.Security.Cryptography.OpenSsl                                4.3.0      4.3.3                   
   > runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl      4.3.0      4.3.3                   
   > runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl      4.3.0      4.3.3                   
   > runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple            4.3.0      4.3.1                   
   > runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl          4.3.0      4.3.3                   
   > runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl             4.3.0      4.3.3                   
   > runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl       4.3.0      4.3.3                   
   > runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl       4.3.0      4.3.3                   
   > runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl       4.3.0      4.3.3                   
   > System.Buffers                                                                     4.5.0      4.5.1                   
   > System.Console                                                                     4.3.0      4.3.1                   
   > System.Drawing.Common                                                              5.0.0      5.0.2                   
   > System.IO.Pipelines                                                                4.5.2      4.7.4                   
   > System.Linq.Dynamic.Core                                                           1.2.9      1.2.10                  
   > System.Memory                                                                      4.5.1      4.5.4                   
   > System.Net.Http                                                                    4.3.0      4.3.4                   
   > System.Net.Primitives                                                              4.3.0      4.3.1                   
   > System.Net.Security                                                                4.3.0      4.3.2                   
   > System.Reflection.Emit.ILGeneration                                                4.3.0      4.7.0                   
   > System.Reflection.Emit.Lightweight                                                 4.3.0      4.7.0                   
   > System.Reflection.TypeExtensions                                                   4.3.0      4.7.0                   
   > System.Runtime                                                                     4.3.0      4.3.1                   
   > System.Runtime.CompilerServices.Unsafe                                             4.5.1      4.7.1                   
   > System.Runtime.Extensions                                                          4.3.0      4.3.1                   
   > System.Security.Cryptography.Algorithms                                            4.3.0      4.3.1                   
   > System.Security.Cryptography.Cng                                                   4.5.0      4.7.0                   
   > System.Security.Cryptography.OpenSsl                                               4.3.0      4.7.0                   
   > System.Security.Cryptography.Pkcs                                                  4.5.0      4.7.0                   
   > System.Security.Cryptography.X509Certificates                                      4.3.0      4.3.2                   
   > System.Security.Cryptography.Xml                                                   4.5.0      4.7.0                   
   > System.Text.Encoding.CodePages                                                     4.7.0      4.7.1                   
   > System.Text.Encodings.Web                                                          4.5.0      4.7.2                   
   > System.Text.RegularExpressions                                                     4.3.0      4.3.1                   
   > System.Threading.Tasks.Extensions                                                  4.3.0      4.5.4                   
   > System.Xml.ReaderWriter                                                            4.3.0      4.3.1                   
   > Foo.Bar.Application                                                        1.0.0      Not found at the sources
   > Foo.Bar.Common                                                             1.0.0      Not found at the sources
   > Foo.Bar.Domain                                                             1.0.0      Not found at the sources

    

I have checked the list, but I cannot figure out how can I deduct which package is to blame for not using .NET 5.

Any idea about how to find out the culprit?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+4
−0

You could start to track down the problem by using Assembly.LoadFrom() to attempt loading each library individually.

I have a routine in a .NET 5 solution that performs some analysis on assemblies deployed with my application. I retooled it a bit here to make something that would work as part of a console application your could run in your .NET 5 only environment as a step in the debugging process.

// Look for DLL plugins
foreach (string pluginDll in Directory.GetFiles(".", "*.dll", SearchOption.AllDirectories))
{
    try
    {
        Console.WriteLine("Attempting to load " + pluginDll);
        Assembly.LoadFrom(pluginDll);
        Console.WriteLine(pluginDll + " Loaded");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: " + ex);
    }
}

If you run this from the location of your application, it will try to load all dlls and will give you feedback about which ones can and can't load.


A full working code in .NET 5 that shows a meaningful string to identify the target framework:

static void Main(string[] args)
{
	var dirPath = "full path to directory containing all assemblies";
	var loadedDlls = new HashSet<string>();

	foreach (string pluginDll in Directory.GetFiles(dirPath, "*.dll", SearchOption.AllDirectories))
	{
		string filename = Path.GetFileName(pluginDll);

		if (loadedDlls.Contains(filename))
		{
			Console.WriteLine($"{filename} already loaded");
			continue;
		}

		try
		{
			Console.WriteLine("Attempting to load " + pluginDll);
			var assembly = Assembly.LoadFrom(pluginDll);

			var targetFwk = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType == typeof(TargetFrameworkAttribute));
			Console.WriteLine($"{pluginDll}: Target fwk = {targetFwk?.ConstructorArguments[0].Value}");

			loadedDlls.Add(filename);
		}
		catch (Exception ex)
		{
			Console.WriteLine("Error: " + ex);
		}
	}
}
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

I cannot check it right now, but I will try it and let you know what I was able to find out. Thanks. (2 comments)
I cannot check it right now, but I will try it and let you know what I was able to find out. Thanks.
Alexei‭ wrote over 3 years ago

I cannot check it right now, but I will try it and let you know what I was able to find out. Thanks.

Alexei‭ wrote over 3 years ago

I have checked the code and your idea worked as expected. I have also included the code that showed me meaningful target frameworks for most of my assemblies. Indeed some Microsoft.* assemblies are targeting 3.0 or 3.1. I am wondering if .NET Standard 2.0 as a target is an issue here (as opposed to 2.1) or only those 3.x versions are those creating a dependency on the ASP.NET Core 3.x runtime? Thank you.