Windowscommunitytoolkit: WinRT C++ UWP Can't add nuget package Microsoft.Toolkit.Uwp.Notifications

Created on 11 Aug 2020  路  18Comments  路  Source: windows-toolkit/WindowsCommunityToolkit

Describe the bug

When adding the nuget library Microsoft.Toolkit.Uwp.Notifications, the following error is displayed and the install fails:

Severity    Code    Description Project File    Line    Suppression State
Error       Could not install package 'System.ValueTuple 4.5.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', 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.             
  • [ ] Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:

Steps to Reproduce

Steps to reproduce the behavior:

  1. In Visual Studio 2019 v 16.6 create a Blank App (C++/WinRT) project
  2. Attempt to add the Microsoft.Toolkit.Uwp.Notifications NuGet package. Add the latest 6.1.0 package.
    Note Error message,

Expected behavior

The package should be added to the project without error.

Environment

NuGet Package(s): 
Microsoft.Toolkit.Uwp.Notifications

Package Version(s): 
6.1.0
Note: 5.1.1 will install - but is missing key functionality for notifications.

Windows 10 Build Number:
- [ ] May 2019 Update (18362)

App min and target version:
- [ ] Fall Creators Update (16299)
- [ X] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [X ] May 2019 Update (18362)
- [ ] May 2020 Update (19041)
- [ ] Insider Build (xxxxx)

Device form factor:
- [ X] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [ X] 2019 (version:  16.6) 
- [ ] 2019 Preview (version: )

Additional context

Add any other context about the problem here.

Completed bug notifications

Most helpful comment

All 18 comments

Hello mjfusa, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 馃檶

@mjfusa can you try updating App min and target version to "May 2020 Update (19041)"? It is installing fine on my end.

@Kyaa-dost Thanks - I tried that and no luck. Are you adding the package to a Blank App (WinRT/C++) project? This is where the problem is - it works fine with a C# app. You will need to add C++/WinRT support to VS if you haven't already by installing this: https://marketplace.visualstudio.com/items?itemName=CppWinRTTeam.cppwinrt101804264

@mjfusa Thanks for the detailed info. I am able to reproduce this now.

Let's see what devs have to say about this bug.

@andrewleader have you noticed any problems here in this space? Any thoughts on what might be going on here?

FYI @azchohfi as well.

Hmm, the System.Tuple dependency isn't compatible with C++ WinRT? I'm not sure when that was added but I'm betting older versions of the library didn't have this dependency. @mjfusa can you try installing some older versions of the Notifications library and see if that works?

Version 5.1.1, for example, will probably work.

@andrewleader - Yes 5.1.1 installs without a problem. However it is missing critical functionality needed for notifications.

Hey @mjfusa, I think I've fixed the issue. Are you familiar with how to install local copies of NuGet packages? If not let me know and I can help.

Here's an updated local copy (extract it first and then place the NuGet package somewhere on your computer, and then in VS, change NuGet Package Explorer to look in that folder): Microsoft.Toolkit.Uwp.Notifications.7.0.0-build.175.gec43fb1a8e.zip

I verified this new version works with a C++/CX app (and the previous 6.x.x versions didn't)... but for a C++/WinRT app I couldn't even get version 5.1.1 working (it installed, but even just referencing the Microsoft::Toolkit::Uwp::Notifications namespace wasn't working... I'm not an expert on C++/WinRT, I'm more used to C++/CX, so open to any suggestions/help if you have ideas!). Or maybe you'll be able to figure out how it works :)

Thanks @andrewleader - That worked! However, can you base the fix on 6.1.0? This added the ToastContentBuilder class which I need. It looks like the 7.0.0 preview is based on 6.0? ToastContentBuilder Class (Microsoft.Toolkit.Uwp.Notifications) | Microsoft Docs

@andrewleader For C++/WinRT (C++/CX is no longer recommended), you need to add support to VS if you haven't already by installing this: https://marketplace.visualstudio.com/items?itemName=CppWinRTTeam.cppwinrt101804264

Awesome to hear it worked! I have the project templates in VS, but maybe I needed something else... I'll have to check that out, thanks so much Mike for validating that this worked!!

@azchohfi can we bring this fix in the PR to 6.1.0? It's a super simple one-liner fix :)

@michael-hawker can we cherry pick #3423 to another branch from rel/6.1.0 (dev/6.1.1)?

I hope this fix didn't break this: https://github.com/windows-toolkit/WindowsCommunityToolkit/pull/2499
It seems Tuple is required for the ToastContent changes,
@azchohfi @andrewleader

I think the ToastContentBuilder class was never supported for C++, looking at the Builder code (I wasn't the one who authored it), there's an #if !WINRT that I believe causes all the Builder code to not be included in C++.

Is it correct that by "break" you simply mean the ToastContentBuilder class isn't appearing from your C++/WinRT project?

In a C# project, I tested the updated library and ToastContentBuilder is working.

@andrewleader See the PR review https://github.com/windows-toolkit/WindowsCommunityToolkit/pull/2499 - it mentions why Tuple was needed and the additional nuget package dependency was approved. So the last fix may have broke this.
Yes - I am not seeing the class in C++. But now I can build. I'll have to do this without the ToastContentBuilder class.

The Tuple dependency is still included on everything except native (which is C++), see the screenshot below. Native doesn't support the Tuple dependency, so that's probably also why they excluded the ToastContentBuilder class from being compiled in the native code (but they previously still had the Tuple dependency be included on native, which was why it failed installing).

image

Maybe it's possible to refactor the ToastContentBuilder class so it'll also work for C++ apps and not have the dependency on Tuple? Could you create a new issue for enabling ToastContentBuilder for C++ so that request can at least be tracked?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesmcroft picture jamesmcroft  路  3Comments

SmartPolarBear picture SmartPolarBear  路  4Comments

kusanagi2k2 picture kusanagi2k2  路  4Comments

ranjeshj picture ranjeshj  路  3Comments

nolanblew picture nolanblew  路  3Comments