Blazor template fixes (#10770)

* Invert UseLocalDB condition in template

* Replace UseBlazorClientSideFiles with UseClientSideBlazorFiles

* Add NotFoundContent to client-side templates, and make all consistent

* In client-side templates, remove references to MyGet feeds as they are no longer updated

* Workaround for lack of conditionals in .razor: Two separate versions of MainLayout.razor

* Workaround for lack of conditionals in .razor: Four variants of LoginDisplay.*.razor

* Fix launchSettings for Windows auth
This commit is contained in:
Steve Sanderson 2019-06-04 16:38:41 +01:00 committed by Artak
parent 851a1eeb39
commit 55b310d16b
22 changed files with 112 additions and 77 deletions

View File

@ -11,15 +11,11 @@
<Target Name="SetTemplateJsonSymbolReplacements">
<PropertyGroup>
<IncludeCustomRestoreSourcesValue>true</IncludeCustomRestoreSourcesValue>
<IncludeCustomRestoreSourcesValue Condition=" '$(IsFinalBuild)' == 'true' AND ('$(PreReleaseLabel)' == 'servicing' OR '$(PreReleaseLabel)' == 'rtm')">false</IncludeCustomRestoreSourcesValue>
<!--
Properties here will be injected into the template config *.json files
during the build, replacing tokens of the form ${PropertyName}
-->
<GeneratedContentProperties>
IncludeCustomRestoreSources=$(IncludeCustomRestoreSourcesValue);
TemplateBlazorVersion=$(PackageVersion);
TemplateComponentsVersion=$(ComponentsPackageVersion);
RepositoryCommit=$(SourceRevisionId);

View File

@ -71,12 +71,6 @@
"type": "bind",
"binding": "HostIdentifier"
},
"IncludeCustomRestoreSourcesSymbol": {
"type": "parameter",
"datatype": "bool",
"description": "If set, includes restore sources for the Blazor MyGet feed.",
"defaultValue": "${IncludeCustomRestoreSources}"
},
"TemplateBlazorVersionSymbol": {
"type": "parameter",
"datatype": "string",

View File

@ -1 +1,5 @@
<Router AppAssembly="typeof(Program).Assembly" />
<Router AppAssembly="typeof(Program).Assembly">
<NotFoundContent>
<p>Sorry, there's nothing at this address.</p>
</NotFoundContent>
</Router>

View File

@ -3,10 +3,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Exe</OutputType>
<RestoreAdditionalProjectSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

View File

@ -2,10 +2,6 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RestoreAdditionalProjectSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

View File

@ -33,7 +33,7 @@ namespace BlazorHosted_CSharp.Server
app.UseBlazorDebugging();
}
app.UseBlazorClientSideFiles<Client.Startup>();
app.UseClientSideBlazorFiles<Client.Startup>();
app.UseRouting();

View File

@ -43,12 +43,6 @@
"type": "bind",
"binding": "HostIdentifier"
},
"IncludeCustomRestoreSourcesSymbol": {
"type": "parameter",
"datatype": "bool",
"description": "If set, includes restore sources for the Blazor MyGet feed.",
"defaultValue": "${IncludeCustomRestoreSources}"
},
"TemplateBlazorVersionSymbol": {
"type": "parameter",
"datatype": "string",

View File

@ -3,10 +3,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<RestoreAdditionalProjectSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>

View File

@ -44,12 +44,6 @@
"type": "bind",
"binding": "HostIdentifier"
},
"IncludeCustomRestoreSourcesSymbol": {
"type": "parameter",
"datatype": "bool",
"description": "If set, includes restore sources for the Blazor MyGet feed.",
"defaultValue": "${IncludeCustomRestoreSources}"
},
"TemplateBlazorVersionSymbol": {
"type": "parameter",
"datatype": "string",

View File

@ -1 +1,5 @@
<Router AppAssembly="typeof(Program).Assembly" />
<Router AppAssembly="typeof(Program).Assembly">
<NotFoundContent>
<p>Sorry, there's nothing at this address.</p>
</NotFoundContent>
</Router>

View File

@ -2,10 +2,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RestoreAdditionalProjectSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

View File

@ -2,8 +2,4 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\build\dependencies.props" />
<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\build\sources.props" />
<PropertyGroup>
<IncludeCustomRestoreSourcesSymbol>true</IncludeCustomRestoreSourcesSymbol>
</PropertyGroup>
</Project>

View File

@ -10,7 +10,7 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">RazorComponentsWeb_CSharp</RootNamespace>
</PropertyGroup>
<!--#if (IndividualLocalAuth && UseLocalDB) -->
<!--#if (IndividualLocalAuth && !UseLocalDB) -->
<ItemGroup>
<None Update="app.db" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

View File

@ -67,8 +67,65 @@
},
{
"condition": "(NoAuth)",
"rename": {
"Shared/MainLayout.NoAuth.razor": "Shared/MainLayout.razor"
},
"exclude": [
"Shared/LoginDisplay.razor"
"Shared/LoginDisplay.*.razor",
"Shared/MainLayout.Auth.razor"
]
},
{
"condition": "(!NoAuth)",
"rename": {
"Shared/MainLayout.Auth.razor": "Shared/MainLayout.razor"
},
"exclude": [
"Shared/MainLayout.NoAuth.razor"
]
},
{
"condition": "(IndividualLocalAuth)",
"rename": {
"Shared/LoginDisplay.IndividualLocalAuth.razor": "Shared/LoginDisplay.razor"
},
"exclude": [
"Shared/LoginDisplay.IndividualB2CAuth.razor",
"Shared/LoginDisplay.OrganizationalAuth.razor",
"Shared/LoginDisplay.WindowsAuth.razor"
]
},
{
"condition": "(IndividualB2CAuth)",
"rename": {
"Shared/LoginDisplay.IndividualB2CAuth.razor": "Shared/LoginDisplay.razor"
},
"exclude": [
"Shared/LoginDisplay.IndividualLocalAuth.razor",
"Shared/LoginDisplay.OrganizationalAuth.razor",
"Shared/LoginDisplay.WindowsAuth.razor"
]
},
{
"condition": "(OrganizationalAuth)",
"rename": {
"Shared/LoginDisplay.OrganizationalAuth.razor": "Shared/LoginDisplay.razor"
},
"exclude": [
"Shared/LoginDisplay.IndividualLocalAuth.razor",
"Shared/LoginDisplay.IndividualB2CAuth.razor",
"Shared/LoginDisplay.WindowsAuth.razor"
]
},
{
"condition": "(WindowsAuth)",
"rename": {
"Shared/LoginDisplay.WindowsAuth.razor": "Shared/LoginDisplay.razor"
},
"exclude": [
"Shared/LoginDisplay.IndividualLocalAuth.razor",
"Shared/LoginDisplay.IndividualB2CAuth.razor",
"Shared/LoginDisplay.OrganizationalAuth.razor"
]
}
]

