-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Configurable wwwroot for StaticWebAssets #34178
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <AddRazorSupportForMvc>true</AddRazorSupportForMvc> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <!-- We don't want to run build server when not running as tests. --> | ||
| <UseRazorBuildServer>false</UseRazorBuildServer> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
| </ItemGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using System; | ||
| using ClassLibrary; | ||
|
|
||
| namespace AnotherClassLib | ||
| { | ||
| public class Class2 | ||
| { | ||
| public void Method() | ||
| { | ||
| Console.WriteLine(typeof(Class1)); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @{ var message = "Hello world";} | ||
| @message |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @using ClassLibrary | ||
| @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| div.fluent { display: inline-block } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| (function () { | ||
| document.getElementById('project-direct-dep').innerHTML = 'project-direct-dep'; | ||
| })() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <!-- We don't want to run build server when not running as tests. --> | ||
| <UseRazorBuildServer>false</UseRazorBuildServer> | ||
| <StaticWebAssetRootPath>client</StaticWebAssetRootPath> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj" /> | ||
| <ProjectReference Include="..\AnotherClassLib\AnotherClassLib.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.5.002.0 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppWithP2PReference", "AppWithP2PReference.csproj", "{8B39F50A-A007-48AE-AC28-7C105B1BE86E}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {8B39F50A-A007-48AE-AC28-7C105B1BE86E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {8B39F50A-A007-48AE-AC28-7C105B1BE86E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {8B39F50A-A007-48AE-AC28-7C105B1BE86E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {8B39F50A-A007-48AE-AC28-7C105B1BE86E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {4A225483-0649-465C-B592-89D92B3A3A96} | ||
| EndGlobalSection | ||
| EndGlobal |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using System; | ||
|
|
||
| namespace AppWithP2PReference.Models | ||
| { | ||
| public class ErrorViewModel | ||
| { | ||
| public string RequestId { get; set; } | ||
|
|
||
| public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| | ||
| namespace AppWithP2PReference | ||
| { | ||
| public class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| // Just make sure we have a reference to the MvcShim | ||
| var t = typeof(Microsoft.AspNetCore.Mvc.IActionResult); | ||
| System.Console.WriteLine(t.FullName); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| @{ | ||
| ViewData["Title"] = "About"; | ||
| } | ||
| <h2>@ViewData["Title"]</h2> | ||
| <h3>@ViewData["Message"]</h3> | ||
|
|
||
| <p>Use this area to provide additional information.</p> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @{ | ||
| ViewData["Title"] = "Contact"; | ||
| } | ||
| <h2>@ViewData["Title"]</h2> | ||
| <h3>@ViewData["Message"]</h3> | ||
|
|
||
| <address> | ||
| One Microsoft Way<br /> | ||
| Redmond, WA 98052-6399<br /> | ||
| <abbr title="Phone">P:</abbr> | ||
| 425.555.0100 | ||
| </address> | ||
|
|
||
| <address> | ||
| <strong>Support:</strong> <a href="mailto:[email protected]">Support@example.com</a><br /> | ||
| <strong>Marketing:</strong> <a href="mailto:[email protected]">Marketing@example.com</a> | ||
| </address> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| @{ | ||
| ViewData["Title"] = "Home Page"; | ||
| } | ||
|
|
||
| <div> | ||
| <p>Some test content.</p> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <environment include="Development"> | ||
| <script src="~/lib/jquery-validation/dist/jquery.validate.js"></script> | ||
| <script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script> | ||
| </environment> | ||
| <environment exclude="Development"> | ||
| <script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js" | ||
| asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js" | ||
| asp-fallback-test="window.jQuery && window.jQuery.validator" | ||
| crossorigin="anonymous" | ||
| integrity="sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k"> | ||
| </script> | ||
| <script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js" | ||
| asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js" | ||
| asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive" | ||
| crossorigin="anonymous" | ||
| integrity="sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH"> | ||
| </script> | ||
| </environment> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| @using AppWithP2PReference | ||
| @using AppWithP2PReference.Models | ||
| @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| @{ | ||
| Layout = "_Layout"; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace ClassLibrary | ||
| { | ||
| public class Class1 | ||
| { | ||
| // Just here so this assembly has some compilation inputs. | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
| <PropertyGroup> | ||
| <AddRazorSupportForMvc>true</AddRazorSupportForMvc> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <Copyright>© Microsoft</Copyright> | ||
| <Product>Razor Test</Product> | ||
| <Company>Microsoft</Company> | ||
| <Description>ClassLibrary Description</Description> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <!-- We don't want to run build server when not running as tests. --> | ||
| <UseRazorBuildServer>false</UseRazorBuildServer> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
| <StaticWebAssetSourcePath Include="public" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <p>Hello from razor</p> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| p { | ||
| font-size: bold; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>@ViewData["Title"] - SimpleMvc</title> | ||
|
|
||
| <environment include="Development"> | ||
| <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" /> | ||
| <link rel="stylesheet" href="~/css/site.css" /> | ||
| </environment> | ||
| <environment exclude="Development"> | ||
| <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css" | ||
| asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css" | ||
| asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" /> | ||
| <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" /> | ||
| </environment> | ||
| </head> | ||
| <body> | ||
| <nav class="navbar navbar-inverse navbar-fixed-top"> | ||
| <div class="container"> | ||
| <div class="navbar-header"> | ||
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
| <span class="sr-only">Toggle navigation</span> | ||
| <span class="icon-bar"></span> | ||
| <span class="icon-bar"></span> | ||
| <span class="icon-bar"></span> | ||
| </button> | ||
| <a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">SimpleMvc</a> | ||
| </div> | ||
| <div class="navbar-collapse collapse"> | ||
| <ul class="nav navbar-nav"> | ||
| <li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li> | ||
| <li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li> | ||
| <li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </nav> | ||
| <div class="container body-content"> | ||
| @RenderBody() | ||
| <hr /> | ||
| <footer> | ||
| <p>© 2017 - SimpleMvc</p> | ||
| </footer> | ||
| </div> | ||
|
|
||
| <environment include="Development"> | ||
| <script src="~/lib/jquery/dist/jquery.js"></script> | ||
| <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script> | ||
| <script src="~/js/site.js" asp-append-version="true"></script> | ||
| </environment> | ||
| <environment exclude="Development"> | ||
| <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js" | ||
| asp-fallback-src="~/lib/jquery/dist/jquery.min.js" | ||
| asp-fallback-test="window.jQuery" | ||
| crossorigin="anonymous" | ||
| integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk"> | ||
| </script> | ||
| <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js" | ||
| asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js" | ||
| asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal" | ||
| crossorigin="anonymous" | ||
| integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"> | ||
| </script> | ||
| <script src="~/js/site.min.js" asp-append-version="true"></script> | ||
| </environment> | ||
|
|
||
| @RenderSection("Scripts", required: false) | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @using ClassLibrary | ||
| @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| (function () { | ||
| document.getElementById('project-transitive-dep').innerHTML = 'project-transitive-dep'; | ||
| })() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 commentThe 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 commentThe 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 |
||
| $(ResolveStaticWebAssetsInputsDependsOn); | ||
| _ResolveBlazorWasmOutputs; | ||
| </ResolveStaticWebAssetsInputsDependsOn> | ||
|
|
@@ -85,6 +86,10 @@ Copyright (c) .NET Foundation. All rights reserved. | |
|
|
||
| <Target Name="_BlazorWasmNativeForBuild" DependsOnTargets="_GatherBlazorFilesToBuild;WasmBuildApp" Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'" /> | ||
|
|
||
| <Target Name="_EnsureStaticWebAssetRootPath"> | ||
| <Error Message="The 'StaticWebAssetRootPath' property can't be changed for Blazor WebAssembly project" Condition="'$(StaticWebAssetRootPath)' != 'wwwroot'" /> | ||
| </Target> | ||
|
|
||
| <Target Name="_GatherBlazorFilesToBuild"> | ||
| <ItemGroup> | ||
| <WasmAssembliesToBundle Condition="'%(WasmAssembliesToBundle.FileName)' == 'Microsoft.JSInterop.WebAssembly'" AOT_InternalForceToInterpret="true" /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,14 @@ Copyright (c) .NET Foundation. All rights reserved. | |
| --> | ||
| <Project ToolsVersion="14.0"> | ||
|
|
||
| <!-- Input and output configuration --> | ||
| <PropertyGroup> | ||
| <StaticWebAssetRootPath Condition="'$(StaticWebAssetRootPath)' == ''">wwwroot</StaticWebAssetRootPath> | ||
| </PropertyGroup> | ||
| <ItemGroup Condition="@(StaticWebAssetSourcePath->Count()) == 0"> | ||
| <StaticWebAssetSourcePath Include="wwwroot" /> | ||
| </ItemGroup> | ||
|
|
||
|
Comment on lines
+14
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Intention described in the comment above.. |
||
| <!-- Properties for supporting static content --> | ||
| <PropertyGroup> | ||
|
|
||
|
|
@@ -22,15 +30,15 @@ Copyright (c) .NET Foundation. All rights reserved. | |
| <DefaultItemExcludes>$(DefaultItemExcludes);**\node_modules\**;node_modules\**</DefaultItemExcludes> | ||
| <DefaultItemExcludes>$(DefaultItemExcludes);**\jspm_packages\**;jspm_packages\**</DefaultItemExcludes> | ||
| <DefaultItemExcludes>$(DefaultItemExcludes);**\bower_components\**;bower_components\**</DefaultItemExcludes> | ||
| <DefaultWebContentItemExcludes>$(DefaultWebContentItemExcludes);wwwroot\**</DefaultWebContentItemExcludes> | ||
| <DefaultWebContentItemExcludes>$(DefaultWebContentItemExcludes);@(StaticWebAssetSourcePath->'%(Identity)\**')</DefaultWebContentItemExcludes> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="'$(EnableDefaultItems)' == 'true' And '$(EnableDefaultContentItems)' == 'true' "> | ||
| <!-- 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 commentThe reason will be displayed to describe this comment to others. Learn more. Why can't this just be There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Does it make sense to you? Unfortunatelly this style of msbuild globing doesn't work outside of a target |
||
|
|
||
| <!-- Specifically support the ~/.well-known directory as per IETF RFC5785 --> | ||
| <Content Include="wwwroot\.well-known\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes)" /> | ||
| <Content Include="%(StaticWebAssetSourcePath->Identity)\.well-known\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes)" /> | ||
|
|
||
| <Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'" /> | ||
| <Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'" /> | ||
|
|
@@ -43,9 +51,9 @@ Copyright (c) .NET Foundation. All rights reserved. | |
| <Content Update="$(AppDesignerFolder)\**" CopyToPublishDirectory="Never" Condition="'$(AppDesignerFolder)' != ''"/> | ||
|
|
||
| <!-- Remove Content items from other item types (in a way that CPS understands) --> | ||
| <None Remove="wwwroot\**;**\*.json;**\*.config" /> | ||
| <Compile Remove="wwwroot\**" /> | ||
| <EmbeddedResource Remove="wwwroot\**" /> | ||
| <None Remove="%(StaticWebAssetSourcePath->Identity)\**;**\*.json;**\*.config" /> | ||
| <Compile Remove="%(StaticWebAssetSourcePath->Identity)\**" /> | ||
| <EmbeddedResource Remove="%(StaticWebAssetSourcePath->Identity)\**" /> | ||
|
|
||
| <!-- Keep track of the default content items for later to distinguish them from newly generated content items --> | ||
| <!-- It's important to keep this here so that it works well with the Web SDK --> | ||
|
|
||
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?