Xamarin.ios 让PCL、Mvvmcross、Nuget和Xamarin工作室播放;“尼斯”;在Mac上

Xamarin.ios 让PCL、Mvvmcross、Nuget和Xamarin工作室播放;“尼斯”;在Mac上,xamarin.ios,xamarin.android,mvvmcross,xamarin-studio,Xamarin.ios,Xamarin.android,Mvvmcross,Xamarin Studio,查看MvvmCross.PortableSupport.3.0.1.nuspec 我注意到有以下几行: <file src="_._" target="lib\portable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp71\_._" />. 。 我知道nuget正在从该列表(win+…+sl40+wp71)创建一个受支持框架的列表,并且添加该库的项目必须支持其中一个框架。基本上,它列举了可以添加到其中的项目类型 现在,如果我尝试将这个

查看MvvmCross.PortableSupport.3.0.1.nuspec 我注意到有以下几行:

<file src="_._" target="lib\portable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp71\_._" />.
我知道nuget正在从该列表(win+…+sl40+wp71)创建一个受支持框架的列表,并且添加该库的项目必须支持其中一个框架。基本上,它列举了可以添加到其中的项目类型

现在,如果我尝试将这个包安装到一个带有Profile49的可移植项目中,这将在Windows上起作用,因为Windows上的Profile49是net45+wp80

但是在Mac上,Profile49是net45+wp80+MonoAndroid10+MonoTouch10

这意味着不能在Mac上Profile49的项目上安装带有受支持框架win+net45+MonoAndroid16+MonoTouch40+sl40+wp71的nuget软件包,因为有些框架的版本较低(MonoTouch10和MonoAndroid10)

  • mvvmcross端是否可以使用字符串portable win+net45+MonoAndroid+MonoTouch+sl40+wp71?具体版本有什么原因吗


  • 为什么Xamarin附带的配置文件(例如/Library/Frameworks/Mono.framework/External/xbuild Frameworks/.NETPortable/v4.5/Profile/Profile49)包括MonoTouch10和MonoAndroid10


感谢您的见解。

更新:如果您正在使用Xamarin Studio的Alpha频道,则不再需要从Windows复制PCL。您可以使用v4.0、Profile158,这也适用于异步

更新:我在本文中添加了有关如何使异步在PCL中工作的说明:,因此,如果您想在PCL中使用异步,请在本文之后转到这里

一种解决问题的有效方法,我必须让Mac上的Mvvm+PCL+Xamarin Studio正常工作。详情见下文

下面的步骤使Android和PCL项目能够正常工作。对于iOS项目,Mac上的Xamarin Studio正在向Nuget传输MonoTouch的TargetFramework,版本=v1.0。由于mvvm软件包包含+MonoTouch40,Nuget拒绝在项目上安装这些软件包。解决方法是添加

  <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
v4.0
在.csproj中,添加带有Nuget的包,并将TargetFrameworkVersion设置回v1.0

我已经在Visual Studio中验证了该行为。有一个带有TargetFramework MonoTouch的项目,版本=v4.0,报告给Nuget插件。这就是为什么相同的包可以在VisualStudio上工作,而不能在Xamarin Studio Mac上工作。我想这应该是一致的

台阶 沙马林工作室
  • 确保在Mac下使用Xamarin Studio中的Beta或Alpha频道
  • 安装Nuget软件包管理器:Xamarin Studio/加载项管理器
  • 将.NETPortable安装到Mono.Framework中
  • 将.NETPortable(C:\Program Files(x86)\Reference Assembly\Microsoft\Framework.NETPortable)文件夹从Windows PC复制到Mac

  • 将其置于/Library/Frameworks/Mono.framework/External/xbuild Frameworks/.NETPortable/(确保不要覆盖现有文件夹,以防Xamarin Studio附带此文件夹!!!)()
  • 补丁Nuget 在这里可以找到一个打补丁的叉子:,以2.7分支为例。如果您想修补自己:

    git clone https://git01.codeplex.com/nuget
    cd nuget
    git checkout -b 2.7 origin/2.7 
    
    patch -p1 < {patch file saved from below}
    
    cd src/Core
    xbuild
    
    cp bin/Debug/NuGet.Core.dll  ~/Library/Application\ Support/XamarinStudio-4.0/LocalInstall/Addins/MonoDevelop.PackageManagement.0.6/NuGet.Core.dll
    
    git克隆https://git01.codeplex.com/nuget
    光碟
    git签出-b 2.7源代码/2.7
    修补程序-p1<{从下面保存的修补程序文件}
    cd src/Core
    xbuild
    cp bin/Debug/NuGet.Core.dll~/Library/Application\Support/XamarinStudio-4.0/LocalInstall/Addins/MonoDevelop.PackageManagement.0.6/NuGet.Core.dll
    
    如果Xamarin Studio保持打开状态,请重新启动它

    试试看!
  • 开放Xamarin工作室
  • 创建一个新的可移植库
  • 在项目中,转到选项、构建/常规您应该会看到一个对话框,允许您选择目标框架(例如,net45+wp8对应于Profile49)
  • 转到引用,管理Nuget包,添加Mvvmcross
  • 下面是一个教程视频

  • Nuget.Core.dll的修补程序:

    
    
        diff --git a/src/Core/NETPortable/NetPortableProfileTable.cs b/src/Core/NETPortable/NetPortableProfileTable.cs
        index 6f6a9ff..edc710c 100644
        --- a/src/Core/NETPortable/NetPortableProfileTable.cs
        +++ b/src/Core/NETPortable/NetPortableProfileTable.cs
        @@ -49,16 +49,12 @@ namespace NuGet
                 private static NetPortableProfileCollection BuildPortableProfileCollection()
                 {
                     var profileCollection = new NetPortableProfileCollection();
        -            string portableRootDirectory =
        -                    Path.Combine(
        -                        Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),
        -                        @"Reference Assemblies\Microsoft\Framework\.NETPortable");
        -
        +            string portableRootDirectory = GetPortableRootDirectory ();
                     if (Directory.Exists(portableRootDirectory))
                     {
                         foreach (string versionDir in Directory.EnumerateDirectories(portableRootDirectory, "v*", SearchOption.TopDirectoryOnly))
                         {
        -                    string profileFilesPath = versionDir + @"\Profile\";
        +                    string profileFilesPath = Path.Combine(versionDir,"Profile");
                             profileCollection.AddRange(LoadProfilesFromFramework(profileFilesPath));
                         }
                     }
        @@ -66,6 +62,22 @@ namespace NuGet
                     return profileCollection;
                 }
    
        +        private static string GetPortableRootDirectory()                                                                                                                                                                                                                                                                                               
        +        {                                                                                                                                                                                                                                                                                                                                              
        +            if (IsMonoOnMac ()) {                                                                                                                                                                                                                                                                                                                      
        +                return "/Library/Frameworks/Mono.framework/External/xbuild-frameworks/.NETPortable";                                                                                                                                                                                                                                                   
        +            }                                                                                                                                                                                                                                                                                                                                          
        +            return Path.Combine(                                                                                                                                                                                                                                                                                                                       
        +                Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),                                                                                                                                                                                                                     
        +                @"Reference Assemblies\Microsoft\Framework\.NETPortable");                                                                                                                                                                                                                                                                             
        +        }                                                                                                                                                                                                                                                                                                                                              
        +                                                                                                                                                                                                                                                                                                                                                       
        +        static bool IsMonoOnMac ()                                                                                                                                                                                                                                                                                                                     
        +        {                                                                                                                                                                                                                                                                                                                                              
        +            // Environment.OSVersion.Platform returns UNIX, didn't find a better way :-(                                                                                                                                                                                                                                                               
        +            return File.Exists ("/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder");                                                                                                                                                                                                                                                      
        +        }       
        +
                 private static IEnumerable<NetPortableProfile> LoadProfilesFromFramework(string profileFilesPath)
                 {
                     if (Directory.Exists(profileFilesPath))
    
    
    
    diff——git a/src/Core/NETPortable/NetPortableProfileTable.cs b/src/Core/NETPortable/NetPortableProfileTable.cs
    索引6f6a9ff..edc710c 100644
    ---a/src/Core/NETPortable/NetPortableProfileTable.cs
    +++b/src/Core/NETPortable/NetPortableProfileTable.cs
    @@-49,16+49,12@@namespace numget
    私有静态NetPortableProfileCollection BuildPortableProfileCollection()
    {
    var profileCollection=new NetPortableProfileCollection();
    -字符串可移植根目录=
    -路径。联合收割机(
    -Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86,Environment.SpecialFolderOption.DoNotVerify),
    -@“引用程序集\Microsoft\Framework\.NETPortable”);
    -
    +字符串portableRootDirectory=GetPortableRootDirectory();
    if(Directory.Exists(portableRootDirectory))
    {
    foreach(Directory.EnumerateDirectory中的字符串versionDir(portableRootDirectory,“v*”,SearchOption.TopDirectoryOnly))
    {
    -字符串profilefilepath=versionDir+@“\Profile\”;
    +字符串profilefilepath=Path.Combine(versionDir,“Profile”);
    AddRange(LoadProfilesFromFramework(ProfileFilePath));
    }
    }
    @@-66,6+62,22@@namespace numget
    回收;
    }
    +私有静态字符串GetPortableRootDirectory()
    +        {