Skip to content

Commit

Permalink
WinUI 3 sample: Update Readme and fixed-version Runtime code (#258)
Browse files Browse the repository at this point in the history
* Update readme & cmtd-out Runtime code

* in-sentence link

* official name of sample
  • Loading branch information
mikehoffms authored Nov 7, 2024
1 parent d480172 commit 1709010
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public App()
{
this.InitializeComponent();

// 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);
// 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:

// 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 5 additions & 46 deletions SampleApps/WebView2_WinUI3_Sample/readme.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
# 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>

# WinUI 3 (Windows App SDK) sample app

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 1709010

Please sign in to comment.