NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 253 forks source link

Inaccurate Target #3812

Closed sunnydaleDoby closed 7 years ago

sunnydaleDoby commented 7 years ago

Details about Problem

When trying to install System.Numerics.Vectors.4.1.1 into a VS2015 c++ project, the system gives the following error:

Severity Code Description Project File Line Suppression State Error Could not install package 'System.Numerics.Vectors 4.1.1'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I have also installed the Package Manager Console and have the same problem.

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): latest, downloaded from NuGet today.

NuGet version (x.x.x.xxx): Not sure where to find the version for the VS utility. The package manager console version is: 3.5.0.1996

dotnet.exe --version (if appropirate):

VS version (if appropriate):

OS version (i.e. win10 v1607 (14393.321)): Windows 10.

Worked before? If so, with which NuGet version:

Detailed repro steps so we can see the same problem

  1. Open new C++ project -- blank app (Universal Windows)
  2. Goto Tools > NuGet Package Manager > Manage NuGet Packages for Solution > Browse > search for System.Numerics.Vectors > Install

    Other observations:

  3. Do the same steps for a C# project and it installs fine.
  4. Win2D installs fine.
  5. The same error is generated with command line package manager.

...

Other suggested things

Verbose Logs

Please include verbose logs (NuGet.exe -verbosity detailed | dotnet.exe --verbose | etc...)

Sample Project

Very helpful if you can zip a project and paste into this issue! The minimal project is rejected -- its 40mb zipped.

zhili1208 commented 7 years ago

why you want to install this package to C++ project? this package is not supported for c++.

sunnydaleDoby commented 7 years ago

I disagree.

It's part of the .net framework which should work for managed c++ code. All .net code interacts across the many languages, including managed c++. There is nothing on the Microsoft website that says it's not for c++.

I am trying to install this into a managed code project --even though the error message says native code.

Clearly there is an error.

Tom

On Mon, Nov 28, 2016 at 2:47 PM, Zhi Li notifications@github.com wrote:

why you want to install this package to C++ project? this package is not supported for c++.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NuGet/Home/issues/3812#issuecomment-263419454, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDkkQ88n_IT5KXxR50cPUDLB5dl0Zkjks5rC1nxgaJpZM4Kjxtf .

sunnydaleDoby commented 7 years ago

In fact, Microsoft gives ++ examples on their website:

https://msdn.microsoft.com/en-us/library/dn858385(v=vs.111).aspx

Tom

On Mon, Nov 28, 2016 at 5:04 PM, Thomas Dobroth dobroth@gmail.com wrote:

I disagree.

It's part of the .net framework which should work for managed c++ code. All .net code interacts across the many languages, including managed c++. There is nothing on the Microsoft website that says it's not for c++.

I am trying to install this into a managed code project --even though the error message says native code.

Clearly there is an error.

Tom

On Mon, Nov 28, 2016 at 2:47 PM, Zhi Li notifications@github.com wrote:

why you want to install this package to C++ project? this package is not supported for c++.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NuGet/Home/issues/3812#issuecomment-263419454, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDkkQ88n_IT5KXxR50cPUDLB5dl0Zkjks5rC1nxgaJpZM4Kjxtf .

zhili1208 commented 7 years ago

Yes, this DLL should work with managed C++, but NuGet is not support managed C++ scenario now. So you can't install the package, you need to download this package and add reference manually.

sunnydaleDoby commented 7 years ago

How does one download the package, disassemble it and install manually? The download is a NuGet package that I cannot disassemble.

Tom

On Mon, Nov 28, 2016 at 5:21 PM, Zhi Li notifications@github.com wrote:

Yes, this DLL should work with managed C++, but NuGet is not support managed C++ scenario now. So you can't install the package, you need to download this package and add reference manually.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NuGet/Home/issues/3812#issuecomment-263448062, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDkkRahCSMjeDlC_3GefcU8nedBifmoks5rC34jgaJpZM4Kjxtf .

ericstj commented 7 years ago

Even if you could install it (you can't, that's a NuGet bug with how it represents C++ UWP projects) how do you intend to use a managed DLL in a native C++ project? This isn't a winmd. There is no "managed C++" UWP project.

sunnydaleDoby commented 7 years ago

Again, Again,

It's a managed project that I'm trying to install it.

No different than Win2D that installs fine.

The error message gives bad information that is misleading you.

Tom

On Mon, Nov 28, 2016 at 9:23 PM, Eric StJohn notifications@github.com wrote:

Even if you could install it (you can't, that's a NuGet bug with how it represents C++ UWP projects) how do you intend to use a managed DLL in a native C++ project? This isn't a winmd. There is no "managed C++" UWP project.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NuGet/Home/issues/3812#issuecomment-263479587, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDkkXgy9Bd5Y7n0vWeKO7BKUoJEPj95ks5rC7bvgaJpZM4Kjxtf .

zhili1208 commented 7 years ago

you can change the nupkg file to zip file and unzip it

ericstj commented 7 years ago

The error message gives bad information that is misleading you.

It's not misleading me. That is indeed how NuGet classifies all C++ projects and is why I said that's a NuGet bug with how it represents C++ UWP projects

