Skip to content

Commit

Permalink
[PowerToys Run] Update to net5 (#12434)
Browse files Browse the repository at this point in the history
* [Setup] Add support for installing both dotnet 3 and 5 (#12306)

* [PowerToys Run] Update to net5 (#12286)

* Change targets of projects

* Update Microsoft.Toolkit.Uwp.Notifications,

changed TargetFramework for PowerLauncher project in order to resolve an issue with ModernWpf

* Specify windows version in order to fix build errors

* Fixed suppressed warnings

* Updated sdk

* Removed usage of obsolete GlobalAssemblyCache

* Removed obsolete DesktopNotificationManagerCompat

* Update nuget versions

* Update installer

* [PowerToys Run] Obsolete APIs and warnings introduced in .net5 (#12423)

* Change targets of projects

* Update Microsoft.Toolkit.Uwp.Notifications,

changed TargetFramework for PowerLauncher project in order to resolve an issue with ModernWpf

* Fixed suppressed warnings

* Removed obsolete DesktopNotificationManagerCompat

* Get rid of binary formatter

* Update tests

* Don't include new image cache file to the report

* There's no need to call IsOwner as it doesn't make sense

* Fix different nullability exception

* Exclude extra dlls from tests

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
  • Loading branch information
mykhailopylyp and yuyoyuppe committed Jul 21, 2021
1 parent 37132c9 commit c651a4b
Show file tree
Hide file tree
Showing 58 changed files with 180 additions and 402 deletions.
5 changes: 4 additions & 1 deletion .pipelines/ci/templates/build-powertoys-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ steps:
**\UnitTest-ColorPickerUI.dll
**\Microsoft.Interop.Tests.dll
!**\obj\**
!**\ref\**
- task: VSTest@2
displayName: 'XUnit Tests'
inputs:
Expand All @@ -139,6 +140,7 @@ steps:
testAssemblyVer2: |
**\ImageResizer.Test.dll
!**\obj\**
!**\ref\**
- task: VSTest@2
displayName: 'NUnit Tests'
Expand All @@ -155,6 +157,7 @@ steps:
**\Wox.Test.dll
**\Microsoft.PowerToys.Run.Plugin.System.UnitTests.dll
!**\obj\**
!**\ref\**
# Native dlls
- task: VSTest@2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ namespace fs = std::filesystem;

namespace updating
{
constexpr size_t REQUIRED_MINIMAL_PATCH = 15;

bool dotnet_is_installed()
bool dotnet_is_installed(const size_t major, const size_t minor, const size_t requiredMinimalPatch)
{
auto runtimes = exec_and_read_output(LR"(dotnet --list-runtimes)");
if (!runtimes)
{
return false;
}
std::regex dotnet3_1_x{ R"(Microsoft\.WindowsDesktop\.App\s3\.1\.(\d+))" };
std::array<char, 512> regexBuffer;
sprintf_s(regexBuffer.data(),
regexBuffer.size(),
R"(Microsoft\.WindowsDesktop\.App\s%zu\.%zu\.(\d+))",
major,
minor);
std::regex dotnetRegex{ regexBuffer.data() };

size_t latestPatchInstalled = 0;
using rexit = std::sregex_iterator;
for (auto it = rexit{ begin(*runtimes), end(*runtimes), dotnet3_1_x }; it != rexit{}; ++it)
for (auto it = rexit{ begin(*runtimes), end(*runtimes), dotnetRegex }; it != rexit{}; ++it)
{
if (!it->ready() || it->size() < 2)
{
Expand All @@ -40,16 +44,15 @@ namespace updating
latestPatchInstalled = std::max(patch, latestPatchInstalled);
}
}
return latestPatchInstalled >= REQUIRED_MINIMAL_PATCH;
return latestPatchInstalled >= requiredMinimalPatch;
}

std::optional<fs::path> download_dotnet()
std::optional<fs::path> download_dotnet(const wchar_t* dotnetDesktopDownloadLink)
{
const wchar_t DOTNET_DESKTOP_DOWNLOAD_LINK[] = L"https://download.visualstudio.microsoft.com/download/pr/d30352fe-d4f3-4203-91b9-01a3b66a802e/bb416e6573fa278fec92113abefc58b3/windowsdesktop-runtime-3.1.15-win-x64.exe";
const wchar_t DOTNET_DESKTOP_FILENAME[] = L"windowsdesktop-runtime.exe";

auto dotnet_download_path = fs::temp_directory_path() / DOTNET_DESKTOP_FILENAME;
winrt::Windows::Foundation::Uri download_link{ DOTNET_DESKTOP_DOWNLOAD_LINK };
winrt::Windows::Foundation::Uri download_link{ dotnetDesktopDownloadLink };

const size_t max_attempts = 3;
bool download_success = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace fs = std::filesystem;
namespace updating
{
bool dotnet_is_installed();
std::optional<fs::path> download_dotnet();
bool dotnet_is_installed(const size_t major, const size_t minor, const size_t requiredMinimalPatch);
std::optional<fs::path> download_dotnet(const wchar_t* dotnetDesktopDownloadLink);
bool install_dotnet(fs::path dotnet_download_path, const bool silent);
}
30 changes: 22 additions & 8 deletions installer/PowerToysBootstrapper/bootstrapper/bootstrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,39 @@ int Bootstrapper(HINSTANCE hInstance)
{
if (installDotnet)
{
spdlog::debug("Detecting if dotnet is installed");
const bool dotnetInstalled = updating::dotnet_is_installed();
spdlog::debug("Dotnet is already installed: {}", dotnetInstalled);
if (!dotnetInstalled)
auto dotnet3Info = std::make_tuple(VersionHelper{ 3, 1, 15 },
L"https://download.visualstudio.microsoft.com/download/pr/d30352fe-d4f3-4203-91b9-01a3b66a802e/bb416e6573fa278fec92113abefc58b3/windowsdesktop-runtime-3.1.15-win-x64.exe");
auto dotnet5Info = std::make_tuple(VersionHelper{ 5, 0, 7 },
L"https://download.visualstudio.microsoft.com/download/pr/2b83d30e-5c86-4d37-a1a6-582e22ac07b2/c7b1b7e21761bbfb7b9951f5b258806e/windowsdesktop-runtime-5.0.7-win-x64.exe");

const std::array dotnetsToInstall = { std::move(dotnet3Info), std::move(dotnet5Info) };

for (const auto& [ver, downloadLink] : dotnetsToInstall)
{
const auto& [major, minor, minimalRequiredPatch] = ver;
spdlog::debug("Detecting if dotnet {} is installed", ver.toString());
const bool dotnetInstalled = updating::dotnet_is_installed(major, minor, minimalRequiredPatch);

if (dotnetInstalled)
{
spdlog::debug("Dotnet {} is already installed: {}", ver.toString(), dotnetInstalled);
continue;
}

bool installedSuccessfully = false;
if (const auto dotnet_installer_path = updating::download_dotnet())
if (const auto dotnetInstallerPath = updating::download_dotnet(downloadLink))
{
// Dotnet installer has its own progress bar
CloseProgressBarDialog();
installedSuccessfully = updating::install_dotnet(*dotnet_installer_path, g_Silent);
installedSuccessfully = updating::install_dotnet(*dotnetInstallerPath, g_Silent);
if (!installedSuccessfully)
{
spdlog::error("Couldn't install dotnet");
spdlog::error("Couldn't install dotnet {}", ver.toString());
}
}
else
{
spdlog::error("Couldn't download dotnet");
spdlog::error("Couldn't download dotnet {}", ver.toString());
}

if (!installedSuccessfully)
Expand Down
2 changes: 1 addition & 1 deletion installer/PowerToysSetup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@

<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
<File Source="$(var.BinX64Dir)modules\Launcher\Microsoft.Launcher.dll" />
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;UnitsNet.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;ManagedTelemetry.dll;PowerLauncher.Telemetry.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;ManagedCommon.dll;System.IO.Abstractions.dll;Microsoft.PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll;System.Runtime.CompilerServices.Unsafe.dll;System.Text.Encodings.Web.dll?>
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;UnitsNet.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;ManagedTelemetry.dll;PowerLauncher.Telemetry.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;ManagedCommon.dll;System.IO.Abstractions.dll;Microsoft.PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll;Microsoft.Windows.SDK.NET.dll;WinRT.Runtime.dll?>
<File Id="File_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\$(var.File)" />
<?endforeach?>
<File Source="$(var.BinX64Dir)Settings\Microsoft.PowerToys.Settings.UI.Lib.dll" />
Expand Down
2 changes: 1 addition & 1 deletion installer/PowerToysSetup/publish.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ echo ^<PropertyGroup^> >> !launcherPublishProfile!
echo ^<PublishProtocol^>FileSystem^</PublishProtocol^> >> !launcherPublishProfile!
echo ^<Configuration^>Release^</Configuration^> >> !launcherPublishProfile!
echo ^<Platform^>x64^</Platform^> >> !launcherPublishProfile!
echo ^<TargetFramework^>netcoreapp3.1^</TargetFramework^> >> !launcherPublishProfile!
echo ^<TargetFramework^>net5.0-windows10.0.18362.0^</TargetFramework^> >> !launcherPublishProfile!
echo ^<PublishDir^>..\..\..\..\x64\Release\modules\launcher^</PublishDir^> >> !launcherPublishProfile!
echo ^<RuntimeIdentifier^>win-x64^</RuntimeIdentifier^> >> !launcherPublishProfile!
echo ^<SelfContained^>false^</SelfContained^> >> !launcherPublishProfile!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>

<IsPackable>false</IsPackable>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Version.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<ProjectGuid>{BB23A474-5058-4F75-8FA3-5FE3DE53CDF4}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Community.PowerToys.Run.Plugin.UnitConverter</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Version.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows10.0.18362</TargetFramework>
<ProjectGuid>{4D971245-7A70-41D5-BAA0-DDB5684CAF51}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Community.PowerToys.Run.Plugin.VSCodeWorkspaces</RootNamespace>
Expand Down Expand Up @@ -56,12 +56,6 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<Reference Include="Windows.Foundation.UniversalApiContract">
<HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Foundation.UniversalApiContract\8.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>

<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Version.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<ProjectGuid>{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Plugin.Folder</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Version.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<ProjectGuid>{F8B870EB-D5F5-45BA-9CF7-A5C459818820}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Plugin.Indexer</RootNamespace>
Expand Down Expand Up @@ -53,10 +53,10 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\settings-ui\Microsoft.PowerToys.Settings.UI.Library\Microsoft.PowerToys.Settings.UI.Library.csproj" >
<ProjectReference Include="..\..\..\..\settings-ui\Microsoft.PowerToys.Settings.UI.Library\Microsoft.PowerToys.Settings.UI.Library.csproj">
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj" >
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows10.0.18362</TargetFramework>

<IsPackable>false</IsPackable>

Expand Down

0 comments on commit c651a4b

Please sign in to comment.