Skip to content
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

Add background elevated process for setup flow #59

Merged
merged 20 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Logging", "logging\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Settings", "settings\DevHome.Settings\DevHome.Settings.csproj", "{72CE876A-7272-4460-92EB-845A45B743FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.SetupFlow.ElevatedServer", "tools\SetupFlow\DevHome.SetupFlow.ElevatedServer\DevHome.SetupFlow.ElevatedServer.csproj", "{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}"
ProjectSection(ProjectDependencies) = postProject
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1} = {A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.SetupFlow.ElevatedComponent", "tools\SetupFlow\DevHome.SetupFlow.ElevatedComponent\DevHome.SetupFlow.ElevatedComponent.csproj", "{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.SetupFlow.ElevatedComponent.Setup", "tools\SetupFlow\DevHome.SetupFlow.ElevatedComponent.Setup\DevHome.SetupFlow.ElevatedComponent.Setup.csproj", "{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}"
ProjectSection(ProjectDependencies) = postProject
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1} = {A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.SetupFlow.ElevatedComponent.Projection", "tools\SetupFlow\DevHome.SetupFlow.ElevatedComponent.Projection\DevHome.SetupFlow.ElevatedComponent.Projection.csproj", "{053AF75C-5CD8-497F-BA25-47435BD86047}"
ProjectSection(ProjectDependencies) = postProject
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1} = {A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -511,6 +528,70 @@ Global
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x64.Build.0 = Release|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x86.ActiveCfg = Release|x86
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x86.Build.0 = Release|x86
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|Any CPU.ActiveCfg = Debug|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|Any CPU.Build.0 = Debug|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|arm64.ActiveCfg = Debug|ARM64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|arm64.Build.0 = Debug|ARM64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|x64.ActiveCfg = Debug|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|x64.Build.0 = Debug|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|x86.ActiveCfg = Debug|x86
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Debug|x86.Build.0 = Debug|x86
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|Any CPU.ActiveCfg = Release|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|Any CPU.Build.0 = Release|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|arm64.ActiveCfg = Release|ARM64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|arm64.Build.0 = Release|ARM64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|x64.ActiveCfg = Release|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|x64.Build.0 = Release|x64
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|x86.ActiveCfg = Release|x86
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508}.Release|x86.Build.0 = Release|x86
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|Any CPU.ActiveCfg = Debug|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|Any CPU.Build.0 = Debug|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|arm64.ActiveCfg = Debug|ARM64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|arm64.Build.0 = Debug|ARM64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|x64.ActiveCfg = Debug|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|x64.Build.0 = Debug|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|x86.ActiveCfg = Debug|x86
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Debug|x86.Build.0 = Debug|x86
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|Any CPU.ActiveCfg = Release|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|Any CPU.Build.0 = Release|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|arm64.ActiveCfg = Release|ARM64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|arm64.Build.0 = Release|ARM64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|x64.ActiveCfg = Release|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|x64.Build.0 = Release|x64
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|x86.ActiveCfg = Release|x86
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1}.Release|x86.Build.0 = Release|x86
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|Any CPU.ActiveCfg = Debug|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|Any CPU.Build.0 = Debug|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|arm64.ActiveCfg = Debug|ARM64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|arm64.Build.0 = Debug|ARM64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|x64.ActiveCfg = Debug|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|x64.Build.0 = Debug|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|x86.ActiveCfg = Debug|x86
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Debug|x86.Build.0 = Debug|x86
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|Any CPU.ActiveCfg = Release|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|Any CPU.Build.0 = Release|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|arm64.ActiveCfg = Release|ARM64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|arm64.Build.0 = Release|ARM64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|x64.ActiveCfg = Release|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|x64.Build.0 = Release|x64
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|x86.ActiveCfg = Release|x86
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B}.Release|x86.Build.0 = Release|x86
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|Any CPU.ActiveCfg = Debug|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|Any CPU.Build.0 = Debug|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|arm64.ActiveCfg = Debug|ARM64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|arm64.Build.0 = Debug|ARM64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|x64.ActiveCfg = Debug|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|x64.Build.0 = Debug|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|x86.ActiveCfg = Debug|x86
{053AF75C-5CD8-497F-BA25-47435BD86047}.Debug|x86.Build.0 = Debug|x86
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|Any CPU.ActiveCfg = Release|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|Any CPU.Build.0 = Release|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|arm64.ActiveCfg = Release|ARM64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|arm64.Build.0 = Release|ARM64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|x64.ActiveCfg = Release|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|x64.Build.0 = Release|x64
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|x86.ActiveCfg = Release|x86
{053AF75C-5CD8-497F-BA25-47435BD86047}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -537,6 +618,10 @@ Global
{6254ADB1-B6FD-4D74-AF13-40C997919178} = {222B92B1-AC7A-409D-957B-A3851D3F41B0}
{AA13E2A1-7F04-419C-9E53-9E8CD45487A7} = {4179A05E-37F1-46CD-9218-0889EA2BB75B}
{88E889AD-4F51-4312-8E16-5B81FA6BB1FD} = {4179A05E-37F1-46CD-9218-0889EA2BB75B}
{940FD524-1AC0-4BBA-BBBE-1E4F2E797508} = {4179A05E-37F1-46CD-9218-0889EA2BB75B}
{A7E5FD7B-B41A-4CAE-A45A-E686DFA8ACF1} = {4179A05E-37F1-46CD-9218-0889EA2BB75B}
{B0DE9F34-90E8-4A4C-AD37-BBE4DFE6CD5B} = {4179A05E-37F1-46CD-9218-0889EA2BB75B}
{053AF75C-5CD8-497F-BA25-47435BD86047} = {4179A05E-37F1-46CD-9218-0889EA2BB75B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {030B5641-B206-46BB-BF71-36FF009088FA}
Expand Down
17 changes: 14 additions & 3 deletions src/DevHome.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
Expand All @@ -8,7 +11,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
<PublishProfile Condition="'$(BuildingInsideVisualStudio)' != 'True'">Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWinUI>true</UseWinUI>
Expand All @@ -35,7 +38,7 @@

<ItemGroup>
<ProjectReference Include="..\common\DevHome.Common.csproj" />
<ProjectReference Include="..\settings\DevHome.Settings\DevHome.Settings.csproj" />
<ProjectReference Include="..\settings\DevHome.Settings\DevHome.Settings.csproj" />
<ProjectReference Include="..\tools\SampleTool\src\SampleTool.csproj" />
<ProjectReference Include="..\tools\Dashboard\DevHome.Dashboard\DevHome.Dashboard.csproj" />
<ProjectReference Include="..\tools\SetupFlow\DevHome.SetupFlow\DevHome.SetupFlow.csproj" />
Expand Down Expand Up @@ -67,4 +70,12 @@
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>

<!-- In the setup flow there is a WinRT component that gets consumed by project reference
in some places and by referencing the .winmd in others. This results in multiple
projects having the .winmd as output, which causes a build error. We disable that
check for now, but we should find a solution that doesn't require it. -->
<PropertyGroup>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using DevHome.SetupFlow.ComInterop.Projection.WindowsPackageManager;
using DevHome.SetupFlow.Common.Models;
using DevHome.SetupFlow.Common.Services;
using DevHome.SetupFlow.ElevatedComponent;
using DevHome.Telemetry;
using Microsoft.Management.Deployment;
using Windows.Foundation;
Expand Down Expand Up @@ -114,4 +115,6 @@ private bool RequiresElevation()
public ActionCenterMessages GetErrorMessages() => throw new NotImplementedException();

public ActionCenterMessages GetRebootMessage() => throw new NotImplementedException();

IAsyncOperation<TaskFinishedState> ISetupTask.ExecuteAsAdmin(IElevatedComponentFactory elevatedComponentFactory) => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<ItemGroup>
<ProjectReference Include="..\..\..\common\DevHome.Common.csproj" />
<ProjectReference Include="..\DevHome.SetupFlow.ComInterop.Projection\DevHome.SetupFlow.ComInterop.Projection.csproj" />
<ProjectReference Include="..\DevHome.SetupFlow.ElevatedComponent.Projection\DevHome.SetupFlow.ElevatedComponent.Projection.csproj" />
<ProjectReference Include="..\DevHome.SetupFlow.ElevatedComponent.Setup\DevHome.SetupFlow.ElevatedComponent.Setup.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 13 additions & 3 deletions tools/SetupFlow/DevHome.SetupFlow.Common/Models/ISetupTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using System.Windows.Input;
using DevHome.SetupFlow.ElevatedComponent;
using Windows.Foundation;

namespace DevHome.SetupFlow.Common.Models;
Expand All @@ -14,7 +15,7 @@ public interface ISetupTask
/// <summary>
/// Gets a value indicating whether this task requires admin privileges to be executed.
/// </summary>
public abstract bool RequiresAdmin
public bool RequiresAdmin
{
get;
}
Expand All @@ -29,7 +30,7 @@ public abstract bool RequiresAdmin
/// Setting up WSL (future) will require us to reboot the machine to finish, but other
/// tasks like installing an app may trigger a reboot out of our control.
/// </remarks>
public abstract bool RequiresReboot
public bool RequiresReboot
{
get;
}
Expand All @@ -47,7 +48,16 @@ public abstract bool RequiresReboot
/// <returns>
/// The async operation that executes this task. The value returned indicates whether the task completed successfully.
/// </returns>
public abstract IAsyncOperation<TaskFinishedState> Execute();
public IAsyncOperation<TaskFinishedState> Execute();

/// <summary>
/// Executes this setup task as admin.
/// </summary>
/// <param name="elevatedComponentFactory">Helper object to create the needed objects on the elevated process.</param>
/// <returns>
/// The async operation that executes this task. The value returned indicates whether the task completed successfully.
/// </returns>
public IAsyncOperation<TaskFinishedState> ExecuteAsAdmin(IElevatedComponentFactory elevatedComponentFactory);

/// <summary>
/// Gets the object used to display all messages in the loading screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using CommunityToolkit.Mvvm.Input;
using DevHome.SetupFlow.Common.Models;
using DevHome.SetupFlow.Common.ViewModels;
using DevHome.SetupFlow.ElevatedComponent;

namespace DevHome.SetupFlow.Common.Services;

Expand Down Expand Up @@ -49,6 +50,11 @@ public IList<ISetupTaskGroup> TaskGroups
get; set;
}

