【发布时间】:2016-07-27 08:14:53
【问题描述】:
所以我一直在尝试制作一个将使用 netstandard 类库公共代码的项目,但是由于我不断遇到错误,我一直没有成功。我一直在关注https://oren.codes/2016/07/09/using-xamarin-forms-with-net-standard/ 和https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/ 的帖子,了解如何操作。他的示例我可以下载并正常运行,但是当我尝试按照他的说明复制它时,我遇到了错误
您的项目未引用“.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
我知道这听起来很明显;只需在 project.json 的 frameworks 部分添加.NETPortable,Version=v4.5,Profile=Profile111,然后我就会收到此错误(80% 肯定这是由于添加它引起的,因为否则它不存在)
包含 MSBuild 目标和 props 文件的包不能完全安装在面向多个框架的项目中。 MSBuild 目标和道具文件已被忽略。 ...project.nuget.targets
另外,当我查看示例项目时,他没有针对 .NETPortable,Version=v4.5,Profile=Profile111,它工作正常
如果您想看一下,这是迄今为止我最接近的:https://github.com/Toxicable/XamarinFormsNetstandardIssue
它只是应用了以下步骤的模板项目(Xamrin 表单 protalble)
- 运行 `PM> 在每个项目上卸载-Package xamarin.forms -Force -RemoveDependencies; IOS 和 Andriod 先 PCL 最后。
- 根据控制台提示重启VS
- 在每个项目中添加
project.json,如下所示 - 尝试构建,但它不会
PCL 项目.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": {}
}
}
project.Driod project.json
{
"dependencies": {
},
"frameworks": {
"MonoAndroid,Version=v6.0": {
}
},
"runtimes": {
"win": {}
}
}
project.iOS project.json
{
"dependencies": {
},
"frameworks": {
"Xamarin.iOS,Version=v1.0": {
}
},
"runtimes": {
"win": {}
}
}
【问题讨论】:
-
您看过关于 Cycle 7 Service Release 1 的说明吗? releases.xamarin.com/… 这些构建引入了与新的 .NET Standard 1.6 的兼容性。这尤其允许开发人员使用针对 .NET Standard 1.6 构建的 NuGet 包。
-
@JonDouglas我已经看到了,我不确定这与我的问题有什么关系,我的目标是低网络标准,因为它是最兼容的,但会变成我可以针对 iOS 的最高标准Andriod 是 1.6,我认为一旦项目实际构建完成
标签: c# xamarin xamarin.forms