From 2601f9d5254c6a4de289b44355bfe5d094a8dc24 Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Wed, 5 Aug 2020 13:47:07 +0200 Subject: [PATCH] Added strong naming and fixed a dependency (#34) * Added strong naming for the .NET Framework 4.x dlls as was discussed in #3. Strong naming doesn't help for security but it's sometimes needed as companies want to build strongly named assemblies themselves, and these can only use other strong named assembly. The general way to do this, is to sign the assembly with a public known snk file (Which is in the repository) so it's strongly named but without negative side effects. * Fixed a tricky issue with .resx files, concerns GenerateResourceUsePreserializedResources and dependencies. * Fixed the copyright years. * Fixed an issue with SystemInfo, somehow the DpiFactorX/DpiFactorY weren't initialized. * As net45 doesn't build with "dotnet build", we need to use msbuild instead. * Removing unneeded packages for net4x * msbuild needs nuget restore before the build to work * Make sure that PRs don't push the packages to the nuget feed (will fail anyway) --- azure-pipelines.yml | 23 ++++++---- src/Directory.Build.props | 14 +++++- src/NotifyIconWpf.snk | Bin 0 -> 596 bytes src/NotifyIconWpf/BalloonIcon.cs | 2 +- src/NotifyIconWpf/Interop/SystemInfo.cs | 40 +++++++++++++++--- .../Interop/WindowMessageSink.cs | 2 +- src/NotifyIconWpf/Interop/WindowsMessages.cs | 2 +- src/NotifyIconWpf/NotifyIconWpf.csproj | 9 ++-- src/NotifyIconWpf/NotifyIconWpf.snk | Bin 0 -> 596 bytes src/NotifyIconWpf/PopupActivationMode.cs | 2 +- src/NotifyIconWpf/TaskbarIcon.Declarations.cs | 2 +- src/NotifyIconWpf/TaskbarIcon.cs | 2 +- src/NotifyIconWpf/Util.cs | 6 +-- src/Sample Project/Sample Project.csproj | 5 --- .../Windowless Sample.csproj | 6 +-- src/WindowsFormsSample/Form1.cs | 12 +++--- .../WindowsFormsSample.csproj | 5 +-- src/global.json | 5 ++- 18 files changed, 89 insertions(+), 48 deletions(-) create mode 100644 src/NotifyIconWpf.snk create mode 100644 src/NotifyIconWpf/NotifyIconWpf.snk diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1d9fadf..a0f0424 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,17 +32,24 @@ stages: versionSpec: '5.5.1' - task: UseDotNet@2 - displayName: 'Use .NET Core sdk 3.1.2' + displayName: 'Use .NET Core sdk 3.1.6' inputs: packageType: sdk - version: 3.1.201 + version: 3.1.302 - - task: DotNetCoreCLI@2 - displayName: Build + - task: NuGetCommand@2 + displayName: NuGet restore inputs: - command: build - projects: '$(solution)' - arguments: '--configuration $(buildConfiguration) /p:Platform="$(buildPlatform)"' + command: 'restore' + restoreSolution: '$(solution)' + feedsToUse: config + + - task: MSBuild@1 + displayName: Build and package + inputs: + solution: '$(solution)' + platform: $(buildPlatform) + configuration: $(buildConfiguration) - task: CopyFiles@2 displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)' @@ -58,7 +65,7 @@ stages: - task: NuGetCommand@2 displayName: 'Publish to wpf-notifyicon feed' - condition: succeeded() + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) inputs: command: 'push' versioningScheme: byBuildNumber diff --git a/src/Directory.Build.props b/src/Directory.Build.props index cc136e1..849d6d3 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -22,6 +22,12 @@ Source code and extensive sample application available at http://www.hardcodet.n NotifyIcon WPF Tray Notify ToolTip Popup Balloon Toast + + true + + + false + true @@ -48,8 +54,14 @@ Source code and extensive sample application available at http://www.hardcodet.n true + + true + ..\NotifyIconWpf.snk + false + + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/NotifyIconWpf.snk b/src/NotifyIconWpf.snk new file mode 100644 index 0000000000000000000000000000000000000000..30e2369ee29e013aa128ba7171a1d9e16ad81939 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096o@3TZSjh=Uq?{po48Lmza+f?uL&y z+5L)GeKlf5hXXFIZzZNX0Wi=yAL3a}_(dLnTFW(cRor_^LUySA{~}?(0+h;s9%RkX z22t#UbG%Kv2Ko9>{U|0%^(uu}^1C_FN0*7x^ON1#p^}ImNbj~2^A;1ioq!g)c#OQ) zVd(iZ5f|v*N$z;;p!E0RO=?>x1b(Xmj}HO26|wDEx!dIZ;X$E3x&!U=b+E7}TD3Jr zCUO(t9jlx=35e`BCZ~>Tw9Yb3TdjEj_0+%bQE(NSr@k2}VktYf`o6q>wt6hXGX5=R zmMAx#+Une$g|0VfVo{(7^ILN8V-d{fvc-v4f&E4m=J&`sqi=|PXbQ(lRb_jdI*QHh zo!ePHfw}{e+!}AtfF*qH>>!7C>jZf#o_#_sy2eLTfXx;4;3L?AVNCHLS*1?CQ*zJL zoApQgCg4GBP`W!dFjPhdMiT}ZM3nq%;0ttk~1p>C(S$VOKLODae&-B!kT1Es{ znYvqweznMjgZJc{OO;AQ383Y;-^DF(D1YX{2a1e@9}4k)bK{N;P!SHvcwvmSaPojG z`fOIc)W9;vPo9nS?T& public static class SystemInfo { - private static readonly System.Windows.Point DpiFactors; - static SystemInfo() + { + UpdateFactors(); + } + + internal static void UpdateFactors() { using (var source = new HwndSource(new HwndSourceParameters())) { if (source.CompositionTarget?.TransformToDevice != null) { - DpiFactors = new System.Windows.Point(source.CompositionTarget.TransformToDevice.M11, source.CompositionTarget.TransformToDevice.M22); + DpiFactorX = source.CompositionTarget.TransformToDevice.M11; + DpiFactorY = source.CompositionTarget.TransformToDevice.M22; return; } - DpiFactors = new System.Windows.Point(1, 1); } + + DpiFactorX = DpiFactorY = 1; } /// /// Returns the DPI X Factor /// - public static double DpiFactorX => DpiFactors.X; + public static double DpiFactorX { get; private set; } = 1; /// /// Returns the DPI Y Factor /// - public static double DpiFactorY => DpiFactors.Y; + public static double DpiFactorY { get; private set; } = 1; } } \ No newline at end of file diff --git a/src/NotifyIconWpf/Interop/WindowMessageSink.cs b/src/NotifyIconWpf/Interop/WindowMessageSink.cs index 19b5eac..97f0392 100644 --- a/src/NotifyIconWpf/Interop/WindowMessageSink.cs +++ b/src/NotifyIconWpf/Interop/WindowMessageSink.cs @@ -1,5 +1,5 @@ // hardcodet.net NotifyIcon for WPF -// Copyright (c) 2009 - 2013 Philipp Sumi +// Copyright (c) 2009 - 2020 Philipp Sumi // Contact and Information: http://www.hardcodet.net // // This library is free software; you can redistribute it and/or diff --git a/src/NotifyIconWpf/Interop/WindowsMessages.cs b/src/NotifyIconWpf/Interop/WindowsMessages.cs index 2d4b8ec..51ae1bf 100644 --- a/src/NotifyIconWpf/Interop/WindowsMessages.cs +++ b/src/NotifyIconWpf/Interop/WindowsMessages.cs @@ -1,5 +1,5 @@ // hardcodet.net NotifyIcon for WPF -// Copyright (c) 2009 - 2013 Philipp Sumi +// Copyright (c) 2009 - 2020 Philipp Sumi // Contact and Information: http://www.hardcodet.net // // This library is free software; you can redistribute it and/or diff --git a/src/NotifyIconWpf/NotifyIconWpf.csproj b/src/NotifyIconWpf/NotifyIconWpf.csproj index 454fc1b..1307fc6 100644 --- a/src/NotifyIconWpf/NotifyIconWpf.csproj +++ b/src/NotifyIconWpf/NotifyIconWpf.csproj @@ -4,11 +4,14 @@ Hardcodet.NotifyIcon.Wpf NotifyIcon for WPF NotifyIcon WPF - net45;net472;netcoreapp3.0;netcoreapp3.1 + net45;net472;netcoreapp3.1 + true + NotifyIconWpf.snk + false - - + + diff --git a/src/NotifyIconWpf/NotifyIconWpf.snk b/src/NotifyIconWpf/NotifyIconWpf.snk new file mode 100644 index 0000000000000000000000000000000000000000..ec0afc54b9ad54bba40d3cd865c82b33dceb8983 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096AQ8ul*AetzhVT`&gv5U73Hj-cx@#bXa za)ZyN3g228c@a2gk%@$U7hGSwPF1ZiiAQe3B$ZQ|?caB2#=uRaeWl|Uo>uNy)wnTJ zlVr{<{A)gy)i00jiZmc(ujn+8KaIi4QnNb-VG2B^cM+0}a|O2ZL-#$k%fiTA>Fn0; zzBC9yOm?x%eY&+gmX(40e}6?q#{FD59nM5IM_PegjE$5pZt?itJP2F_L+a6KZ-^5c1q>^V?v^1`2p}i!^VB#KS(ot|V~aEx%ZFKD-St z_R3toCxQmFOys{P7i+`*$0QmznE?jw^2O&K|J=!)1P^dYyz0+K!vsbX`mH5wUX%_s z4W_&51;cGt>>ol@uH=nUmgffl@2#jSWNTR855Q4ro$J86%PNlBh%XPLc%PGaf6X8Q zQBOAUrnao}Nd=+uN1UK4wDnCli~UB-?RgbgArt24=@y+n z(u-z<`)f@lL{$@HWZW~brtMrJf*WE2!a1>Y$6fbEj9Y^%M6G}s5+=-6E0j5J?lX9B zvdK3Pcc@?jr?ud@(CHBUY54^}N1Exi`aRFmTSQ)lnU^)ot>Ay`{GTSrU1b=pORpJ4 i;nPbwmk3-$On^u=tAgQcD&Samples Sample Project Sample Project - true - - - - diff --git a/src/Windowless Sample/Windowless Sample.csproj b/src/Windowless Sample/Windowless Sample.csproj index 928655b..8b973fe 100644 --- a/src/Windowless Sample/Windowless Sample.csproj +++ b/src/Windowless Sample/Windowless Sample.csproj @@ -1,18 +1,14 @@  WinExe - net45;net472;netcoreapp3.0;netcoreapp3.1 + net45;net472;netcoreapp3.1 Windowless_Sample Windowless Sample Windowless Sample - true - - - diff --git a/src/WindowsFormsSample/Form1.cs b/src/WindowsFormsSample/Form1.cs index 9e32170..1d30d71 100644 --- a/src/WindowsFormsSample/Form1.cs +++ b/src/WindowsFormsSample/Form1.cs @@ -19,12 +19,14 @@ namespace WindowsFormsSample protected override void OnLoad(EventArgs e) { base.OnLoad(e); - notifyIcon = new TaskbarIcon(); - notifyIcon.Icon = Resources.Led; - notifyIcon.ToolTipText = "Left-click to open popup"; - notifyIcon.Visibility = Visibility.Visible; + notifyIcon = new TaskbarIcon + { + Icon = Resources.Led, + ToolTipText = "Left-click to open popup", + Visibility = Visibility.Visible, + TrayPopup = new FancyPopup() + }; - notifyIcon.TrayPopup = new FancyPopup(); } protected override void OnClosed(EventArgs e) diff --git a/src/WindowsFormsSample/WindowsFormsSample.csproj b/src/WindowsFormsSample/WindowsFormsSample.csproj index 3cfb103..85bae38 100644 --- a/src/WindowsFormsSample/WindowsFormsSample.csproj +++ b/src/WindowsFormsSample/WindowsFormsSample.csproj @@ -5,14 +5,11 @@ WindowsFormsSample.Program WindowsFormsSample WindowsFormsSample - true + true - - - diff --git a/src/global.json b/src/global.json index 7bf4830..db989f5 100644 --- a/src/global.json +++ b/src/global.json @@ -1,6 +1,7 @@ { "sdk": { - "version": "3.1.200", - "rollForward": "latestPatch" + "version": "3.1.100", + "rollForward": "latestMajor", + "allowPrerelease": true } } \ No newline at end of file