2016-07-26 41 views
1

所以我一直在尝试做一个项目,将使用netstandard类库通用代码,但是我一直不成功,因为我一直在遇到错误。我一直在关注如何在这里发布https://oren.codes/2016/07/09/using-xamarin-forms-with-net-standard/https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/。他的示例我可以下载并运行良好,但是当我尝试使用他的指令复制它时,我遇到了错误错误,当试图与Xamarin形式使用netstandard

您的项目未引用“.NETPortable,Version = v4.5,Profile = Profile111”框架。在project.json的“frameworks”部分中添加对“.NETPortable,Version = v4.5,Profile = Profile111”的引用,然后重新运行NuGet恢复。 FixMyCity.Mobile C:\ Program Files(x86)\ MSBuild \ Microsoft \ NuGet \ Microsoft.NuGet.targets 140

我知道这听起来很明显;只需添加.NETPortable,Version=v4.5,Profile=Profile111在project.json的框架部分,但后来我得到这个错误(80%肯定它是由在加入它,因为它不存在以其他方式)

包含的MSBuild目标的软件包和道具文件无法完全安装在针对多个框架的项目中。 MSBuild目标和道具文件已被忽略。 ... project.nuget.targets

而且当我在看样品的项目,他不针对.NETPortable,Version=v4.5,Profile=Profile111,它工作正常

这是我与它到目前为止,如果你得到的最接近想看看:https://github.com/Toxicable/XamarinFormsNetstandardIssue
这只是模板项目(Xamrin形式protalble)与步骤下方施加

  1. 运行`PM>卸载,包装xamarin.forms -Force -RemoveDependencies在每个项目上; IOS和Andriod首先是PCL。
  2. 重启VS通过控制台提示
  3. 添加在project.json每个项目如下
  4. 尝试构建,但也它不会

PCL project.json

{ 
    "supports": {}, 
    "dependencies": { 
    "Xamarin.Forms": "2.3.0.107", 
    "NETStandard.Library": "1.6.0" 
    }, 
    "frameworks": { 
    "netstandard1.1": { 
     "imports": "portable-net45+win8+wpa81+wp8" 
    }, 
    ".NETPortable,Version=v4.5,Profile=Profile111": {} 
    } 
} 

项目.Driod project.json

{ 
    "dependencies": { 
    }, 
    "frameworks": { 
    "MonoAndroid,Version=v6.0": { 
    } 
    }, 
    "runtimes": { 
    "win": {} 
    } 
} 

project.iOS project.json

{ 
    "dependencies": { 
    }, 
    "frameworks": { 
    "Xamarin.iOS,Version=v1.0": { 
    } 
    }, 
    "runtimes": { 
    "win": {} 
    } 
} 
+0

你见过票据参考1? https://releases.xamarin.com/beta-release-cycle-7-service-release-1-updated/ 这些构建引入了与新的.NET标准1.6的兼容性。这尤其允许开发人员使用已针对.NET Standard 1.6构建的NuGet包。 –

+0

@JonDouglas我已经看到,我不确定与我的问题有什么关系,即时通讯瞄准低网络标准,因为它是最兼容的,但会改变到我能够瞄准iOS和Andriod的最高水平,我认为这是1.6一旦项目真正建立起来 – Toxicable

回答

1

我下载了你的项目,并注意到,Xamarin窗体移植库一直在寻找一个有点古怪,你通常会看到Xamarin形式和.NET标准库在你的蓝色图标引用中。

我不知道它是如何发生的,但是这里是你如何解决它。

  1. 从您的project.json中删除".NETPortable,Version=v4.5,Profile=Profile111": {}

  2. 卸载项目

  3. 编辑项目文件

enter image description here

  • 删除此行<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>

  • 变化V4 .5至v5.0 <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>

  • 保存文件并重新加载项目,现在建立无需Profile111,也将显示在周期7服务发布

  • enter image description here

    +0

    这正是问题所在,非常感谢您抽出时间指出这一点,也不确定它是如何发生的,但我希望任何有此问题的人都可以在此找到答案 – Toxicable