Azure-Kinect-Sensor-SDK icon indicating copy to clipboard operation
Azure-Kinect-Sensor-SDK copied to clipboard

Cannot reference Sensor SDK from .NET Class Library

Open dotMorten opened this issue 4 years ago • 6 comments

Describe the bug Create a new .NET Standard Class Library, and you'll be prevented from referencing the SDK due to the class library being AnyCPU. This limitation should not be put on libraries but only on applications.

To Reproduce

  1. Create a new .NET Standard Class Library
  2. Add the Microsoft.Azure.Kinect.Sensor nuget package
  3. Notice the error in the output window:
1>C:\Users\mn\.nuget\packages\microsoft.azure.kinect.sensor\1.3.0\build\netstandard2.0\Microsoft.Azure.Kinect.Sensor.targets(4,5): error : Azure Kinect only supports the x86/x64 platform ('AnyCPU' not supported)
1>Done building project "Microsoft.Azure.Kinect.BodyTracking.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Expected behavior Check should only be done on applications, not libraries.

Suggested fix Change the targets file to also check on output type:

  <Target Name="EnsureAzureKinectPlatform" BeforeTargets="PrepareForBuild">
    <Error Condition="'$(Platform)' != 'x64' AND '$(Platform)' != 'x86' AND '$(OutputType)'!='Library'" Text="Azure Kinect only supports the x86/x64 platform ('$(Platform)' not supported)" />
  </Target>

Side note Since such a class library would transitively bring in the kinect sensor package, you should also add the same build files in the nuget package to /buildTransitive/ to ensure the .targets file are run on applications not directly referencing that nuget package.

Screenshots image

Desktop (please complete the following information):

  • OS with Version: N/A
  • SDK Version: 1.3.0
  • Firmware version: N/A

Additional context

dotMorten avatar Nov 07 '19 07:11 dotMorten

In addition referencing the project from a .NET Core WPF app, you'll hit a similar issue because it doesn't use the $(Platform) value, but relies on runtime identifiers instead.

dotMorten avatar Nov 07 '19 08:11 dotMorten

Thanks. We should be publishing a new alpha after we complete #822 and I'll try integrating those suggestions to the NuGet release.

FYI, #822 adds some APIs to expose raw handle access that will make it possible to interop with the body tracking SDK.

Brent-A avatar Nov 07 '19 19:11 Brent-A

Is this still an issue? I thought it would be fixed for 1.4.0...

vpenades avatar Mar 10 '20 09:03 vpenades

@qm13 Was this addressed?

dotMorten avatar Jul 11 '20 02:07 dotMorten

@dotMorten my bad. I believe this is still an issue.

qm13 avatar Jul 14 '20 00:07 qm13

Any chance there's a workaround for this until this can get fixed?

tmoody460 avatar Jul 17 '20 04:07 tmoody460