Skip to content

Commit

Permalink
Revert "WinUI 3 sample: Update Readme and fixed-version Runtime code (M…
Browse files Browse the repository at this point in the history
  • Loading branch information
Henko551 authored Nov 15, 2024
1 parent 73a6638 commit 8b6ca7c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
Expand Down
Binary file not shown.
51 changes: 46 additions & 5 deletions SampleApps/WebView2_WinUI3_Sample/readme.md
Original file line number Diff line number Diff line change
@@ -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
<pre>\WebView2_WinUI3_Sample\WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53\</pre>
2 Update the package project wapproj file for the version your using
<pre> < Content Include="FixedRuntime\95.0.1020.53\\**\*.*" > </pre>
3 Uncomment the code in app.xaml.cs to enable the runtime override
<pre>
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);
}
</pre>
4 Update the version information for the appropriate version
<pre>
String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53");
</pre>


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).

0 comments on commit 8b6ca7c

Please sign in to comment.