Closed chucker closed 2 years ago
(Is my assumption even correct? Is it necessary/recommended, in a hosted project, to add all client project's references to the server project so that static assets are available at runtime? I'm pretty sure I was told that that's the recommended way.)
@chucker thanks for contacting us.
It's not clear what might be going on, but it seems like an issue on the package you are mentioning. Dependencies from the client flow to the server provided you have a project reference from the server to the client project, so this is something specific in the package you are referencing.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am adding packages (dependencies) to my Blazor WASM hosted project, and they work at design time, but not at runtime. This happens because I often forget that the same dependencies need to be added to the server project as well. There are no (good) diagnostics to indicate this.
For example, given a Blazor WASM hosted solution with the projects MyProject.Client, MyProject.Server, MyProject.Shared, adding
<PackageReference Include="Toolbelt.Blazor.HotKeys" Version="12.0.1" />
to the client project will appear to work correctly in the.razor
and.cs
files: IntelliSense discovers the project's public members. However, at runtime, nothing happens — because I need to add the same dependency to the server project so that assets get copied correctly.Describe the solution you'd like
Ideally, IMHO, the server project should pull in all dependencies of the client project.
But failing that, an analyzer would be great. If a project with SDK
Microsoft.NET.Sdk.Web
(the "server") depends on a project with SDKMicrosoft.NET.Sdk.BlazorWebAssembly
(the "client"), and that project in turn has package references which 1) contain static assets and 2) aren't also referenced by the server, an analyzer should warn about that.Maybe this analyzer should regard project property
BlazorStaticAssetsIgnore
with a semicolon-separated list of dependencies where the analyzer should not warn, for cases where users explicitly want to customize their assets.Additional context
(This has probably been discussed before, but I couldn't find it.)