UWP - Cannot resolve Assembly or Windows Metadata file

kwinsor5kwinsor5 Member ✭✭
edited July 2018 in Xamarin.Forms

Hi All,

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 to the X.Mobile.UWP project directly, I can compile. This shouldn't be the answer though since the UWP project never directly references the Core project.

Answers

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    @kwinsor5 , Which version of Visual Studio are you using? Could you please try update VS to the latest Version(15.7.5) and try again?

  • kwinsor5kwinsor5 Member ✭✭

    Thanks for the reply, @ElvisXia. Yes, I am currently running 15.7.5.

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai
    edited July 2018

    @kwinsor5 Could you please try the project on other machine? If the error doesn't occur on other windows machine. You can try repair/reinstall VS through VS installer. If the error did occur on other machine, could you please share a basic demo about that so that I can try it on my side and try to find a solution to this issue?

  • kwinsor5kwinsor5 Member ✭✭
    edited July 2018

    @ElvisXia The other 2 developers on the project get the same exceptions. I briefly tried to reproduce the issue in a new project and I wasn't able to, so it's definitely project specific. I will try to build the project on a brand new machine today. I'll keep you posted.

    EDIT: Yes, the errors exist on a brand new machine as well.

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    @kwinsor5 If this issue is not reproduceable in a blank project, then you can copy all the files to a new project(With the same project name) and try again. I think this can fix the issue.

  • MichelMoorlagMichelMoorlag USMember ✭✭

    Having this same issue. Is there any solution fix for this?

  • kwinsor5kwinsor5 Member ✭✭

    I haven't found one that works, though I haven't tried @ElvisXia's suggestion of creating a blank project and copying all files over. My project isn't exactly small so I was kind of just hoping Xamarin would release a fix for it before too long as it's not crippling, just an extra reference in my UWP project. If you do try it let us know if it works for you!

  • I believe 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. :smiley:

    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. :wink:

  • kwinsor5kwinsor5 Member ✭✭

    @Siavash_Nabavizadeh Thanks for the response. Removing the project isn't an option for me as another web API project references X.Core also. If you meant that you created a new project, moved the files over, and deleted the original .Common project I'll give that a shot, though.

  • > @kwinsor5 said:
    > @Siavash_Nabavizadeh Thanks for the response. Removing the project isn't an option for me as another web API project references X.Core also. If you meant that you created a new project, moved the files over, and deleted the original .Common project I'll give that a shot, though.

    Yes actually I wanted to mention the fact that, by removing it starts working. Therefore, the project was added in wrong or faulty status.You can create another working one and compare the *.csproj files of the correct one and not working one.
  • SymboLinkerSymboLinker Member
    edited March 14

    My list of project names that gave the same errors:

    A (.NET Standard 2.0 class library)
    A.X (.NET Standard 2.0 class library) Dependencies > Projects > A
    A.X.Android
    A.X.iOS
    A.X.UWP References > A.X (and not yet directly A)

    The only project that referenced A, was A.X.
    I thought I was safe, as intelliSense suggested: for A.X.UWP, all classes and namespaces of A where available through A.X.
    But only after DIRECTLY referencing A from A.X.UWP, I could build project A.X.UWP.

    In short:
    A
    A.X Dependencies > Projects > A
    A.X.UWP References > A.X and A

Sign In or Register to comment.