Repository navigation
|
I have a browser-wasm project using .NET11.0 rc1 without blazor. It would be nice if I could move the wwwroot from the root to a subdirectory for better managing, but I didn't find any related MSBuild Property. Is there any solution? |
Replies: 3 comments 1 reply
|
There's no MSBuild property for it. The static web assets SDK hardcodes the folder: ResolveProjectStaticWebAssets in Microsoft.NET.Sdk.StaticWebAssets.targets calls DefineStaticWebAssets with RelativePathPattern="wwwroot/**" and ContentRoot="$(MSBuildProjectDirectory)\wwwroot". You can still keep the files somewhere else. DefineStaticWebAssets matches on an item's Link (or TargetPath) metadata before its physical path, and ContentRoot can be set per item. So you can map another folder in as if it were wwwroot:
(web is whatever subfolder you want.) Delete the old wwwroot folder, or the default glob will pick it up too. The files still get served from the app root and published to wwwroot/ in the output, because that output path is fixed as well. |
|
I got an integrity error for main.js after I added the code below, but everything was fine when I restarted my VS. Thanks! |
|
The integrity error could be fixed with$(MSBuildProjectDirectory)\Platform\Browser\wwwroot. The runtime will find files in the $(MSBuildProjectDirectory)\wwwroot without it and send empty response with 200 OK and cause integrity error. Restarting VS above is possibly a cache error that temporarily fixes this. |
There's no MSBuild property for it. The static web assets SDK hardcodes the folder: ResolveProjectStaticWebAssets in Microsoft.NET.Sdk.StaticWebAssets.targets calls DefineStaticWebAssets with RelativePathPattern="wwwroot/**" and ContentRoot="$(MSBuildProjectDirectory)\wwwroot".
You can still keep the files somewhere else. DefineStaticWebAssets matches on an item's Link (or TargetPath) metadata before its physical path, and ContentRoot can be set per item. So you can map another folder in as if it were wwwroot:
(web is whatever subfolder you want.) Delete the old wwwroot folder, or the default glob will pick it up too. The files still get served from the app root and published to wwwroot…