dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

Package Dependency issue: NuGet's fault? #331

Closed DSakura207 closed 7 years ago

DSakura207 commented 7 years ago

Hi there, My company uses PInvoke.NCrypt. When we update the package, the dependency is incorrect, NuGet sets PInvoke.Windows.Core's HintPath to .Net 2.0 version, not .Net 4.0. I have tried to install it in a fresh project and the same thing happens. Targeting 4.6.1 or 4.6.2 doesn't make a difference. Here is the output from the Package Manager Console:

PM> Install-package PInvoke.NCrypt

Attempting to gather dependency information for package 'PInvoke.NCrypt.0.5.64' with respect to project 'TestApplication', targeting '.NETFramework,Version=v4.6.2' Gathering dependency information took 517.45 ms Attempting to resolve dependencies for package 'PInvoke.NCrypt.0.5.64' with DependencyBehavior 'Lowest' Resolving dependency information took 0 ms Resolving actions to install package 'PInvoke.NCrypt.0.5.64' Resolved actions to install package 'PInvoke.NCrypt.0.5.64' Retrieving package 'PInvoke.BCrypt 0.5.64' from 'nuget.org'. Retrieving package 'PInvoke.Kernel32 0.5.64' from 'nuget.org'. Retrieving package 'PInvoke.NCrypt 0.5.64' from 'nuget.org'. Retrieving package 'PInvoke.Windows.Core 0.5.64' from 'nuget.org'. Adding package 'PInvoke.Windows.Core.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.Windows.Core.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.Windows.Core.0.5.64' to 'packages.config' Successfully installed 'PInvoke.Windows.Core 0.5.64' to TestApplication Adding package 'PInvoke.Kernel32.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.Kernel32.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.Kernel32.0.5.64' to 'packages.config' Successfully installed 'PInvoke.Kernel32 0.5.64' to TestApplication Adding package 'PInvoke.BCrypt.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.BCrypt.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.BCrypt.0.5.64' to 'packages.config' Successfully installed 'PInvoke.BCrypt 0.5.64' to TestApplication Adding package 'PInvoke.NCrypt.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.NCrypt.0.5.64' to folder 'D:\visual studio 2017\Projects\TestApplication\packages' Added package 'PInvoke.NCrypt.0.5.64' to 'packages.config' Successfully installed 'PInvoke.NCrypt 0.5.64' to TestApplication Executing nuget actions took 1.54 sec Time Elapsed: 00:00:02.5184976

Is there anything wrong with the dependency?

Thanks :)

AArnott commented 7 years ago

By design. There is no need for net40 or higher for the Windows.Core package so we only ship net20.

DSakura207 commented 7 years ago

If I understand @AArnott correctly, net40 and higher does not need the Windows.Core package, right? However NuGet says it is needed for .Net 4.0 and portable class library 4.0 & 4.5. Hence, NuGet will add net20 reference to project references and cause compiler throw CS1685 for System.Runtime.CompilerServices.ExtensionAttribute.

I guess something just went wrong...

AArnott commented 7 years ago

@DSakura1987 Can you provide the repro project or repro steps to see the compiler error that you are seeing?