Distribute a WebView2 app as a single executable file
You may want to distribute your application with a single executable file, instead of a package of many files. To create a single executable file, or to reduce the size of your package, you should statically link the WebView2Loader files. The WebView2 SDK contains a header file, WebView2Loader.dll
, and the IDL
file. WebView2Loader.dll
is a small component that helps apps locate the WebView2 Runtime, or Microsoft Edge preview channels, on the device.
For an app that doesn't ship WebView2Loader.dll
, do the following:
Open the
.vcxproj
project file for your app in a text editor, such as Visual Studio Code.The
.vcproj
project file might be a hidden file, meaning that the file isn't shown in Visual Studio. To find hidden files, use the command line.Locate the section in the code where you include the WebView2 NuGet package target files. The location in the code is highlighted in the following figure:
Copy the following code and paste it where the
Microsoft.Web.WebView2.targets
is included:<PropertyGroup> <WebView2LoaderPreference>Static</WebView2LoaderPreference> </PropertyGroup>
The inserted code is shown below:
Compile and run your app.
See also
- Get started with WebView2
- WebView2Samples repo - a comprehensive example of WebView2 capabilities.
- WebView2 API reference
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기