Bug 56868 - Netstandard resources library is missing from apk file
Summary: Netstandard resources library is missing from apk file
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.3 (15.2)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-05-26 10:49 UTC by krt
Modified: 2017-08-30 10:06 UTC (History)
4 users (show)

Tags: bb
Is this bug a regression?: ---
Last known good build:


Attachments
Sample project demonstrating issue (11.89 KB, application/x-zip-compressed)
2017-06-26 06:21 UTC, krt
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 56868 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description krt 2017-05-26 10:49:19 UTC
I've added nuget package "Humanizer.Core.ru" to my project.

I see that it's referenced in csproj file:
  <ItemGroup>
    <PackageReference Include="Humanizer.Core.ru">
      <Version>2.2.0</Version>
    </PackageReference>
  </ItemGroup>

I see its presence in obj/project.assets.json:
      "Humanizer.Core.ru/2.2.0": {
        "type": "package",
        "dependencies": {
          "Humanizer.Core": "[2.2.0]"
        },
        "resource": {
          "lib/netstandard1.0/ru/Humanizer.resources.dll": {
            "locale": "ru"
          }
        }
      }

But it's missing from release .apk build (only Humanizer.dll is there). And my app is crashing with 
System.ArgumentException: The resource object with key 'DateHumanize_MultipleYearsAgo' was not found
Comment 1 krt 2017-05-26 10:54:28 UTC
Software versions:

VS 15.2 (26430.6) Release
Xamarin 4.5.0.443 (c871575)
Xamarin.Android.SDK 7.3.0.13 (448f54f)
Comment 2 Oren Novotny 2017-05-29 13:34:35 UTC
This is a tooling issue -- I believe the fix has been merged but I'm not sure how/where it makes it into the tooling: https://github.com/dotnet/sdk/issues/1006
Comment 3 krt 2017-05-29 13:43:10 UTC
But I don't have this issue with console application (with new .csproj file format). And I don't see Humanizer.resources.dll anywhere (it hasn't been overwritten because main assembly is Humanizer.dll)
Comment 4 Jon Douglas [MSFT] 2017-06-23 17:06:13 UTC
(In reply to krt from comment #3)
> But I don't have this issue with console application (with new .csproj file
> format). And I don't see Humanizer.resources.dll anywhere (it hasn't been
> overwritten because main assembly is Humanizer.dll)

I believe this would also potentially work with using packages.config as the PackageReference still needs work in some tooling. Other than that, can you please upload a sample project demonstrating this issue on the Xamarin.Android side of things? I am marking this bug as NEEDINFO until we have a reproduction of this issue and it's not resolved UPSTREAM.
Comment 5 krt 2017-06-26 06:21:34 UTC
Created attachment 23103 [details]
Sample project demonstrating issue
Comment 7 Jon Douglas [MSFT] 2017-08-14 18:50:59 UTC
I'm seeing the following error on 15.3 and 15.3 (Preview 7.1) with the provided project:

2>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1411,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Humanizer, Version=2.2.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e'. Perhaps it doesn't exist in the Mono for Android profile?
2>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1411,2): error : File name: 'Humanizer.dll'
2>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1411,2): error :    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
2>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1411,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
2>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1411,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)
2>  Output Item(s): ResolvedAssemblies= (TaskId:242)
2>  Output Item(s): ResolvedUserAssemblies= (TaskId:242)
2>  Output Item(s): ResolvedFrameworkAssemblies= (TaskId:242)
2>  Output Item(s): ResolvedSymbols= (TaskId:242)
2>Done executing task "ResolveAssemblies" -- FAILED. (TaskId:242)
2>Done building target "_ResolveAssemblies" in project "testproj.csproj" -- FAILED.: (TargetId:221)

It seems you can resolve this in the reproduction project if you add the Humanizer and Humanizer.Core.ru packages to the Xamarin.Android project.

---------------------------------------

The fix Oren is referring to seems to be apart of the newly released .NET Core 2.0 SDK which you can download here: https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.0-download.md

From my initial investigation, it seems like we need to ensure the 2.0 version is being used rather than 1.1.0. However I still need to investigate that the SDK changes are being used in the build process.

Marking as CONFIRMED for the time being as I was able to reproduce..
Comment 8 krt 2017-08-30 10:06:34 UTC
I think the problem is that generated file obj/project.assets.json does not contain runtime identifier and it prevents from resolving CopyLocal items here https://github.com/NuGet/NuGet.BuildTasks/blob/dev/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs#L311