Sharing Razor pages between projects
I've spent too much time on this, so to save others my pain. Basically, you can get it to work, but you don't get access to the Viewbag/Model if you go the embedded resource route
Resources were the following:
Precompile using RazorGenerator: This solution was also promoted by this page and this upcoming book from o'Reilly. Didn't work because there's a bug compiling class libraries.
Precompile to Embedded resource and use a custom ViewEngine as described by Stack overflow answer (Duplicate of this). This does work and you can use the shared Views, but as noted above, you don't get to use the @ViewBag or indeed the @Model. Which somewhat defeats the whole exercise.
We can't be the only people who what to have multiple ASP.NET MVC projects and share Views between them.
There's also the option of just pulling in the Views via Nuget but that requires a private Nuget feed which we don't have set up.
Frustrating
Next, set up a Visual Studio Template to pull the latest version of the Views off the network on initializing a new project.
- Previous: Getting it wrong.
- Next: Fancy Copy and Paste