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

Bringing Project Ironsides into Dev Home #2887

Merged
merged 13 commits into from
May 15, 2024
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
18 changes: 18 additions & 0 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevSetupAgent.Test", "exten
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HyperVExtension.HostGuestCommunication", "extensions\HyperVExtension\src\HyperVExtension.HostGuestCommunication\HyperVExtension.HostGuestCommunication.csproj", "{D759CD66-494C-4A00-8075-8B65A9891349}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.PI", "tools\PI\DevHome.PI\DevHome.PI.csproj", "{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PI", "PI", "{DB3D0F2C-1A7F-44B4-B408-B21A56212985}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Customization", "Customization", "{623998FD-B0A6-4980-95D5-A5072301CA10}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Customization", "tools\Customization\DevHome.Customization\DevHome.Customization.csproj", "{AF527EA4-6A24-4BD6-BC6E-A5863DC3489C}"
Expand Down Expand Up @@ -614,6 +618,18 @@ Global
{D759CD66-494C-4A00-8075-8B65A9891349}.Release|x64.Build.0 = Release|x64
{D759CD66-494C-4A00-8075-8B65A9891349}.Release|x86.ActiveCfg = Release|x86
{D759CD66-494C-4A00-8075-8B65A9891349}.Release|x86.Build.0 = Release|x86
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Debug|arm64.ActiveCfg = Debug|ARM64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Debug|arm64.Build.0 = Debug|ARM64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Debug|x64.ActiveCfg = Debug|x64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Debug|x64.Build.0 = Debug|x64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Debug|x86.ActiveCfg = Debug|x86
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Debug|x86.Build.0 = Debug|x86
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Release|arm64.ActiveCfg = Release|ARM64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Release|arm64.Build.0 = Release|ARM64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Release|x64.ActiveCfg = Release|x64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Release|x64.Build.0 = Release|x64
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Release|x86.ActiveCfg = Release|x86
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725}.Release|x86.Build.0 = Release|x86
{AF527EA4-6A24-4BD6-BC6E-A5863DC3489C}.Debug|arm64.ActiveCfg = Debug|arm64
{AF527EA4-6A24-4BD6-BC6E-A5863DC3489C}.Debug|arm64.Build.0 = Debug|arm64
{AF527EA4-6A24-4BD6-BC6E-A5863DC3489C}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -745,6 +761,8 @@ Global
{F4095FD3-6A3F-490B-966D-E63059612EE6} = {3E3791DF-070D-4ADE-96E8-93D6FBD53953}
{0E05A442-BDC7-43D4-A000-F8C986826716} = {3E3791DF-070D-4ADE-96E8-93D6FBD53953}
{D759CD66-494C-4A00-8075-8B65A9891349} = {81AACED5-CFB5-47A6-AFD6-4625AADCFFA3}
{CAAC0CDF-9AB8-4F43-A3EB-38D785AF5725} = {DB3D0F2C-1A7F-44B4-B408-B21A56212985}
{DB3D0F2C-1A7F-44B4-B408-B21A56212985} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
{623998FD-B0A6-4980-95D5-A5072301CA10} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
{AF527EA4-6A24-4BD6-BC6E-A5863DC3489C} = {623998FD-B0A6-4980-95D5-A5072301CA10}
{FAB6FAA7-ADF4-4B65-9831-0C819915E6E1} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
Expand Down
2 changes: 1 addition & 1 deletion common/DevHome.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Management.Automation" Version="7.4.0" />
<PackageReference Include="WinUIEx" Version="1.8.0" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions common/Helpers/RuntimeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Security.Principal;
using Windows.Win32;
using Windows.Win32.Foundation;

Expand All @@ -27,4 +28,10 @@ public static bool IsOnWindows11
return version.Major >= 10 && version.Build >= 22000;
}
}

