NuGet restores/installs/locks invalid dll variant for UWP app

95 views Asked by At

New UWP project (targeting 10586 or AU version, doesn't matter). When installing package Google.Apis 1.20 (or other versions) project.lock.json contains following lines:

{
  "version": 2,
  "targets": {
    "UAP,Version=v10.0": {
      "Google.Apis/1.20.0": {
        "type": "package",
        "dependencies": {
          "Google.Apis.Core": "1.20.0",
          ...          
          "System.Threading.Tasks": "4.0.11"
        },
        "compile": {
          "lib/win81/Google.Apis.PlatformServices.dll": {},
          "lib/win81/Google.Apis.dll": {}
        },
        "runtime": {
          "lib/win81/Google.Apis.PlatformServices.dll": {},
          "lib/win81/Google.Apis.dll": {}
        }
      },

I am wondering why the compile/runtime nodes are referencing lib/win81 while the package itself contains netstandard1.3 folder.

If I install Google.Apis.Core, it references netstandard1.3 dlls from this package and still win81 dlls from Google.Apis.

Wondering, why is that and how to force it to use netstandard1.3 instead?


Here is a structure and nuspec of the package:

Google Apis package tree

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>Google.Apis</id>
    <version>1.20.0</version>
    <title>Google APIs Client Library</title>
    <authors>Google Inc.</authors>
    <owners>google-apis-packages</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
    <projectUrl>https://developers.google.com/api-client-library/dotnet</projectUrl>
    <description>The Google APIs Client Library is a runtime client for working with Google services.
          The library supports service requests, media upload and download, etc.

          Supported Platforms:

          - .NET Framework 4.5 and 4.6

          - NetStandard1.3

          - Windows 8 Apps

          - Windows Phone 8 and 8.1

          - Portable Class Libraries</description>
    <tags>Google</tags>
    <dependencies>
      <group>
        <dependency id="Google.Apis.Core" version="1.20.0" />
        <dependency id="Zlib.Portable.Signed" version="1.11.0" />
      </group>
      <group targetFramework=".NETFramework4.5">
        <dependency id="log4net" version="2.0.3" />
        <dependency id="Google.Apis.Core" version="1.20.0" />
        <dependency id="Zlib.Portable.Signed" version="1.11.0" />
      </group>
      <group targetFramework=".NETStandard1.3">
        <dependency id="Google.Apis.Core" version="1.20.0" />
        <dependency id="System.Collections" version="4.0.11" />
        <dependency id="System.Diagnostics.Debug" version="4.0.11" />
        <dependency id="System.IO" version="4.1.0" />
        <dependency id="System.IO.Compression" version="4.1.0" />
        <dependency id="System.Linq" version="4.1.0" />
        <dependency id="System.Net.Http" version="4.1.0" />
        <dependency id="System.Net.Primitives" version="4.0.11" />
        <dependency id="System.Reflection" version="4.1.0" />
        <dependency id="System.Runtime" version="4.1.0" />
        <dependency id="System.Runtime.Extensions" version="4.1.0" />
        <dependency id="System.Text.Encoding" version="4.0.11" />
        <dependency id="System.Threading" version="4.0.11" />
        <dependency id="System.Threading.Tasks" version="4.0.11" />
        <dependency id="System.Reflection.TypeExtensions" version="4.1.0" />
      </group>
    </dependencies>
  </metadata>
</package>
2

There are 2 answers

4
Sunteen Wu On

According to the description of the Google APIs Client Library 1.20.0 Nuget package, it supported follow platforms:

  • .NET Framework 4.5 and 4.6

  • NetStandard1.3

  • Windows 8 Apps

  • Windows Phone 8 and 8.1

  • Portable Class Libraries

Same as Google APIs Core Client Library 1.20.0 library. So we are not sure if all the features of this package support UWP platform, but it should be worked for UWP. I'm not sure why you need to change the Dll reference if this package can work for UWP app, if you are met issues when building the uwp app with this package, please try to update the .Net Core version to 5.2.2 in the project.json file as follows, it will build successfully and you can try to go on.

{
 "dependencies": {
  "Google.Apis": "1.20.0",
  "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
}

Anyway, reference which dll depend on how the google-apis-packages team package the library, we cannot directly change it. The compile just shows the directory structure. If you want to force change it, you may need to package the library by yourself, details please reference Creating a Package. In my opinion packaging by yourself may be fussy and this package possible cannot be used in uwp.

0
Linda Lawton - DaImTo On

The Google .Net clinet library does not currently support UWP. We are hoping to support UWP in v2 release which should be early 2017 see #787