[Spa] Introduce NoSpaFrontEnd option for testing purposes (#15)

[Spa] Introduces NoSpaFrontEnd (hidden) option for testing purposes (#15)

In order for us to ensure the templates are up to date with the latest changes on the .NET runtime, we want to have some tests that are able to build them (and run the server part independently) if necessary.

For that matter, we are introducing the NoSpaFrontEnd option which is hidden from the users and that can be specified in tests to remove all integration with the SPA frontend.

We will continue droping the files on disk, but there will be no npm restore during build nor we will try to launch the SPA proxy when the app launches.

We will have some tests on the ASP.NET Core repo that install the templates package produced by the repo and build the templates to at least catch build breaks that changes on ASP.NET Core can cause.
This commit is contained in:
Javier Calvarro Nelson 2021-08-27 18:39:14 +02:00 коммит произвёл GitHub
Родитель 7c217732be
Коммит 2e63715e12
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 40 добавлений и 10 удалений

Просмотреть файл

@ -4,11 +4,13 @@
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<!--#if (!NoSpaFrontEnd) -->
<SpaRoot>ClientApp\</SpaRoot>
<SpaProxyServerUrl Condition="'$(RequiresHttps)' == 'True'">https://localhost:5002</SpaProxyServerUrl>
<SpaProxyServerUrl Condition="'$(RequiresHttps)' != 'True'">http://localhost:5002</SpaProxyServerUrl>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<!--#endif -->
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
@ -28,6 +30,7 @@
<ItemGroup Condition=" '$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' != 'True' ">
<None Update="app.db" CopyToOutputDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
</ItemGroup>
<!--#if (!NoSpaFrontEnd) -->
<ItemGroup>
<!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
@ -62,5 +65,5 @@
</ResolvedFileToPublish>
</ItemGroup>
</Target>
<!--#endif -->
</Project>

Просмотреть файл

@ -6,13 +6,14 @@
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<!--#if (!NoSpaFrontEnd) -->
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<SpaProxyServerUrl Condition="'$(RequiresHttps)' == 'True'">https://localhost:5002</SpaProxyServerUrl>
<SpaProxyServerUrl Condition="'$(RequiresHttps)' != 'True'">http://localhost:5002</SpaProxyServerUrl>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<!--#endif -->
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
@ -32,6 +33,7 @@
<ItemGroup Condition=" '$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' != 'True' ">
<None Update="app.db" CopyToOutputDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
</ItemGroup>
<!--#if (!NoSpaFrontEnd) -->
<ItemGroup>
<!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
@ -66,5 +68,5 @@
</ResolvedFileToPublish>
</ItemGroup>
</Target>
<!--#endif -->
</Project>

Просмотреть файл

@ -19,6 +19,9 @@
"iisHttpsPort": {
"isHidden": true
},
"NoSpaFrontEnd":{
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""

Просмотреть файл

@ -113,7 +113,12 @@
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
},
"NoSpaFrontEnd": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Avoids adding any of the node/spa files. Used for testing only."
},
"kestrelHttpPort": {
"type": "parameter",
"datatype": "integer",

Просмотреть файл

@ -4,7 +4,7 @@
@inject UserManager<ApplicationUser> UserManager
@{
string returnUrl = null;
string? returnUrl = null;
var query = ViewContext.HttpContext.Request.Query;
if (query.ContainsKey("returnUrl"))
{
@ -16,7 +16,7 @@
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity!.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/">

Просмотреть файл

@ -22,7 +22,9 @@
//#endif
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
//#if(!NoSpaFrontEnd)
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
//#endif
}
},
"IIS Express": {
@ -30,7 +32,9 @@
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
//#if(!NoSpaFrontEnd)
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
//#endif
}
}
}

Просмотреть файл

@ -19,6 +19,9 @@
"iisHttpsPort": {
"isHidden": true
},
"NoSpaFrontEnd":{
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""

Просмотреть файл

@ -115,6 +115,12 @@
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
},
"NoSpaFrontEnd": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Avoids adding any of the node/spa files. Used for testing only."
},
"kestrelHttpPort": {
"type": "parameter",
"datatype": "integer",

Просмотреть файл

@ -4,7 +4,7 @@
@inject UserManager<ApplicationUser> UserManager
@{
string returnUrl = null;
string? returnUrl = null;
var query = ViewContext.HttpContext.Request.Query;
if (query.ContainsKey("returnUrl"))
{
@ -16,7 +16,7 @@
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity!.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/">

Просмотреть файл

@ -22,7 +22,9 @@
//#endif
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
//#if(!NoSpaFrontEnd)
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
//#endif
}
},
"IIS Express": {
@ -30,7 +32,9 @@
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
//#if(!NoSpaFrontEnd)
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
//#endif
}
}
}