-
Notifications
You must be signed in to change notification settings - Fork 427
Visual Studio uses netstandard1.3 instead of net452 when consumed by a net461 project #580
Comments
I just tried this locally with a package that has two dlls, one in |
the package is https://www.nuget.org/packages/MQTTnet/2.5.1 the repository with the source is already mentioned above. if i add net461 targetframework to MQTTnet/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj my output is the following: net452 is ok: net461 contains system.security dlls that are only included for netstandard https://github.com/chkr1011/MQTTnet/blob/develop/Build/MQTTnet.nuspec so i actually dont know how to verify what dll is chosen as they all have the same name. but it seems all dependencies in the group netstandard 1.3 are included. |
i just verified it, the dll itself is chosen correctly i added the following code to the package: public static class TargetFraameworkProvider
{
public static string TargetFramework
{
get
{
#if NET452
return "net452";
#elif NET461
return "net461";
#elif NETSTANDARD1_3
return "netstandard1.3";
#elif NETSTANDARD2_0
return "netstandard2.0";
#elif WINDOWS_UWP
return "uap10.0";
#endif
}
}
} that prints 452 when included from 461 but the system security dlls are still copied to the ouput folder although they should not be included. |
also if i add net461 to that project (so there is an exact match later on) its bin folder already contains the dlls that are not present in net452 bin folder |
Those are likely the netstandard 2.0 shims for net461+ that are copied from |
but why are these shims not required for net452? also when i downgrade the extension packages to 1.0.2 which depends on netstandard 1.1 i still see the same behavior for net461. and why arent these shims visualized in the dependency tree of the included nugets? |
because the logic only kicks in for net461+ https://github.com/dotnet/sdk/blob/aeb50655bbf9ee652c21b1f1375c6107fe1f0790/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets#L17-L18 If you retarget to 4.7.1, you shouldn't get additional assemblies - using 2.0.2 / VS 15.4.* (15.5 should add back a few again since there are bugs because of how the assemblies in 4.7.1 are versioned) |
okay that wasn't a good explanation 😅 @joperezr can probably give a good. |
hmm sry I just dont understand why that is brought in with a targets file. For me this is some kind of black magic. Why doesnt the nuget i reference include everything it needs for the target platform i specify. so i can clearly see what i depend on? i created a nuget with the downgraded packages. and if i now use that nuget none of that additional dlls are copied to the consuming package, when adding a project reference they are copied. that is confusing me even more. |
@dasMulli is right, those libraries you are seeing are just the shims that will enable running netstandard based dlls on desktop. I agree that is not great that all of these files are being brought in by a targets file, but here is the reasoning behind it. We started having a lot of users that wanted to consume .NET Standard components on desktop, and they were all failing when trying to run because they were missing these shims. Originally, we decided that the proposed solution was that if you wanted to do this, you had to add a reference to the package |
thx for clarifying. |
From my opinionated end-user perspective I actually prefer this to be done by the tooling. It would be hard to track which projects would need updates to a |
i am contributing to a library https://github.com/chkr1011/MQTTnet this library targets netstandard1.3 and net452.
recently we get complaints by consumers of the library that we have added so many dependencies.
if a project targeting net461 all dependencies that are required for netstandard 1.3 are forced on that project.
why is that the case?
My understanding is that visual studio should use net452 dlls when targeting net462 not netstandard1.3 + added polyfill dependencies
if this issue is in the wrong place feel free to move it where it belongs i didnt know a better place to start with.
The text was updated successfully, but these errors were encountered: