所以我一直在尝试做一个项目,将使用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)与步骤下方施加
- 运行`PM>卸载,包装xamarin.forms -Force -RemoveDependencies在每个项目上; IOS和Andriod首先是PCL。
- 重启VS通过控制台提示
- 添加在
project.json
每个项目如下 - 尝试构建,但也它不会
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": {}
}
}
你见过票据参考1? https://releases.xamarin.com/beta-release-cycle-7-service-release-1-updated/ 这些构建引入了与新的.NET标准1.6的兼容性。这尤其允许开发人员使用已针对.NET Standard 1.6构建的NuGet包。 –
@JonDouglas我已经看到,我不确定与我的问题有什么关系,即时通讯瞄准低网络标准,因为它是最兼容的,但会改变到我能够瞄准iOS和Andriod的最高水平,我认为这是1.6一旦项目真正建立起来 – Toxicable