diff options
author | Javier Calvarro Nelson <jacalvar@microsoft.com> | 2021-08-27 19:39:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-27 19:39:14 +0300 |
commit | 2e63715e12fbbeda76df0f4693f3f1d2edb9e49c (patch) | |
tree | c4d3ae81d32edbf3a829689e8b355879f6cf76e7 | |
parent | 7c217732be40f0b4a2d82f1de524dd97b806a3c9 (diff) |
[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.
10 files changed, 40 insertions, 10 deletions
diff --git a/src/Angular-CSharp.csproj.in b/src/Angular-CSharp.csproj.in index e94b238..cb8d864 100644 --- a/src/Angular-CSharp.csproj.in +++ b/src/Angular-CSharp.csproj.in @@ -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> diff --git a/src/React-CSharp.csproj.in b/src/React-CSharp.csproj.in index 6b0e808..04554a0 100644 --- a/src/React-CSharp.csproj.in +++ b/src/React-CSharp.csproj.in @@ -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> diff --git a/src/content/Angular-CSharp/.template.config/dotnetcli.host.json b/src/content/Angular-CSharp/.template.config/dotnetcli.host.json index 63792e4..d961706 100644 --- a/src/content/Angular-CSharp/.template.config/dotnetcli.host.json +++ b/src/content/Angular-CSharp/.template.config/dotnetcli.host.json @@ -19,6 +19,9 @@ "iisHttpsPort": { "isHidden": true }, + "NoSpaFrontEnd":{ + "isHidden": true + }, "ExcludeLaunchSettings": { "longName": "exclude-launch-settings", "shortName": "" diff --git a/src/content/Angular-CSharp/.template.config/template.json b/src/content/Angular-CSharp/.template.config/template.json index 94d7e28..31b9e39 100644 --- a/src/content/Angular-CSharp/.template.config/template.json +++ b/src/content/Angular-CSharp/.template.config/template.json @@ -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", diff --git a/src/content/Angular-CSharp/Pages/Shared/_LoginPartial.cshtml b/src/content/Angular-CSharp/Pages/Shared/_LoginPartial.cshtml index f2884db..306bec9 100644 --- a/src/content/Angular-CSharp/Pages/Shared/_LoginPartial.cshtml +++ b/src/content/Angular-CSharp/Pages/Shared/_LoginPartial.cshtml @@ -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="/"> diff --git a/src/content/Angular-CSharp/Properties/launchSettings.json b/src/content/Angular-CSharp/Properties/launchSettings.json index 0b901aa..d5ccfad 100644 --- a/src/content/Angular-CSharp/Properties/launchSettings.json +++ b/src/content/Angular-CSharp/Properties/launchSettings.json @@ -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 } } } diff --git a/src/content/React-CSharp/.template.config/dotnetcli.host.json b/src/content/React-CSharp/.template.config/dotnetcli.host.json index 63792e4..d961706 100644 --- a/src/content/React-CSharp/.template.config/dotnetcli.host.json +++ b/src/content/React-CSharp/.template.config/dotnetcli.host.json @@ -19,6 +19,9 @@ "iisHttpsPort": { "isHidden": true }, + "NoSpaFrontEnd":{ + "isHidden": true + }, "ExcludeLaunchSettings": { "longName": "exclude-launch-settings", "shortName": "" diff --git a/src/content/React-CSharp/.template.config/template.json b/src/content/React-CSharp/.template.config/template.json index 5fcab90..eceaf8d 100644 --- a/src/content/React-CSharp/.template.config/template.json +++ b/src/content/React-CSharp/.template.config/template.json @@ -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", diff --git a/src/content/React-CSharp/Pages/Shared/_LoginPartial.cshtml b/src/content/React-CSharp/Pages/Shared/_LoginPartial.cshtml index 8e7fccb..306bec9 100644 --- a/src/content/React-CSharp/Pages/Shared/_LoginPartial.cshtml +++ b/src/content/React-CSharp/Pages/Shared/_LoginPartial.cshtml @@ -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="/"> diff --git a/src/content/React-CSharp/Properties/launchSettings.json b/src/content/React-CSharp/Properties/launchSettings.json index cf8837d..27c20bd 100644 --- a/src/content/React-CSharp/Properties/launchSettings.json +++ b/src/content/React-CSharp/Properties/launchSettings.json @@ -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 } } } |