public RemoteObject<IElevatedComponentFactory> RemoteElevatedFactory
{
get; set;
}

/// <summary>
/// Gets or sets the list of pages to be shown in this flow.
/// </summary>
Expand Down Expand Up @@ -91,6 +97,16 @@ public void NotifyNavigationCanExecuteChanged()
GoToNextPageCommand.NotifyCanExecuteChanged();
}

/// <summary>
/// Releases the remote factory, terminating the background process.
/// </summary>
public void ReleaseRemoteFactory()
{
// Disposing of this object signals the background process to terminate.
RemoteElevatedFactory?.Dispose();
RemoteElevatedFactory = null;
}

/// <summary>
/// Determines whether a given page is one that was shown previously on the flow.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Windows.Input;
using DevHome.SetupFlow.Common.Models;
using DevHome.SetupFlow.ElevatedComponent;
using Windows.Foundation;

namespace DevHome.SetupFlow.ConfigurationFile.Models;
Expand All @@ -22,5 +23,7 @@ internal class ConfigureTask : ISetupTask

public ActionCenterMessages GetRebootMessage() => throw new NotImplementedException();

IAsyncOperation<TaskFinishedState> ISetupTask.Execute() => throw new NotImplementedException();
IAsyncOperation<TaskFinishedState> ISetupTask.Execute() => throw new NotImplementedException();

