可以在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,这也适用于 Async.更新:我在本文中添加了有关如何使异步在 PCL 中工作的说明:Xamarin Studio Mac、便携式类库、异步和 Android,所以如果你想在你的 PCL 中使用异步,请参考这篇文章.我必须让 Mac 上的 Mvvm+PCL+Xamarin Studio 才能工作的问题的一种有效解决方案.详情见下文.以下步骤使 Android 和 PCL 项目能够正常工作.对于 iOS 项目,Mac 上的 Xamarin Studio 正在将 MonoTouch,Version=v1.0 的 TargetFramework 传达给 Nuget.由于 mvvm 包包含 +MonoTouch40 Nuget 拒绝在项目上安装包.解决方法是添加 v4.0到 .csproj,使用 Nuget 添加包并将 TargetFrameworkVersion 设置回 v1.0.我已经验证了 Visual Studio 中的行为.有一个带有 TargetFramework MonoTouch,Version=v4.0 的项目被报告给 Nuget 插件.这就是为什么相同的包适用于 Visual Studio 而不适用于 Xamarin Studio Mac.我想这应该更正以保持一致.步骤Xamarin Studio确保在 Mac 下的 Xamarin Studio 中使用 Beta 或 Alpha 通道安装 Nuget 包管理器:Xamarin Studio/加载项管理器将 .NETPortable 安装到 Mono.Framework将 .NETPortable (C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortable) 文件夹从 Windows PC 复制到 Mac将它放在/Library/Frameworks/Mono.framework/External/xbuild-frameworks/.NETPortable/下(确保不要覆盖已经存在的文件夹,以防 Xamarin Studio 附带它!!!)(参见此处)补丁 Nuget可以在此处找到修补的 fork:https://nuget.codeplex.com/SourceControl/network/forks/takoyakich/nuget/latest,选择 2.7 分支.如果你想自己打补丁:git clone https://git01.codeplex.com/nugetCD nugetgit checkout -b 2.7 origin/2.7补丁 -p1 如果 Xamarin Studio 保持打开状态,请重新启动它.测试一下!打开 Xamarin Studio创建一个新的便携式库在项目上,转到选项,构建/常规,您应该会看到一个对话框,让您选择目标框架(例如,.net45+wp8 对应于 Profile49)转到引用、管理 Nuget 包、添加 Mvvmcross关注 @slodge 出色的 n+1 mvvmcross 教程视频之一,来自这里...修补 Nuget.Core.dll: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 @@ 命名空间 NuGet私有静态 NetPortableProfileCollection BuildPortableProfileCollection(){var profileCollection = new NetPortableProfileCollection();- 字符串可移植RootDirectory =- Path.Combine(- Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),- @"参考程序集MicrosoftFramework.NETPortable");——+ 字符串可移植根目录 = GetPortableRootDirectory();if (Directory.Exists(portableRootDirectory)){foreach (Directory.EnumerateDirectories(portableRootDirectory, "v*", SearchOption.TopDirectoryOnly) 中的字符串 versionDir){- 字符串 profileFilesPath = versionDir + @"Profile";+ string profileFilesPath = Path.Combine(versionDir,"Profile");profileCollection.AddRange(LoadProfilesFromFramework(profileFilesPath));}}@@ -66,6 +62,22 @@ 命名空间 NuGet返回个人资料集合;}+ 私有静态字符串 GetPortableRootDirectory()+ {+ 如果 (IsMonoOnMac ()) {+ return "/Library/Frameworks/Mono.framework/External/xbuild-frameworks/.NETPortable";+ }+ 返回 Path.Combine(+ Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),+ @"参考程序集MicrosoftFramework.NETPortable");+ }++ static bool IsMonoOnMac ()+ {+//Environment.OSVersion.Platform 返回 UNIX,没有找到更好的方法 :-(+ 返回 File.Exists ("/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder");+ }+私有静态 IEnumerableLoadProfilesFromFramework(string profileFilesPath){if (Directory.Exists(profileFilesPath))Looking at the MvvmCross.PortableSupport.3.0.1.nuspecI noticed the there is the following line:<file src="_._" target="libportable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp71\_._" />.I understand that nuget is creating a list of supported frameworks from that list (win+...+sl40+wp71) and that the project to which this library is added must support one of those frameworks. Basically it enumerates the project types to which this can be added.Now if I try to install this package into a portable project having Profile49 this will work on Windows since Profile49 on Windows is net45+wp80.However on the Mac the Profile49 is net45+wp80+MonoAndroid10+MonoTouch10.This means that a nuget package with the supported frameworks win+net45+MonoAndroid16+MonoTouch40+sl40+wp71 cannot be installed on a project of Profile49 on Mac since there are frameworks having a lower version (MonoTouch10 and MonoAndroid10).Could the string portable-win+net45+MonoAndroid+MonoTouch+sl40+wp71 be used on the mvvmcross side instead? Any reason for the specific versions?Why do the profiles shipped with Xamarin (e.g. /Library/Frameworks/Mono.framework/External/xbuild-frameworks/.NETPortable/v4.5/Profile/Profile49) include MonoTouch10 and MonoAndroid10?Thank you for your insights. 解决方案 Update: If you are using the Alpha channel of Xamarin Studio there is no longer a need to copy PCLs from Windows. You can use v4.0, Profile158, this also works out of the box with Async.Update: I added instructions on how to get async to work in PCL in this article: Xamarin Studio Mac, Portable class library, Async and Android, so go there after this article if you want to work with async in your PCL.A sort of working solution to the problem I had to get Mvvm+PCL+Xamarin Studio on Mac to work. See below for the details. The steps below make things work for Android and PCL projects. For iOS projects Xamarin Studio on Mac is communicating a TargetFramework of MonoTouch,Version=v1.0 to Nuget. Since the mvvm packages contain +MonoTouch40 Nuget refuses to install the packages on the project. A workaround is to add <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>to the .csproj, add the packages with Nuget and set TargetFrameworkVersion back to v1.0. I have verified the behaviour in Visual Studio. There a project with TargetFramework MonoTouch,Version=v4.0 is reported to the Nuget plugin. This is why the same packages work on Visual Studio an not on Xamarin Studio Mac. I guess this should be corrected to be consistent.StepsXamarin StudioMake sure to use the Beta or Alpha channel in Xamarin Studio under MacInstall the Nuget package manager: Xamarin Studio / Add-In ManagerInstall .NETPortable into Mono.FrameworkCopy the .NETPortable (C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortable) folder from a Windows PC to your MacPlace it under /Library/Frameworks/Mono.framework/External/xbuild-frameworks/.NETPortable/ (Make sure not to overwrite an already existing folder, in case this gets shipped with Xamarin Studio!!!) (see here also)Patch NugetA patched fork can be found here: https://nuget.codeplex.com/SourceControl/network/forks/takoyakich/nuget/latest, take the 2.7 branch. If you want to patch yourself:git clone https://git01.codeplex.com/nugetcd nugetgit checkout -b 2.7 origin/2.7patch -p1 < {patch file saved from below}cd src/Corexbuildcp bin/Debug/NuGet.Core.dll ~/Library/Application Support/XamarinStudio-4.0/LocalInstall/Addins/MonoDevelop.PackageManagement.0.6/NuGet.Core.dllRestart Xamarin Studio if you kept it open.Test it!Open Xamarin StudioCreate a new portable libraryOn the project, go to options, Build/General you should see a dialog letting you choose the Target Frameworks (e.g. .net45+wp8 corresponds to Profile49)Goto references, Manage Nuget packages, Add MvvmcrossFollow one of @slodge 's excellent n+1 mvvmcross tutorial videos from here ...Patch to 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 AssembliesMicrosoftFramework.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 AssembliesMicrosoftFramework.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)) 这篇关于让 PCL、Mvvmcross、Nuget 和 Xamarin Studio 播放“nice"在 Mac 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-15 00:07