-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BlazorWebView for WPF not debuggable when blazor code is in a different project #1349
Comments
you need to change your original blazor and wpf project type to |
Moving wwwroot folder to WPF project will break the blazor application. Copying the files to bin folder is only a work around. When you host the blazor application in an asp.net core application, it does not copy the files and instead uses a CompositeFileProvider with all the paths from generated static web assets xml file. Wpf's blazor web view project needs a similar mechanism rather than duplicating the files in the disk. At the very least, the file provider creation should be extensible so that I can add my own code to make it work better than the workaround you just showed. Also, CSS isolation will not work with this current implementation. I am using it heavily in my blazor application. |
if you still want to keep the blazor wasm project then all you need to do is to make a blazor wasm project and add reference to the shared project and add the wwwroot to the wasm project. of course it will break since the blazor project is not a wasm project anymore so you need to create it again. css isolation will work if you change the css file name in the index.html with the wpf assembly name and thats why we need to keep the index html separate for each wasm and wpf project. eg if your shared project is called |
No, when CSS isolation is used, it is generated in the |
one more thing that is important is you need to remove the |
I don't think the PS: I am not looking for workarounds, I need a real fix. |
mind you that this is still in a very early preview of blazor desktop so expect to do some workarounds to make things work. it is very good to me that at least things are working now but sure it would be nice if they could deliver things like project template, better hot reload, etc later on. about wwwroot for me it already make sense to me that each project such as wpf and wasm have their own wwwroot folder. with this configuration you can share the logic and razor files to not only wpf and wasm but to blazor server (which does not even have index.html), also maui later on when it is released. if you still need to copy your wwwroot manually to output folder then you need to change the properties to Copy if Newer as shown here. |
I know it is early. I am creating this issue just so that they can fix this in time before the final release. But at the end its their call what they want to do with it. For |
Hi, I know this is an older issue now, but I got the repro project working on my machine by doing the following:
The reason that (2) is needed is that the logic for making static web assets such as CSS/HTML/JS available is all part of the Razor SDK. By referencing the SDK, that brings in the MSBuild targets that place files in the correct location in order to be loaded by the system. If you want a totally custom way of providing static assets, we recently added that feature in this PR: #3191 |
Any idea when next preview is coming out? |
Description
I am unable to run/debug WPF application from Visual Studio when hosting a blazor application from another project because index.html does not exist in the output folder. I want to re-use the blazor project from my web application.
WPF's
BlazorWebView
usesPhysicalFileProvider
to the folder of the file pointed to by the value ofHostPage
property. But that file is in another project and is not copied to the WPF project's output folder. If provide path to that file then the generated isolated css file will not be loaded. It should either be customizable and/or aCompositeFileProvider
that uses all paths from the blazor project's static web assets xml file should be configured if that file exists.Steps to Reproduce
Expected Behavior
The application runs and displays my web page as it would in web browser when the blazor project is run.
Actual Behavior
DirectoryNotFoundException
is thrown pointing toBlazorWpf1\BlazorWpf1\bin\Debug\net6.0-windows\wwwroot\
Basic Information
6.0.0-preview.4.21253.5
none
net6.0-windows
Reproduction Link
BlazorWpf1.zip
Workaround
From the source of WPF WebView, I could not figure out any.
The text was updated successfully, but these errors were encountered: