9

查看 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。

这意味着具有支持框架 win+net45+MonoAndroid16+MonoTouch40+sl40+wp71 的 nuget 包无法安装在 Mac 上的 Profile49 项目上,因为存在较低版本的框架(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?

感谢您的见解。

4

2 回答 2

16

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

更新:我在这篇文章中添加了关于如何让异步在 PCL 中工作的说明:Xamarin Studio Mac、可移植类库、异步和 Android,所以如果你想在你的 PCL 中使用异步,请在这篇文章之后去那里。

我必须让 Mac 上的 Mvvm+PCL+Xamarin Studio 工作的问题的一种可行的解决方案。详情见下文。

下面的步骤使事情适用于 Android 和 PCL 项目。对于 iOS 项目,Mac 上的 Xamarin Studio 将 MonoTouch 的 TargetFramework,Version=v1.0 传递给 Nuget。由于 mvvm 包包含 +MonoTouch40 Nuget 拒绝在项目上安装包。一种解决方法是添加

  <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>

到 .csproj,使用 Nuget 添加包并将 TargetFrameworkVersion 设置回 v1.0。

我已经验证了 Visual Studio 中的行为。有一个 TargetFramework MonoTouch,Version=v4.0 的项目被报告给 Nuget 插件。这就是为什么相同的包适用于 Visual Studio 而不是 Xamarin Studio Mac 的原因。我想这应该被纠正以保持一致。

脚步

Xamarin 工作室

  1. 确保在 Mac 下使用 Xamarin Studio 中的 Beta 或 Alpha 通道
  2. 安装 Nuget 包管理器:Xamarin Studio / Add-In Manager

将 .NETPortable 安装到 Mono.Framework

  1. 将 .NETPortable (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable) 文件夹从 Windows PC 复制到 Mac
  2. 将其放在 /Library/Frameworks/Mono.framework/External/xbuild-frameworks/.NETPortable/ 下(确保不要覆盖已经存在的文件夹,以防 Xamarin Studio 附带此文件夹!!!)(另请参见此处

补丁 Nuget

可以在此处找到修补的分支:https ://nuget.codeplex.com/SourceControl/network/forks/takoyakich/nuget/latest ,采用 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

如果保持打开状态,请重新启动 Xamarin Studio。

测试它!

  1. 打开 Xamarin 工作室
  2. 创建一个新的可移植库
  3. 在项目上,转到选项,构建/常规,您应该会看到一个对话框,让您选择目标框架(例如 .net45+wp8 对应于 Profile49)
  4. 转到参考,管理 Nuget 包,添加 Mvvmcross
  5. 从这里关注@slodge 的优秀 n+1 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))

于 2013-07-16T08:15:31.160 回答
4

自 2014 年 2 月起,不再需要上述步骤。使用 Xamarin Studio 4.3.2、Alpha 通道和nugetaddin,首先通过添加mrward的插件存储库然后安装 nuget 插件,我能够将目标切换到p49并将 HotTuna 包直接添加到新的 PCL 项目中。

于 2014-02-22T20:01:48.290 回答