I worked with Win2D to make that package work with native C++ projects. The reason it works in the C++ project is that it contains build/native/*.targets which is applicable in the C++ project.

Win2D has a WinMD which is consumable by the native toolset and provides useful surface area on top of that which is available by the platform (eg: Windows.winmd).

System.Numerics.Vectors does not expose a WinMD. All the types it exposes are either projections of types already in the platform (Windows.winmd) or types that are exclusively managed. /cc @mellinoe

I think you're fighting an uphill battle if you're trying to make managed C++ work for UWP. That's not supported and the C++ compiler won't even handle the .NET Core assemblies used by UWP.

The only context you can use System.Numerics.Vectors in a C++ project is as dependency of a managed WinMD. When the UWP toolchain sees a managed winmd it will inject the entire framework (including System.Numerics.Vectors) during the build.

sunnydaleDoby commented 7 years ago

So I cannot get the hardware accelerated vector math that is available in c# and VB?

On Tue, Nov 29, 2016 at 3:50 PM, Eric StJohn notifications@github.com wrote:

The error message gives bad information that is misleading you.

It's not misleading me. That is indeed how NuGet classifies all C++ projects and is why I said that's a NuGet bug with how it represents C++ UWP projects

I worked with Win2D to make that package work with native C++ projects. The reason it works in the C++ project is that it contains build/native/*.targets which is applicable in the C++ project.

Win2D has a WinMD which is consumable by the native toolset and provides useful surface area on top of that which is available by the platform (eg: Windows.winmd).

System.Numerics.Vectors does not expose a WinMD. All the types it exposes are either projections of types already in the platform (Windows.winmd) or types that are exclusively managed. /cc @mellinoe https://github.com/mellinoe

I think you're fighting an uphill battle if you're trying to make managed C++ work for UWP. That's not supported and the C++ compiler won't even handle the .NET Core assemblies used by UWP.

The only context you can use System.Numerics.Vectors in a C++ project is as dependency of a managed WinMD. When the UWP toolchain sees a managed winmd it will inject the entire framework (including System.Numerics.Vectors) during the build.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NuGet/Home/issues/3812#issuecomment-263738244, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDkkbNfNdsJBRuSy-NviP0H6et14Ssmks5rDLpYgaJpZM4Kjxtf .

ericstj commented 7 years ago

I'm no expert here but here is my understanding: System.Numerics.Vectors was needed to teach the .NET JIT that you wanted to use SIMD instructions by introducing types that would work with those instructions. Some native types already exist in Windows.winmd that were equivalent and those types were made equivalent through projection, but you can use the native types just fine. My understanding is that the C++ compiler has supported SIMD instructions for much longer than .NET and has its own representation of types that correspond to these instructions. @damyanp or @shawnhar might be able to provide more details about how to use those native types.

mellinoe commented 7 years ago

Yeah, there should be some separate types for C++ that you can use which leverage some SIMD intrinsics. https://github.com/Microsoft/Win2D/blob/master/numerics/Cpp/WindowsNumerics.h. I'm also not an expert on this part, but you should be able to use those types if you just include that header. It should already be in your project if you've installed the Win2D nuget package.

shawnhar commented 7 years ago

@sunnydaleDoby you are confusing managed projects with Windows Runtime projects. These have some similarities, but are fundamentally quite different things.

Managed C++, aka C++/CLI (https://en.wikipedia.org/wiki/C%2B%2B/CLI) compiles into .NET IL. The resulting assemblies look just like any other .NET assembly, and can fully interop with any other .NET language - but this technology is not supported for creating UWP apps.

C++ component extensions for the Windows Runtime, aka C++/CX (https://en.wikipedia.org/wiki/C%2B%2B/CX) has a roughly similar syntax but compiles directly into native code. This is what you are using when you create a UWP project, and when you call Win2D APIs.

C++/CX projects can use Win2D because Win2D is a Windows Runtime API, not a .NET API. You cannot call directly into a .NET assembly from C++/CX (although it would be possible to interop via an intermediate Windows Runtime wrappper).

There are many options for SIMD programming in C++, but System.Numerics.Vectors is not one of them. Start with WindowsNumerics.h (https://msdn.microsoft.com/en-us/library/windows/desktop/mt759297(v=vs.85).aspx) if you are working with Windows Runtime APIs, or DirectXMath (https://msdn.microsoft.com/en-us/library/windows/desktop/hh437833(v=vs.85).aspx) if you want to go deeper into low level optimization.

@mellinoe the math types included as part of Win2D are only for downlevel support on Windows 8.1 OS. For UWP apps, everything necessary is included directly in the platform SDK: https://blogs.msdn.microsoft.com/win2d/2015/06/02/winrt-vector-and-matrix-types-in-windows-10/

rrelyea commented 7 years ago

@sunnydaleDoby - does that address your issue? Closing as question. Please let us know if not.

sunnydaleDoby commented 7 years ago

No. I have very little confidence in this answer. Managed c++ code should be able to do anything c# code can.

This did not address the issue. I am left trying to prove a negative.

On Fri, Dec 9, 2016 at 1:49 PM, Rob Relyea notifications@github.com wrote:

Closed #3812 https://github.com/NuGet/Home/issues/3812.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NuGet/Home/issues/3812#event-888976140, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDkkalKVWFKgMNhEKnCmVM_Rd9R6zSgks5rGczqgaJpZM4Kjxtf .