diff --git a/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj b/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj
index de36775d4..4a0fed16e 100644
--- a/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj
+++ b/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj
@@ -121,6 +121,9 @@
Scenario2_Initialize.xamlCode
+
+ Scenario3_Repair.xaml
+ SettingsPage.xamlCode
@@ -138,6 +141,9 @@
Designer
+
+ Designer
+ Designer
@@ -169,6 +175,9 @@
Scenario2_Initialize.xamlCode
+
+ Scenario3_Repair.xaml
+ SettingsPage.xamlCode
diff --git a/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj.filters b/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj.filters
index f2ef19d9c..bcb7cd50a 100644
--- a/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj.filters
+++ b/Samples/DeploymentManager/cpp-winui/DeploymentManagerSample.vcxproj.filters
@@ -10,6 +10,7 @@
+
@@ -54,4 +55,7 @@
+
+
+
\ No newline at end of file
diff --git a/Samples/DeploymentManager/cpp-winui/Project.idl b/Samples/DeploymentManager/cpp-winui/Project.idl
index d6338af15..9bb10b187 100644
--- a/Samples/DeploymentManager/cpp-winui/Project.idl
+++ b/Samples/DeploymentManager/cpp-winui/Project.idl
@@ -18,6 +18,12 @@ namespace DeploymentManagerSample
Scenario2_Initialize();
}
+ [default_interface]
+ runtimeclass Scenario3_Repair : Microsoft.UI.Xaml.Controls.Page
+ {
+ Scenario3_Repair();
+ }
+
/* The following code is template-specific IDL.
These runtime classes are the same across all C++/WinRT WinUI samples. */
diff --git a/Samples/DeploymentManager/cpp-winui/SampleConfiguration.cpp b/Samples/DeploymentManager/cpp-winui/SampleConfiguration.cpp
index 89ada0333..3cff7ab03 100644
--- a/Samples/DeploymentManager/cpp-winui/SampleConfiguration.cpp
+++ b/Samples/DeploymentManager/cpp-winui/SampleConfiguration.cpp
@@ -17,7 +17,8 @@ namespace winrt::DeploymentManagerSample
IVector implementation::MainPage::scenariosInner = single_threaded_observable_vector(
{
Scenario{ L"Get Status", hstring(name_of())},
- Scenario{ L"Initialize", hstring(name_of())}
+ Scenario{ L"Initialize", hstring(name_of())},
+ Scenario{ L"Repair", hstring(name_of())}
});
hstring SampleConfig::FeatureName{ L"DeploymentManager" };
diff --git a/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml b/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml
new file mode 100644
index 000000000..13d188452
--- /dev/null
+++ b/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+ Repair the Windows App SDK Runtime with DeploymentManager.Repair()
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml.cpp b/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml.cpp
new file mode 100644
index 000000000..83c2e6d94
--- /dev/null
+++ b/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml.cpp
@@ -0,0 +1,94 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
+#include "Scenario3_Repair.xaml.h"
+#if __has_include("Scenario3_Repair.g.cpp")
+#include "Scenario3_Repair.g.cpp"
+#endif
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+ using namespace Microsoft::Windows::ApplicationModel::WindowsAppRuntime;
+ using namespace Windows::Foundation;
+}
+
+// To learn more about WinUI, the WinUI project structure,
+// and more about our project templates, see: http://aka.ms/winui-project-info.
+
+namespace winrt::DeploymentManagerSample::implementation
+{
+ Scenario3_Repair::Scenario3_Repair()
+ {
+ InitializeComponent();
+ }
+
+ void Scenario3_Repair::UpdateRepairMessages()
+ {
+ resultStatus().Text(L"Result Status: Running Repair()...");
+ resultExtendedError().Text(L"Result ExtendedError:");
+ resultImplication().Text(L"");
+ }
+
+ void Scenario3_Repair::UpdateDeploymentResultMessages(DeploymentResult deploymentResult)
+ {
+ resultStatus().Text(L"Result Status: "); // TODO DeploymentStatus to string
+
+ // Check the result.
+ if (deploymentResult.Status() == DeploymentStatus::Ok)
+ {
+ resultImplication().Text(L"The WindowsAppRuntime was successfully Repaired and is now ready for use!");
+
+ }
+ else
+ {
+ resultExtendedError().Text(L"Result ExtendedError: " + to_hstring(deploymentResult.ExtendedError()));
+
+ // The WindowsAppRuntime is in a bad state which Repair() did not fix.
+ // Do error reporting or gather information for submitting a bug.
+ // Gracefully exit the program or carry on without using the WindowsAppRuntime.
+ resultImplication().Text(L"Repair() failed to ensure the WindowsAppRuntime.");
+ }
+ }
+
+ void Scenario3_Repair::RepairScenarioButton_Click(IInspectable const& sender, RoutedEventArgs const& e)
+ {
+ UpdateRepairMessages();
+
+ // Repair does NOT do a status check and it will attempt to repair the
+ // WindowsAppRuntime into a good state by deploying packages. Unlike a simple
+ // status check, Repair can sometimes take several seconds to deploy the packages.
+ // These should be run on a separate thread so as not to hang your app while the
+ // packages deploy.
+ DeploymentResult deploymentResult = DeploymentManager::Repair(); // TODO how to run on separate thread?
+
+ UpdateDeploymentResultMessages(deploymentResult);
+ }
+
+ void Scenario3_Repair::ForceRepairScenarioButton_Click(IInspectable const& sender, RoutedEventArgs const& e)
+ {
+ UpdateRepairMessages();
+
+ if (DeploymentManager::GetStatus().Status() == DeploymentStatus::Ok)
+ {
+ // Set force deploy option to true. This will shut down any proccesses associated
+ // with the Main and Singleton packages if they are currently in use.
+ DeploymentRepairOptions deploymentRepairOptions;
+ deploymentRepairOptions.ForceDeployment(true);
+
+ // Repair does a status check, and if the status is not Ok it will attempt to get
+ // the WindowsAppRuntime into a good state by deploying packages. Unlike a simple
+ // status check, Repair can sometimes take several seconds to deploy the packages.
+ // These should be run on a separate thread so as not to hang your app while the
+ // packages deploy.
+ DeploymentResult deploymentResult = DeploymentManager::Repair(deploymentRepairOptions); // TODO how to run on separate thread?
+
+ UpdateDeploymentResultMessages(deploymentResult);
+ }
+ else
+ {
+ resultImplication().Text(L"The WindowsAppRuntime was already in an Ok status, no action taken.");
+ }
+ }
+}
diff --git a/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml.h b/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml.h
new file mode 100644
index 000000000..320629ffb
--- /dev/null
+++ b/Samples/DeploymentManager/cpp-winui/Scenario3_Repair.xaml.h
@@ -0,0 +1,26 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+
+#include "Scenario3_Repair.g.h"
+#include "pch.h"
+
+namespace winrt::DeploymentManagerSample::implementation
+{
+ struct Scenario3_Repair : Scenario3_RepairT
+ {
+ Scenario3_Repair();
+ void UpdateRepairMessages();
+ void UpdateDeploymentResultMessages(winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::DeploymentResult deploymentResult);
+ void RepairScenarioButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
+ void ForceRepairScenarioButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
+ };
+}
+
+namespace winrt::DeploymentManagerSample::factory_implementation
+{
+ struct Scenario3_Repair : Scenario3_RepairT
+ {
+ };
+}
diff --git a/Samples/DeploymentManager/cs-winui/DeploymentManagerSample.csproj b/Samples/DeploymentManager/cs-winui/DeploymentManagerSample.csproj
index 250646b90..f5820da43 100644
--- a/Samples/DeploymentManager/cs-winui/DeploymentManagerSample.csproj
+++ b/Samples/DeploymentManager/cs-winui/DeploymentManagerSample.csproj
@@ -1,7 +1,7 @@
WinExe
- net5.0-windows10.0.19041.0
+ net6.0-windows10.0.19041.010.0.17763.0DeploymentManagerSampleapp.manifest
@@ -12,10 +12,9 @@
Properties\PublishProfiles\win10-$(Platform).pubxml10.0.19041.24
-
-
+
diff --git a/Samples/DeploymentManager/cs-winui/SampleConfiguration.cs b/Samples/DeploymentManager/cs-winui/SampleConfiguration.cs
index 97858b364..dc7e8a523 100644
--- a/Samples/DeploymentManager/cs-winui/SampleConfiguration.cs
+++ b/Samples/DeploymentManager/cs-winui/SampleConfiguration.cs
@@ -18,7 +18,9 @@ public partial class MainPage : Page
private readonly List scenarios = new()
{
new Scenario() { Title = "Get Status", ClassName = typeof(Scenario1_GetStatus).FullName },
- new Scenario() { Title = "Initialize", ClassName = typeof(Scenario2_Initialize).FullName }
+ new Scenario() { Title = "Initialize", ClassName = typeof(Scenario2_Initialize).FullName },
+ new Scenario() { Title = "Repair", ClassName = typeof(Scenario3_Repair).FullName }
+
};
}
diff --git a/Samples/DeploymentManager/cs-winui/Scenario3_Repair.xaml b/Samples/DeploymentManager/cs-winui/Scenario3_Repair.xaml
new file mode 100644
index 000000000..11d2afaf6
--- /dev/null
+++ b/Samples/DeploymentManager/cs-winui/Scenario3_Repair.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+ Repair the Windows App SDK Runtime with DeploymentManager.Repair()
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/DeploymentManager/cs-winui/Scenario3_Repair.xaml.cs b/Samples/DeploymentManager/cs-winui/Scenario3_Repair.xaml.cs
new file mode 100644
index 000000000..7217ace12
--- /dev/null
+++ b/Samples/DeploymentManager/cs-winui/Scenario3_Repair.xaml.cs
@@ -0,0 +1,96 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.Windows.ApplicationModel.WindowsAppRuntime;
+using System.Threading.Tasks;
+
+namespace DeploymentManagerSample
+{
+ public partial class Scenario3_Repair : Page
+ {
+ public Scenario3_Repair()
+ {
+ this.InitializeComponent();
+ }
+
+ private void updateRepairMessages()
+ {
+ resultStatus.Text = "Result Status: Running Repair()...";
+ resultExtendedError.Text = "Result ExtendedError:";
+ resultImplication.Text = "";
+ }
+
+ private void updateDeploymentResultMessages(DeploymentResult deploymentResult)
+ {
+ resultStatus.Text = "Result Status: " + deploymentResult.Status.ToString();
+
+ // Check the result.
+ if (deploymentResult.Status == DeploymentStatus.Ok)
+ {
+ resultImplication.Text = "The WindowsAppRuntime was successfully Repaired and is now ready for use!";
+
+ }
+ else
+ {
+ resultExtendedError.Text = "Result ExtendedError: " + deploymentResult.ExtendedError.ToString();
+
+ // The WindowsAppRuntime is in a bad state which Repair() did not fix.
+ // Do error reporting or gather information for submitting a bug.
+ // Gracefully exit the program or carry on without using the WindowsAppRuntime.
+ resultImplication.Text = "Repair() failed to ensure the WindowsAppRuntime.";
+ }
+ }
+
+ private void RepairScenarioButton_Click(object sender, RoutedEventArgs e)
+ {
+ updateRepairMessages();
+
+ if (DeploymentManager.GetStatus().Status != DeploymentStatus.Ok)
+ {
+ // Repair does NOT check for WindowsAppRuntime status and it will always attempt to get
+ // the WindowsAppRuntime into a good state by deploying packages. Unlike a simple
+ // status check, Repair can sometimes take several seconds to deploy the packages.
+ // These should be run on a separate thread so as not to hang your app while the
+ // packages deploy.
+ var RepairTask = Task.Run(() => DeploymentManager.Repair());
+ RepairTask.Wait();
+
+ updateDeploymentResultMessages(RepairTask.Result);
+ }
+ else
+ {
+ resultImplication.Text = "The WindowsAppRuntime was already in an Ok status, no action taken.";
+ }
+ }
+
+ private void ForceRepairScenarioButton_Click(object sender, RoutedEventArgs e)
+ {
+ updateRepairMessages();
+
+ if (DeploymentManager.GetStatus().Status != DeploymentStatus.Ok)
+ {
+ // Set force deploy option to true. This will shut down any proccesses associated
+ // with the Main and Singleton packages if they are currently in use.
+ DeploymentRepairOptions deploymentRepairOptions = new() {
+ ForceDeployment = true
+ };
+
+ // Repair does NOT check for WindowsAppRuntime status and it will always attempt to get
+ // the WindowsAppRuntime into a good state by deploying packages. Unlike a simple
+ // status check, Repair can sometimes take several seconds to deploy the packages.
+ // These should be run on a separate thread so as not to hang your app while the
+ // packages deploy.
+ var RepairTask = Task.Run(() => DeploymentManager.Repair(deploymentRepairOptions));
+ RepairTask.Wait();
+
+ updateDeploymentResultMessages(RepairTask.Result);
+ }
+ else
+ {
+ resultImplication.Text = "The WindowsAppRuntime was already in an Ok status, no action taken.";
+ }
+ }
+ }
+}