Skip to content

.NET 5 support for Notifications package #3622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jan 26, 2021

Conversation

andrewleader
Copy link
Contributor

@andrewleader andrewleader commented Dec 11, 2020

Fixes #3579 and Fixes #3565

.NET 5 project support for the Notifications package. Had to add targets for both net5.0-windows10.0.17763 (for WPF/console Windows apps) and net5.0 (for ASP.NET, class libraries). The plain net5.0 version does NOT include the Show() APIs since those are for client apps.

Also fixes activation for elevated processes (previously if the app was elevated and toast is clicked, it would launch a new, non-elevated process).

PR Type

What kind of change does this PR introduce?

  • Build or CI related changes

What is the current behavior?

Cannot install Notifications package onto .NET 5 WPF apps or .NET 5 ASP.NET apps

What is the new behavior?

Installing into .NET 5.0 WPF and ASP.NET apps works and all features are functional!

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

Breaking changes

  • For UWP apps with min version 15063 or lower (doesn't affect apps with min version 16299 or higher, and only affects UWP apps)...
    • AdaptiveProgressBar.Value propery has changed from BindableProgressBarValue to AdaptiveProgressBarValue. Use AdaptiveProgressBarValue.FromDouble(0.3) or AdaptiveProgressBarValue.FromBinding("progress").
    • AdaptiveProgressBar Title, ValueStringOverride, and Status properties have changed from BindableString to string.
    • ToastContentBuilder.AddComboBox methods with params overloads have been removed. Use the remaining AddComboBox method.

@ghost
Copy link

ghost commented Dec 11, 2020

Thanks andrewleader for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@michael-hawker michael-hawker added this to the 7.0 milestone Dec 11, 2020
@ghost ghost added the in progress 🚧 label Dec 11, 2020
@ghost ghost added the bug 🐛 An unexpected issue that highlights incorrect behavior label Dec 11, 2020
@andrewleader
Copy link
Contributor Author

andrewleader commented Dec 11, 2020

Tested CI built package with .NET 5 WPF and .NET 5 ASP! Worked! Gonna test with the rest of my test suite to make sure classic projects are still working. Hmm... this broke UWP's min version again, increasing it to 17763 even though it had my changes from #3582... investigating

@michael-hawker any concerns with upgrading the MSBuild.Sdk.Extras global package to "MSBuild.Sdk.Extras": "3.0.22"? It's used by several other projects as the root project type. It seemed like the net5.0 target framework was only supported in the newer package, so I think that's why I increased the version.

@michael-hawker
Copy link
Member

@andrewleader I believe @Sergio0694 updated the MSBuild.Sdk.Extras in a different PR. Thought it had been merged, but if not should be soon?

@Sergio0694
Copy link
Member

@michael-hawker Yeah I did so in #3573, which at the moment only needs another review to be ready to merge 😋

@andrewleader
Copy link
Contributor Author

Ah perfect :) Should I keep my change for updating Extras in my PR? Pretty sure it'd be merged without a conflict right? Or should I revert that specific change?

@azchohfi
Copy link
Contributor

Keep it here as well, its fine and should be merged without a conflict if the change is exactly the same.

@@ -3,7 +3,7 @@
<PropertyGroup>
<!--<TargetFrameworks>netstandard1.4;uap10.0;native;net461;netcoreapp3.1</TargetFrameworks>-->
<!-- Removed 'native' target to unblock CI on VS 16.8, tied to changes breaking workaround for https://github.com/NuGet/Home/issues/5154 -->
<TargetFrameworks>netstandard1.4;uap10.0;net461;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard1.4;uap10.0.19041;net461;netcoreapp3.1;net5.0;net5.0-windows10.0.17763.0</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clairernovotny when we specify uap10.0.19041 here will to be enforced for the "Target" or the "Min" required version of the app?

In our other packages we assume it's the min and have 17763, so I would assume we want to follow that pattern here as well?

@andrewleader was there some guidance or doc you reference in setting this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uap10.0.19041 is the target, not the min. Min version is specified in the <TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>, I've tested and confirmed it installs on old UWPs. I don't think the MSBuild.Sdk.Extras has documented all of this, but it works 🤷‍♂️

That's how the net5.0-windows TF works too, what's specified is the target... however, there's a weird case where if the app is targeting 17763 and the library is targeting 19041 but ALSO has a plain net5.0 target, it'll pick net5.0 instead... hence why I've kept net5.0-windows at 17763 (I confirmed you do not need the 17763 SDK installed to build it though so ppl only need 19041 SDK).

@michael-hawker michael-hawker marked this pull request as draft December 17, 2020 21:57
@michael-hawker
Copy link
Member

@andrewleader converting this to a draft until you've got the new updates in for the nuspec. Let us know when it's ready for review again, thanks!

* Making package works but throws at runtime

* I think it all works!

* Remove comment and update description
@andrewleader
Copy link
Contributor Author

andrewleader commented Dec 22, 2020

Got almost everything working...

  • .NET 5 works
  • C++ UWP works!
  • .NET Framework WPF works
  • .NET Core 3.0 WPF works
  • C# UWP when min version >= 17763 works
  • C# UWP when min version = 10240 does not work

Not sure why C# UWP with low min version is unhappy, throws the following exception at runtime

System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

Version 7.0.0-preview4 didn't have this problem, so it's a new problem, strange...

@andrewleader
Copy link
Contributor Author

Seems like the UWP min version problem was related to updating the MsBuild.Sdk.Extras? Idk, the min version of the SDK was still set to 10240 but it seems like it was still building as if it's for a .NET Standard 2 app or something...

I fiddled around a long time but to work around the issue and still support UWP apps with low min versions, I simply decided to use the WINMD version of the library for that version. So now both UWP C++ apps and UWP C# apps with min version 10240-15063 use the WINMD version.

Switching to that only introduces a very minor breaking change, mostly scoped to progress bar, details added to the PR for the breaking changes.

@andrewleader andrewleader marked this pull request as ready for review January 4, 2021 15:08
@andrewleader
Copy link
Contributor Author

@michael-hawker @azchohfi this is ready for review!

@ghost ghost removed this from the 7.0 milestone Jan 6, 2021
@Kyaa-dost Kyaa-dost added this to the 7.0 milestone Jan 7, 2021
@michael-hawker
Copy link
Member

@andrewleader looks like you have some StyleCop issues like these preventing build:

        D:\a\1\s\Microsoft.Toolkit.Uwp.Notifications\Toasts\Compat\ToastNotificationManagerCompat.cs(479,27): error SA1501: Statement should not be on a single line [D:\a\1\s\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notifications.csproj]
         D:\a\1\s\Microsoft.Toolkit.Uwp.Notifications\Toasts\Compat\ToastNotificationManagerCompat.cs(487,31): error SA1501: Statement should not be on a single line [D:\a\1\s\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notifications.csproj]
         D:\a\1\s\Microsoft.Toolkit.Uwp.Notifications\Toasts\Compat\ToastNotificationManagerCompat.cs(493,31): error SA1501: Statement should not be on a single line [D:\a\1\s\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notifications.csproj]

Copy link

@aurnor aurnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with a standalone .NET5 WPF application. No issue found, all working great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using net5.0-windows10.* target framework results in typeconflicts. Microsoft.Toolkit.Uwp.Notifications not working in a .Net 5 webapi project
7 participants