Referencing Static Files in a Razor Class Library
Answered
I have a Razor Class Library project in my solution to hold common files and components that are used in multiple places in my solution. When I reference static files in the RCL (css, js, etc) and run my project in Visual Studio everything works fine, but when I try to use Rider I get a 404 error for the references to the RCL files. The project that is referencing the RCL is a Blazor Server project.
Any thoughts on what I could be missing here? Does Rider support this?
Thanks,
Greg
Please sign in to leave a comment.
Hello Greg,
At the current moment the mentioned functionality is not completely supported, but it should be OK in the upcoming 21.2, please follow this issue for details: RIDER-45261.
Thanks for the update Olga, I'll be eagerly awaiting 21.2.
Hi again Olga,
I've installed 21.2 EAP5 and the components from my Razor Class Library still aren't working properly. The issue that you referenced seems to mostly refer to Blazor WASM apps and mine is a Blazor Server app. Does the issue still apply?
Thanks,
Greg
Hi Olga,
I'm still having issues in 21.2 EAP 8. Can you give me an update on this?
Thanks,
Greg
Hello Greg,
There is a possible solution described on https://stackoverflow.com/questions/51610513/can-razor-class-library-pack-static-files-js-css-etc-too. If nothing can help, could you please share your solution (for example via the https://uploads.jetbrains.com/ service)?
K.R.
Sofia
Hi Sofia, thanks for getting back to me. The site that you linked above is one that I used in the past to get things working in Visual Studio. Unfortunately I can't share my solution as it is a commercial product. I have attempted to create a sample solution with the same setup as my solution and it is working fine in Rider. This suggests to me that there is a setting somewhere that I changed as my current solution works fine in Visual Studio, but not in Rider and the sample works in both. What is also interesting is that when I run the solution in Rider I get a 404 on the objects in my Razor Class Library as well as the [AssemblyName].Styles.css bundle file.
Not sure what I am missing but it doesn't seem to be anything on the Rider side. I'll keep things up to date here if I am able to find a resolution.
Thanks again,
Greg
Hello Greg,
Unfortunately, I had no luck in reproducing this issue. But it is a very much interesting case and it would be great if you could share your csproj files of your Blazor Server App and of Razor Class Library. One can use https://uploads.jetbrains.com/ for sharing files with JetBrains.
K.R.
Sofia
Hi Sofia
Hi Greg,
Great!
Thank you for keeping me posted.
K.R.
Sofia