View File

@ -1,7 +1,6 @@
<CascadingAuthenticationState>
<Router AppAssembly="typeof(Startup).Assembly">
<NotFoundContent>
<h3>Page not found</h3>
<p>Sorry, there's nothing at this address.</p>
</NotFoundContent>
</Router>

View File

@ -1,7 +1,12 @@
{
"iisSettings": {
//#if (WindowsAuth)
"windowsAuthentication": true,
"anonymousAuthentication": false,
//#else
"windowsAuthentication": false,
"anonymousAuthentication": true,
//#endif
"iisExpress": {
"applicationUrl": "http://localhost:8080",
//#if(RequiresHttps)

View File

@ -1,15 +1,3 @@
@*#if (IndividualLocalAuth)
<AuthorizeView>
<Authorized>
<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
<a href="Identity/Account/LogOut">Log out</a>
</Authorized>
<NotAuthorized>
<a href="Identity/Account/Register">Register</a>
<a href="Identity/Account/Login">Log in</a>
</NotAuthorized>
</AuthorizeView>
#elseif (IndividualB2CAuth)
@using Microsoft.AspNetCore.Authentication.AzureADB2C.UI
@using Microsoft.Extensions.Options
@inject IOptionsMonitor<AzureADB2COptions> AzureADB2COptions
@ -40,18 +28,3 @@
canEditProfile = !string.IsNullOrEmpty(options.EditProfilePolicyId);
}
}
#elseif (OrganizationalAuth)
<AuthorizeView>
<Authorized>
Hello, @context.User.Identity.Name!
<a href="AzureAD/Account/SignOut">Log out</a>
</Authorized>
<NotAuthorized>
<a href="AzureAD/Account/SignIn">Log in</a>
</NotAuthorized>
</AuthorizeView>
#elseif (WindowsAuth)
<AuthorizeView>
Hello, @context.User.Identity.Name!
</AuthorizeView>
#endif*@

View File

@ -0,0 +1,10 @@
<AuthorizeView>
<Authorized>
<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
<a href="Identity/Account/LogOut">Log out</a>
</Authorized>
<NotAuthorized>
<a href="Identity/Account/Register">Register</a>
<a href="Identity/Account/Login">Log in</a>
</NotAuthorized>
</AuthorizeView>

View File

@ -0,0 +1,9 @@
<AuthorizeView>
<Authorized>
Hello, @context.User.Identity.Name!
<a href="AzureAD/Account/SignOut">Log out</a>
</Authorized>
<NotAuthorized>
<a href="AzureAD/Account/SignIn">Log in</a>
</NotAuthorized>
</AuthorizeView>

View File

@ -0,0 +1,3 @@
<AuthorizeView>
Hello, @context.User.Identity.Name!
</AuthorizeView>

View File

@ -6,9 +6,7 @@
<div class="main">
<div class="top-row px-4">
@*#if (!NoAuth)
<LogInDisplay />
#endif*@
<a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank">About</a>
</div>

View File

@ -0,0 +1,15 @@
@inherits LayoutComponentBase
<div class="sidebar">
<NavMenu />
</div>
<div class="main">
<div class="top-row px-4">
<a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank">About</a>
</div>
<div class="content px-4">
@Body
</div>
</div>