public static bool IsCurrentProcessRunningAsAdmin()
{
var identity = WindowsIdentity.GetCurrent();
return identity.Owner?.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid) ?? false;
}
}
7 changes: 6 additions & 1 deletion common/Services/StringResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public string GetLocalized(string key, params object[] args)
try
{
value = _resourceLoader.GetString(key);
value = string.Format(CultureInfo.CurrentCulture, value, args);

// only replace the placeholders if args is not empty
if (args.Length > 0)
{
value = string.Format(CultureInfo.CurrentCulture, value, args);
}
}
catch
{
Expand Down
66 changes: 37 additions & 29 deletions settings/DevHome.Settings/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -547,11 +547,19 @@
</data>
<data name="QuietBackgroundProcessesExperiment_Name" xml:space="preserve">
<value>Quiet background processes</value>
<comment>Name of experimental feature 'Quiet background processes' on the 'Settings -> Experiments' page where you enable it.</comment>
<comment>Name of experimental feature 'Quiet background processes' on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="QuietBackgroundProcessesExperiment_Description" xml:space="preserve">
<value>Quiet background processes allows you to free up resources while developing</value>
<comment>Inline description of the Quiet background processes experimental feature on the 'Settings -> Experiments' page where you enable it.</comment>
<comment>Inline description of the Quiet background processes experimental feature on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="ProjectIronsidesExperiment_Name" xml:space="preserve">
<value>Project Ironsides</value>
<comment>Name of experimental feature 'Project Ironsides' on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="ProjectIronsidesExperiment_Description" xml:space="preserve">
<value>Project Ironsides is a utlity to provide deeper insights into your applications</value>
<comment>Inline description of the Project Ironsides experimental feature on the 'Settings -&gt; Experiments' page where you enable it.</comment>
</data>
<data name="QuickstartPlayground_Name" xml:space="preserve">
<value>Quickstart Playground</value>
Expand Down
2 changes: 2 additions & 0 deletions src/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ protected async override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA

private async void OnActivated(object? sender, AppActivationArguments args)
{
ShowMainWindow();
jaholme marked this conversation as resolved.
Show resolved Hide resolved

// Note: Keep the reference to 'args.Data' object, as 'args' may be
// disposed before the async operation completes (RpcCallFailed: 0x800706be)
var localArgsDataReference = args.Data;
Expand Down
3 changes: 2 additions & 1 deletion src/DevHome.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="WinUIEx" Version="1.8.0" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
</ItemGroup>

<ItemGroup>
Expand All @@ -86,6 +86,7 @@
<ProjectReference Include="..\settings\DevHome.Settings\DevHome.Settings.csproj" />
<ProjectReference Include="..\tools\Dashboard\DevHome.Dashboard\DevHome.Dashboard.csproj" />
<ProjectReference Include="..\tools\Experiments\src\DevHome.Experiments.csproj" />
<ProjectReference Include="..\tools\PI\DevHome.PI\DevHome.PI.csproj" />
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.ElevatedServer.Projection\DevHome.QuietBackgroundProcesses.ElevatedServer.Projection.csproj" />
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.ElevatedServer\DevHome.QuietBackgroundProcesses.ElevatedServer.vcxproj" />
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.Server\DevHome.QuietBackgroundProcesses.Server.vcxproj" />
Expand Down
21 changes: 21 additions & 0 deletions src/NavConfig.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@
"visible": true
}
]
},
{
"identity": "ProjectIronsidesExperiment",
"enabledByDefault": false,
"buildTypeOverrides": [
{
"buildType": "dev",
"enabledByDefault": true,
"visible": true
},
{
"buildType": "canary",
"enabledByDefault": true,
"visible": true
},
{
"buildType": "stable",
"enabledByDefault": false,
"visible": true
}
]
}
]
}
17 changes: 17 additions & 0 deletions src/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,23 @@
</uap:Extension>
</Extensions>
</Application>
<Application Id="Devhome.PI" Executable="DevHome.PI.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="ms-resource:PIDisplayName" Description="ms-resource:PIAppDescription" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" AppListEntry="none">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<!-- Limitations in Microsoft.Extension.Configuration require this to be a key=value pair.-->
<uap5:Extension Category="windows.startupTask" uap10:Parameters="/startuptask=true">
<uap5:StartupTask TaskId="DevHome.PI.Hotkey" Enabled="true" DisplayName="ms-resource:PIStartupTaskDisplayName" />
</uap5:Extension>
<uap3:Extension Category="windows.appExecutionAlias" Executable="DevHome.PI.exe" EntryPoint="Windows.FullTrustApplication" uap10:RuntimeBehavior="packagedClassicApp" uap10:TrustLevel="mediumIL">
<uap3:AppExecutionAlias>
<desktop:ExecutionAlias Alias="devhome.pi.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>
</Extensions>
</Application>
<Application Id="DevHome.HostsFileEditor" Executable="DevHome.HostsFileEditor.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="ms-resource:HostsFileEditorAppDisplayName" Description="ms-resource:HostsFileEditorAppDescription" BackgroundColor="transparent" Square150x150Logo="Assets\HostsFileEditor\Square150x150Logo.png" Square44x44Logo="Assets\HostsFileEditor\Square44x44Logo.png" AppListEntry="none">
<uap:DefaultTile Wide310x150Logo="Assets\HostsFileEditor\Wide310x150Logo.png" />
Expand Down
49 changes: 42 additions & 7 deletions src/Program.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Diagnostics;
using DevHome.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.UI.Dispatching;
using Serilog;

namespace DevHome;

public static class Program
{
private static readonly ILogger _log = Log.ForContext("SourceContext", nameof(Program));
private static App? _app;

[STAThread]
public static void Main(string[] args)
{
// Be sure to parse these args in this instance of the exe... don't redirect this to another instance for parsing which
// may be running in a different security context.
ParseCommandLine(args);

WinRT.ComWrappersSupport.InitializeComWrappers();

var isRedirect = DecideRedirection().GetAwaiter().GetResult();
Expand All @@ -34,11 +43,7 @@ private static async Task<bool> DecideRedirection()
var activatedEventArgs = Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs();

var isRedirect = false;
if (mainInstance.IsCurrent)
{
mainInstance.Activated += OnActivated;
}
else
if (!mainInstance.IsCurrent)
{
// Redirect the activation (and args) to the "main" instance, and exit.
await mainInstance.RedirectActivationToAsync(activatedEventArgs);
Expand All @@ -48,8 +53,38 @@ private static async Task<bool> DecideRedirection()
return isRedirect;
}

private static void OnActivated(object? sender, Microsoft.Windows.AppLifecycle.AppActivationArguments e)
// Currently DevHome supports one set of command line arguments, most useful when debugging different apps within the Dev Home package.
//
// For example:
// --utilitylaunch DevHome.PI.Exe --utilityLaunchArgs "--application problemapp2"
//
// --utilityLaunch is the name of the utility to launch
// --utilityLaunchArgs are the arguments to pass to the utility. This is optional, but be sure to include the quotes if you have spaces in the arguments.
private static void ParseCommandLine(string[] args)
{
_app?.ShowMainWindow();
var builder = new ConfigurationBuilder();
builder.AddCommandLine(args);
var config = builder.Build();

var utilityToLaunch = config["utilitylaunch"];
var utilityLaunchArgs = config["utilitylaunchargs"];

if (!string.IsNullOrEmpty(utilityToLaunch))
{
try
{
var processStartInfo = new ProcessStartInfo
{
FileName = utilityToLaunch,
Arguments = utilityLaunchArgs,
};

Process.Start(processStartInfo);
}
catch (Exception ex)
{
_log.Error(ex, $"Error launching utility: {ex.Message}");
}
}
}
}
Loading
Loading