Xamarin Forms Project with netstandard: can't build UWP
Asked Answered
R

2

6

currently I'm working on a Xamarin app, which uses the .Net-Standard code sharing strategy. While I ca build and run the succesfully on android, i have some problems with the UWP project.

When I try to build the project I'm receiving this error messages:

Could not copy the file "obj\x86\Debug\myapp.UWP.xr.xml" because it was not found.

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.

Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: myapp.Basic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.'

While I was looking for these error messages I found this thread on stackoverflow:

Missing xaml.xr of a class library file in UWP

The thread suggestes to enable the "Generate library layout" in projects that contains XAML-code, which looked very promising, because the myapp.Basic Project contains some XAML-code. Unluckily this option is totaly missing in .Net-standard projects.

Can anybody help me solve this problem?

Rachele answered 28/5, 2018 at 10:28 Comment(6)
Have you tried clean your solution and redeploy it before building?Interplead
Yes of course, this was was first thing I have tried :)Rachele
And this option only applies to ClassLibrary.Interplead
You could try delete bin obj folder in UWP project manually.Interplead
make sure the MinTarget Build for UWP is set to at least Build 16299Dilution
Finally we solved the problem by deleting and adding again all referencesRachele
A
5

In your UWP Project manually add reference to any additional .Net Standard Class library project

in your case to myapp.Basic

Ambagious answered 10/4, 2019 at 18:0 Comment(1)
That did the trick for me when adding a UWP project to an existing Xamarin.Forms project. Thank you!Infirmity
P
4

Bu sure that you add all .Net Standard Class libraries references in your solution to UWP project. For Android and IOS projects adding the main shared code project's reference is enough; but for UWP if you have an extra class library project that your shared code project use you have to add this project too as a reference to UWP project.

Parity answered 7/10, 2019 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.