便携式 Class 库中的 M2MQTT
M2MQTT in Portable Class Library
我想在 Windows 10 通用 windows 平台应用程序和 windows phone 8.1 应用程序之间共享我的 M2MQTT 代码。也许将来会是一个 WPF 应用程序。
我尝试使用 NuGet 将 M2MQTT 包含在可移植 class 库 (PCL) 中。我以满足这两种项目类型的最低要求为目标 PCL。我收到以下错误。是否可以在可由 UWP 和 WP8.1 项目共享的便携式 class 库中引用 m2mqtt?
Attempting to gather dependencies information for package 'M2Mqtt.4.2.0.1' with respect to project 'Pcl45', targeting '.NETPortable,Version=v4.6,Profile=Profile32'
Attempting to resolve dependencies for package 'M2Mqtt.4.2.0.1' with DependencyBehavior 'Lowest'
Resolving actions to install package 'M2Mqtt.4.2.0.1'
Resolved actions to install package 'M2Mqtt.4.2.0.1'
Install failed. Rolling back...
Package 'M2Mqtt 4.2.0.1' does not exist in project 'Pcl45'
Could not install package 'M2Mqtt 4.2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.6,Profile=Profile32', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
附加信息 2015 年 9 月 24 日
我克隆了 M2MQTT GitHub repository 并注意到 Windows 8.1 和 Windows phone 8.1 有一个 .pcl。不过,我没有在 .pcl 中看到对 UWP 的支持。
我想我已经有了答案。否 M2MQTT 不支持 .pcl 在 UWP 项目中。
想知道将来是否有添加 .pcl 支持的计划?
此外,如果我可以在 Xamarin Android 或 Ios 项目中使用 M2MQTT?
附加信息 2015 年 9 月 28 日
根据@Anders Gustafsson 的建议,我成功创建了一个 .pcl,我可以在我的 UWP 应用程序和 windows phone 8.1 应用程序中使用它。不再重复代码。好的。希望这会在 xamarin android 和 ios 中起作用。
有这个警告。
Severity Code Description Project File Line Source Warning
Some NuGet packages were installed using a target framework different from
the current target framework and may need to be reinstalled. Visit
http://docs.nuget.org/docs/workflows/reinstalling-packages for more
information. Packages affected: M2Mqtt Pcl45 0 Build
我克隆了 M2MQTT GitHub 存储库并注意到 Windows 8.1 和 Windows phone 8.1 有一个 .pcl。我没有在 .pcl 中看到对 UWP 的支持。
我想我已经有了答案。否。M2MQTT 当前不支持 UWP 项目中的 .pcl。
M2MQTT 可用作 PCL 配置文件 32 程序集,它能够针对 Windows 8.1,Windows Phone 8.1 和 Windows 10/UWP 项目。 M2Mqtt.WinRT 程序集实际上是一个 PCL 配置文件 32 程序集。
您面临的问题是这个事实没有反映在 NuGet 包中。在 NuGet 包中有单独的 lib 文件夹用于 win81 和 wpa81 与 M2Mqtt.WinRT 组件。理想的情况是应该有一个包含 M2Mqtt.WinRT 的子文件夹 portable-win81+wpa81,然后一切都(可能)对你来说完美无瑕。
似乎有一种解决方法,但我不能保证它是完全可靠的。
- 开始创建可移植的 class 库,但将 PCL 的唯一目标设置为 Windows 8.1。 (如果这不能立即起作用,请创建一个 PCL 以 Windows 8.1 和 Windows Phone 8.1 ,当 PCL 创建完成后,取消选中 Windows Phone 8.1 复选框。)
- 将 M2MQTT 包从 NuGet 添加到您的 PCL。您的 PCL 现在将引用 M2Mqtt.WinRT 程序集 win81 子文件夹。
- 添加 Windows Phone 8.1 作为你的 PCL 的目标,这样你的 PCL(再次)目标Windows 8.1 和 Windows Phone 8.1。执行此操作时,您可能会收到来自 NuGet 的警告消息;忽略那些消息。
现在,您应该能够使用 PCL 中的 M2Mqtt.WinRT 程序集,并且您还应该能够引用 PCL 在 UWP 应用程序中。
为了在您成功从 NuGet 下载 M2MQTT 包后增加可靠性,您可以手动删除然后重新添加对 [ 的引用=78=] 程序集在您的 PCL 项目中。这样您将短路 NuGet,防止 NuGet 意外尝试从不存在的 (portable-win81+wpa81) 目录.
我想在 Windows 10 通用 windows 平台应用程序和 windows phone 8.1 应用程序之间共享我的 M2MQTT 代码。也许将来会是一个 WPF 应用程序。
我尝试使用 NuGet 将 M2MQTT 包含在可移植 class 库 (PCL) 中。我以满足这两种项目类型的最低要求为目标 PCL。我收到以下错误。是否可以在可由 UWP 和 WP8.1 项目共享的便携式 class 库中引用 m2mqtt?
Attempting to gather dependencies information for package 'M2Mqtt.4.2.0.1' with respect to project 'Pcl45', targeting '.NETPortable,Version=v4.6,Profile=Profile32'
Attempting to resolve dependencies for package 'M2Mqtt.4.2.0.1' with DependencyBehavior 'Lowest'
Resolving actions to install package 'M2Mqtt.4.2.0.1'
Resolved actions to install package 'M2Mqtt.4.2.0.1'
Install failed. Rolling back...
Package 'M2Mqtt 4.2.0.1' does not exist in project 'Pcl45'
Could not install package 'M2Mqtt 4.2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.6,Profile=Profile32', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
附加信息 2015 年 9 月 24 日
我克隆了 M2MQTT GitHub repository 并注意到 Windows 8.1 和 Windows phone 8.1 有一个 .pcl。不过,我没有在 .pcl 中看到对 UWP 的支持。
我想我已经有了答案。否 M2MQTT 不支持 .pcl 在 UWP 项目中。
想知道将来是否有添加 .pcl 支持的计划?
此外,如果我可以在 Xamarin Android 或 Ios 项目中使用 M2MQTT?
附加信息 2015 年 9 月 28 日 根据@Anders Gustafsson 的建议,我成功创建了一个 .pcl,我可以在我的 UWP 应用程序和 windows phone 8.1 应用程序中使用它。不再重复代码。好的。希望这会在 xamarin android 和 ios 中起作用。
有这个警告。
Severity Code Description Project File Line Source Warning
Some NuGet packages were installed using a target framework different from
the current target framework and may need to be reinstalled. Visit
http://docs.nuget.org/docs/workflows/reinstalling-packages for more
information. Packages affected: M2Mqtt Pcl45 0 Build
我克隆了 M2MQTT GitHub 存储库并注意到 Windows 8.1 和 Windows phone 8.1 有一个 .pcl。我没有在 .pcl 中看到对 UWP 的支持。
我想我已经有了答案。否。M2MQTT 当前不支持 UWP 项目中的 .pcl。
M2MQTT 可用作 PCL 配置文件 32 程序集,它能够针对 Windows 8.1,Windows Phone 8.1 和 Windows 10/UWP 项目。 M2Mqtt.WinRT 程序集实际上是一个 PCL 配置文件 32 程序集。
您面临的问题是这个事实没有反映在 NuGet 包中。在 NuGet 包中有单独的 lib 文件夹用于 win81 和 wpa81 与 M2Mqtt.WinRT 组件。理想的情况是应该有一个包含 M2Mqtt.WinRT 的子文件夹 portable-win81+wpa81,然后一切都(可能)对你来说完美无瑕。
似乎有一种解决方法,但我不能保证它是完全可靠的。
- 开始创建可移植的 class 库,但将 PCL 的唯一目标设置为 Windows 8.1。 (如果这不能立即起作用,请创建一个 PCL 以 Windows 8.1 和 Windows Phone 8.1 ,当 PCL 创建完成后,取消选中 Windows Phone 8.1 复选框。)
- 将 M2MQTT 包从 NuGet 添加到您的 PCL。您的 PCL 现在将引用 M2Mqtt.WinRT 程序集 win81 子文件夹。
- 添加 Windows Phone 8.1 作为你的 PCL 的目标,这样你的 PCL(再次)目标Windows 8.1 和 Windows Phone 8.1。执行此操作时,您可能会收到来自 NuGet 的警告消息;忽略那些消息。
现在,您应该能够使用 PCL 中的 M2Mqtt.WinRT 程序集,并且您还应该能够引用 PCL 在 UWP 应用程序中。
为了在您成功从 NuGet 下载 M2MQTT 包后增加可靠性,您可以手动删除然后重新添加对 [ 的引用=78=] 程序集在您的 PCL 项目中。这样您将短路 NuGet,防止 NuGet 意外尝试从不存在的 (portable-win81+wpa81) 目录.