You have to fix both folder issues separately
- The *.exe.WebView2 is a cache folder created when you run the webview2 inside the application. The following is how to redirect the folder to where you want it it to go, I used Path.GetTempPath().
CoreWebView2Environment cwv2Environment = await CoreWebView2Environment.CreateAsync(null, Path.GetTempPath(), new CoreWebView2EnvironmentOptions());
await webBrowser.EnsureCoreWebView2Async(cwv2Environment);
Path.GetTempPath() will redirect to the users local app data temp so it would prevent permission issues on the servers and be easily maintained by infrastructure on growing hard drive space.
- A current temp solution is move the runtimes folder to the home directory if that is where you want it and the second line deletes it. In Visual Studio go to the project properties -> Compile -> Build Events and in the Post-build event command line and added the following.
xcopy /y $(TargetDir)runtimes\win-x64\native\WebView2Loader.dll $(TargetDir)$(OutDir)
RD /S /Q "$(TargetDir)runtimes\"