1
votes

Everything was rolling along smoothly until a few days ago when UWP all of a sudden stopped building after pulling a new version from VSTS (git) with the errors:

  • Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: X.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.'
  • Could not copy the file "obj\x86\Debug\MainPage.xbf" because it was not found.
  • Could not copy the file "obj\x86\Debug\App.xbf" because it was not found.
  • Could not copy the file "obj\x86\Debug\X.Mobile.UWP.xr.xml" because it was not found.

I have a solution structure of the following:

  • X.Core (.NET Standard class library)
  • X.Mobile (.NET Standard PCL)
  • X.Mobile.UWP (UWP specific project)

UWP references Mobile, and Mobile references Core (Core is also referenced by a web API project).

The commit that I pulled from source control did not have any changes to the X.Mobile.UWP .csproj file.

Things I have tried:

  1. The obligatory clean and rebuild.
  2. Delete all obj and bin folders for the entire solution.
  3. Remove and re-add all references in the .UWP project.
  4. Upgrade Xamarin.Forms to the latest stable (3.1.0.637273).
  5. Remove and re-add X.Core reference in the X.Mobile project.
  6. Delete C:\Users\%username%.nuget folder.
  7. Update Microsoft.NETCore.UniversalWindowsPlatform to the latest stable (6.1.5).
  8. Change the target version to all available versions - we've been running on build 16299 for several months.

And I've been beating my head against this problem on and off for days now. Android and iOS projects build just fine, which is ironic considering UWP has been our most stable platform. Anyone have any insight?

EDIT: After adding a reference to X.Core directly to the X.Mobile.UWP project, I can compile. This shouldn't be the answer though since UWP never directly references Core.

2
What is the .Net Standard PCL? Without detailed reproducible project I can not see the issue, would you create a minimal repro sample?Breeze Liu - MSFT
The .NET Standard PCL is the "shared" project. The original .NET Core PCL was deprecated, so when you're creating a project in VS2017 your options for Code Sharing Strategy are a shared project and .NET Standard. I apparently cannot reproduce this in a brand new project with the same structure. I'll keep trying to reproduce and add a link to my GitHub if I can.kwinsor5

2 Answers

1
votes

I found the solution.

I had the very same problem because I had added a new (.Net Standard 2.0 Class Library) project into my Xamarin.Forms solution.

In short, initially my solution included the following projects:

BackgroundTaskTest (which have all my Views and ViewModels)
BackgroundTaskTest.Android
BackgroundTaskTest.iOS
BackgroundTaskTest.UWP

Suddenly I decided to add a class library named "BackgroundTaskTest.Common" in the same solution folder:

BackgroundTaskTest.Common (new one)
BackgroundTaskTest (which have all my Views and ViewModels)
BackgroundTaskTest.Android
BackgroundTaskTest.iOS
BackgroundTaskTest.UWP

The Android was working fine with it but the UWP project didn't like that new neighbor (which in your case is named "X.Core"). So I moved my classes from that new project to the "BackgroundTaskTest" again and deleted "BackgroundTaskTest.Common" from my solution with all the references and it has started working.

To finalize and make it short, please compare your X.Mobile.csproj file with X.Mobile.Core.csproj file. you will find the issue in the differences. Plus try to check all your dependencies to the X.Core project to make sure they are the same.

1
votes

I installed NuGet package "NETStandard.Library" and added a reference to all my .Net Standard libraries to my UWP project. This solved the problem for me!