diff --git a/SampleApps/WebView2_WinUI3_Sample/WebView2_WinUI3_Sample/App.xaml.cs b/SampleApps/WebView2_WinUI3_Sample/WebView2_WinUI3_Sample/App.xaml.cs index 2a40787..e9b4de2 100644 --- a/SampleApps/WebView2_WinUI3_Sample/WebView2_WinUI3_Sample/App.xaml.cs +++ b/SampleApps/WebView2_WinUI3_Sample/WebView2_WinUI3_Sample/App.xaml.cs @@ -22,15 +22,15 @@ public App() { this.InitializeComponent(); - // If you're shipping a fixed-version WebView2 Runtime with your app, un-comment the - // following lines of code, and change the version number to the version number of the - // WebView2 Runtime that you're packaging and shipping to users: + // If your shipping a fixed version WebView2 SDK with your application you will need + // to use the following code (update the runtime version to what your shipping. + + //StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; + //String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53"); + //Debug.WriteLine($"Launch path [{localFolder.Path}]"); + //Debug.WriteLine($"FixedRuntime path [{fixedPath}]"); + //Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath); - // StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; - // String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\130.0.2849.39"); - // Debug.WriteLine($"Launch path [{localFolder.Path}]"); - // Debug.WriteLine($"FixedRuntime path [{fixedPath}]"); - // Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath); } /// diff --git a/SampleApps/WebView2_WinUI3_Sample/images/sample-app.png b/SampleApps/WebView2_WinUI3_Sample/images/sample-app.png deleted file mode 100644 index d6df463..0000000 Binary files a/SampleApps/WebView2_WinUI3_Sample/images/sample-app.png and /dev/null differ diff --git a/SampleApps/WebView2_WinUI3_Sample/readme.md b/SampleApps/WebView2_WinUI3_Sample/readme.md index 43c37dd..0566c9e 100644 --- a/SampleApps/WebView2_WinUI3_Sample/readme.md +++ b/SampleApps/WebView2_WinUI3_Sample/readme.md @@ -1,9 +1,50 @@ -# WinUI 3 (Windows App SDK) sample app +# Introduction +This sample shows off using a WebView2 control in a WinUi 3 Windows SDK Packaged application. + +It also optionaly shows how you would update the application to ship with a fixed WebView2 version instead of using the version installed and running on the Windows computer. + +# Relevant directories + +| Directory | Contents | +--- | --- | +| WebView2_WinUI3_Sample | Project code | +| WebView2_WinUI3_Sample (Package) | Packaging and distribution project | +| WebView2_WinUI3_Sample (Package)\FixedRuntime | (Optional) Fixed WebView2 runtime | +| WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53 | (Optional) Fixed WebView2 runtime sample | + + +# Fixed version usage +If you want to ship a fixed version of the WebView2 runtime with your application you will need to include it in your project. + +Instructions can be found at: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution + +The following assume you are using runtime version 95.0.1020.53, you will change this number to whatever version you are using. + +You will need to: +1 Include the fixed WebView2 runtime in the package project +
\WebView2_WinUI3_Sample\WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53\
+2 Update the package project wapproj file for the version your using +
 < Content Include="FixedRuntime\95.0.1020.53\\**\*.*" > 
+3 Uncomment the code in app.xaml.cs to enable the runtime override +
+public App()
+{
+    this.InitializeComponent();
+    // If you are shipping a fixed version WebView2 SDK with your application you will need
+    // to use the following code (update the runtime version to what you are shipping.
+    StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
+    String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53");
+    Debug.WriteLine($"Launch path [{localFolder.Path}]");
+    Debug.WriteLine($"FixedRuntime path [{fixedPath}]");
+    Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath);
+}
+
+4 Update the version information for the appropriate version +
 
+String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53");
+
+ -This sample (**WebView2_WinUI3_Sample**) demonstrates using a WebView2 control in a WinUI 3 (Windows App SDK) Packaged application. -![Sample app](./images/sample-app.png) -This sample also allows you to ship the app with a fixed-version WebView2 Runtime, instead of using whichever version of the WebView2 Runtime is installed and running on the user's computer. -To use this sample, see [WinUI 3 (Windows App SDK) sample app](https://learn.microsoft.com/microsoft-edge/webview2/samples/webview2-winui3-sample).