查看MvvmCross.PortableSupport.3.0.1.nuspec,我注意到有以下一行:
<file src="_._" target="lib\portable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp71\_._" />.
我知道nuget正在从该列表(win+...+sl40+wp71)中创建一个受支持的框架列表,并且添加此库的项目必须支持其中一个框架。基本上,它列举了可以添加到其中的项目类型。
现在,如果我试图将这个包安装到一个具有Profile49的可移植项目中,这将在Profile49上工作,因为Windows上的Profile49是net45+wp80。
然而,在Mac上,Profile49是net45+wp80+MonoAndroid10+MonoTouch10。
这意味着带有支持框架win+net45+MonoAndroid16+MonoTouch40+sl40+wp71的nuget包不能安装在Mac上的Profile49项目上,因为有些框架具有较低的版本(MonoTouch10和MonoAndroid10)。
谢谢你的见解。
发布于 2013-07-16 08:15:31
更新:--如果您使用的是Xamarin的Alpha通道,就不再需要从复制PCL。您可以使用v4.0,Profile158,这也是开箱即用的异步。
更新:--我在本文中添加了关于如何使异步在PCL中工作的说明:Xamarin Studio Mac,便携式类库,异步和Android,因此,如果您想在您的Xamarin Studio Mac,便携式类库,异步和Android中使用异步,请在本文之后进行介绍。
这是一种解决问题的有效解决方案,我不得不让Mvvm+PCL+Xamarin工作室在Mac上工作。详情见下文。
下面的步骤可以让Android和PCL项目发挥作用。对于iOS项目,Mac上的Xamarin正在向Nuget发送一个TargetFramework of MonoTouch,Version=v1.0。由于mvvm包包含+MonoTouch40 40,Nuget拒绝在项目上安装软件包。一个解决办法是添加 v4.0 在.csproj中,添加带有Nuget的包,并将TargetFrameworkVersion设置为v1.0。 我已经在Visual中验证了这种行为。有一个带有TargetFramework MonoTouch的项目,Version=v4.0被报告给Nuget插件。这就是为什么相同的包在Visual上工作,而不是在上工作的原因。我想这应该纠正为一致。
步骤
Xamarin演播室
将.NETPortable安装到Mono.Framework中
补丁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,请重新启动它。
试试看!
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))
发布于 2014-02-22 20:01:48
截至2014年2月,不需要采取上述步骤。使用Xamarin 4.3.2、Alpha通道和nuget
插件,首先通过添加mrward
的addin存储库,然后安装nuget插件,我能够将目标切换到p49
,并将HotTuna包直接添加到一个新的PCL项目中。
https://stackoverflow.com/questions/17653208
复制相似问题