MvvMCross 3.0.6 Nuget package installation issue

2019-01-18 05:34发布

问题:

I am trying to install MVVMCross NuGet package using NuGet 2.5 version. I have added the mono android and touch file to Profile104 folder. Still I am getting following exception:

Attempting to resolve dependency 'MvvmCross.HotTuna.StarterPack (≥ 3.0.6)'.
Attempting to resolve dependency 'MvvmCross.HotTuna.CrossCore (≥ 3.0.6)'.
Attempting to resolve dependency 'MvvmCross.PortableSupport (≥ 3.0.6)'.
Installing 'MvvmCross.PortableSupport 3.0.6'.
Successfully installed 'MvvmCross.PortableSupport 3.0.6'.
Installing 'MvvmCross.HotTuna.CrossCore 3.0.6'.
Successfully installed 'MvvmCross.HotTuna.CrossCore 3.0.6'.
Installing 'MvvmCross.HotTuna.StarterPack 3.0.6'.
Successfully installed 'MvvmCross.HotTuna.StarterPack 3.0.6'.
Installing 'MvvmCross 3.0.6'.
Successfully installed 'MvvmCross 3.0.6'.
Adding 'MvvmCross.PortableSupport 3.0.6' to PortableClassLibrary1.
Uninstalling 'MvvmCross.PortableSupport 3.0.6'.
Successfully uninstalled 'MvvmCross.PortableSupport 3.0.6'.
Install failed. Rolling back...
Could not install package 'MvvmCross.PortableSupport 3.0.6'. 

You are trying to install this package into a project that targets 'portable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I have selected following option when creating a new PCL Library project

Following are the content for the xml files from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks folder

.NET for Windows Store apps.xml

<?xml version="1.0" encoding="utf-8"?>
<Framework
    Identifier=".NETCore"
    Profile="*"
    MinimumVersion="4.5"
    DisplayName=".NET for Windows Store apps"
    MinimumVersionDisplayName="" />

.NET Framework 4.5

<?xml version="1.0" encoding="utf-8"?>
<Framework
    Identifier=".NETFramework"
    Profile="*"
    MinimumVersion="4.5"
    DisplayName=".NET Framework"
    MinimumVersionDisplayName="4.5" />

MonoAndroid.xml

<?xml version="1.0" encoding="utf-8"?>
<Framework DisplayName="Mono for Android"
  Identifier="MonoAndroid"
  Profile="*"
  MinimumVersion="1.6"
  MaximumVersion="*" />

MonoTouch.xml

<?xml version="1.0" encoding="utf-8"?>
<Framework
    DisplayName="MonoTouch"
    Identifier="MonoTouch"
    Profile="*"
    MaximumVersion="*" 
    MinimumVersion="4.0" />

Silverlight 4.xml

<?xml version="1.0" encoding="utf-8"?>
<Framework
    Identifier="Silverlight"
    Profile=""
    MinimumVersion="4.0"
    DisplayName="Silverlight"
    MinimumVersionDisplayName="4" />

VSMonoTouch.xml

<?xml version="1.0" encoding="utf-8"?>
<Framework DisplayName="VS MonoTouch"
  Identifier=".NETFramework"
  Profile="*"
  MinimumVersion="1.0"
  MaximumVersion="1.0" />

Windows Phone 7.5.xml

<?xml version="1.0" encoding="utf-8"?>
<Framework
    Identifier="Silverlight"
    Profile="WindowsPhone7*"
    MinimumVersion="4.0"
    DisplayName="Windows Phone"
    MinimumVersionDisplayName="7.5" />

I am using Visual Studio 2012 Ultimate Update 2 on Windows Server 2012 64 bit edition. Can someone point me in right direction.

回答1:

It looks like you are targeting Windows Phone 7.0 in your Portable Class Library. Try switching to Windows Phone 7.5 and see if that helps. If not, try posting a screenshot of the PCL "choose targets" screen, as well as the contents of all the XML files you've added to the "SupportedFrameworks" folder.


EDIT: Try deleting VSMonoTouch.xml (and restarting Visual Studio afterwards).



回答2:

The workaround mentioned on a comment on Stuart's blog (at http://slodge.blogspot.co.uk/2013/04/n0-first-mvvmcross-application-n1-days.html) worked for me:

Remove Mono for Android, MonoTouch, VS MonoTouch and Windows Phone from the Target Frameworks in the Core project properties. Install MvvmCross NuGet package. Add the Target Frameworks back in.



回答3:

I just got an update to the NuGet. It looks like it's working now.

Here are the steps to have MVVM Cross on a new project:

  1. Create a new project Xamarin Android

  2. Create a new project PCL library (select Mono Android, MonoTouch, and Windows Phone 7.5 and higher).

  3. Add MVVMCross NuGet on both the app and PCL

  4. Add the library as reference to the app

Without adding the MVVMCross also to the app, I get an error on compilation.



回答4:

I have the same issue

Could not install package 'MvvmCross.PortableSupport 3.0.6'. You are trying to install this package into a project that targets 'portable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp71', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Per http://slodge.blogspot.co.uk/2013/04/my-current-pcl-setup-in-visual-studio.html, I do not have VSMonoTouch, just the two files (MonoAndroid,Version=v1.6+.xml and MonoTouch,Version=v1.0+.xml)

I also tried to

"Remove Mono for Android, MonoTouch, VS MonoTouch and Windows Phone from the Target Frameworks in the Core project properties. Install MvvmCross NuGet package. Add the Target Frameworks back in."

But when I try to compile, I get this error:

Error 1 Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the Mono for Android profile? File name: 'System.Windows.dll' at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List1 assemblies, AssemblyDefinition assembly) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List1 assemblies, AssemblyDefinition assembly) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly) at Xamarin.Android.Tasks.ResolveAssemblies.Execute() MyProject



回答5:

I face this issue too. After googling to find solution I found that I use Nuget version 2.4 I upgrade my nuget to 2.6 and it run smoothly. You can download nuget 2.6 here: Nuget 2.6



回答6:

I wrote a step by step post for creating a simple Android app from scratch using PCL

http://enginecore.blogspot.ro/2013/05/first-app-with-xamarin-android-and.html