IAsyncOperation<TaskFinishedState> ISetupTask.ExecuteAsAdmin(IElevatedComponentFactory elevatedComponentFactory) => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Windows.Input;
using DevHome.SetupFlow.Common.Models;
using DevHome.SetupFlow.ElevatedComponent;
using Windows.Foundation;

namespace DevHome.SetupFlow.DevDrive.Models;
Expand All @@ -25,5 +26,7 @@ public bool DependsOnDevDriveToBeInstalled

public ActionCenterMessages GetRebootMessage() => throw new NotImplementedException();

IAsyncOperation<TaskFinishedState> ISetupTask.Execute() => throw new NotImplementedException();
IAsyncOperation<TaskFinishedState> ISetupTask.Execute() => throw new NotImplementedException();

IAsyncOperation<TaskFinishedState> ISetupTask.ExecuteAsAdmin(IElevatedComponentFactory elevatedComponentFactory) => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<!-- CsWinRT properties -->
<PropertyGroup>
<CsWinRTIncludes>DevHome.SetupFlow.ElevatedComponent</CsWinRTIncludes>
</PropertyGroup>
<ItemGroup>
<CsWinRTInputs Include="..\DevHome.SetupFlow.ElevatedComponent\bin\$(Platform)\$(Configuration)\$(TargetFramework)\DevHome.SetupFlow.ElevatedComponent.winmd" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.188-beta">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.188-beta">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />
</ItemGroup>

</Project>
Loading