-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Configurable wwwroot for StaticWebAssets #34178
base: main
Are you sure you want to change the base?
Conversation
Thanks for your PR, @maraf. |
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid adding an extra test project for this?
@@ -66,6 +66,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<!-- Wire-up static web assets --> | |||
<PropertyGroup> | |||
<ResolveStaticWebAssetsInputsDependsOn> | |||
_EnsureStaticWebAssetRootPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine if we don't block people from changing this. But if we do, this should probably be in ResolveStaticWebAssetsConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember you mentioned there are places where this is hardcoded in blazor codebase
<!-- Publish everything under wwwroot, all JSON files, all config files and all Razor files --> | ||
<Content Include="wwwroot\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" /> | ||
<!-- Publish everything under @(StaticWebAssetSourcePath), all JSON files, all config files and all Razor files --> | ||
<Content Include="%(StaticWebAssetSourcePath->Identity)\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this just be $(StaticWebAssetRootPath)\**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my previous approach. With the current approach (which doesn't work yet :/ ) I'm trying to be able to have a nuget package with public
folder, but target app with client
folder. So that libraries/packages could be shared (if the actual code make sense to be shared).
Does it make sense to you?
Unfortunatelly this style of msbuild globing doesn't work outside of a target
<!-- Input and output configuration --> | ||
<PropertyGroup> | ||
<StaticWebAssetRootPath Condition="'$(StaticWebAssetRootPath)' == ''">wwwroot</StaticWebAssetRootPath> | ||
</PropertyGroup> | ||
<ItemGroup Condition="@(StaticWebAssetSourcePath->Count()) == 0"> | ||
<StaticWebAssetSourcePath Include="wwwroot" /> | ||
</ItemGroup> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need to make these input sources configurable? I would rather avoid this, as they are web specific. If people want to follow different conventions, that can be done in the project file directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intention described in the comment above..
for (int i = 0; i < patterns.Length; i++) | ||
matcher.AddInclude(patterns[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brace yourself 😄
@@ -17,7 +17,7 @@ public class DiscoverStaticWebAssets : Task | |||
public ITaskItem[] Candidates { get; set; } | |||
|
|||
[Required] | |||
public string Pattern { get; set; } | |||
public ITaskItem[] Patterns { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid taking multiple patterns here? This can be called via MSBuild batching from outside instead, and simplifies things.
The goal of this PR is to be able to override both input and output folder of static web assets. We need such configuration for WebAssembly template targeting nodejs/v8/etc. The
wwwroot
is not correct name in this context.StaticWebAssetRootPath
(defaultwwwroot
) allowing to configure target folder for static web assetsStaticWebAssetSourcePath
(defaultwwwroot
) allowing to configure source folder(s) static web assetssrc\Assets\TestProjects\RazorAppWithP2PReferenceWithSwaPaths
StaticWebAssetRootPath
is not wwwroot for Blazor Wasm project