Merge pull request #18116 from dotnet-maestro-bot/merge/blazor-wasm-to-master
[automated] Merge branch 'blazor-wasm' => 'master'
This commit is contained in:
commit
40cd13837e
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"dotnet-serve": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-serve"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,12 +4,6 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DefaultWebContentItemExcludes>$(DefaultWebContentItemExcludes);wwwroot\**</DefaultWebContentItemExcludes>
|
<DefaultWebContentItemExcludes>$(DefaultWebContentItemExcludes);wwwroot\**</DefaultWebContentItemExcludes>
|
||||||
|
|
||||||
<!-- By default, enable auto rebuilds for debug builds. Note that the server will not enable it in production environments regardless. -->
|
|
||||||
<BlazorRebuildOnFileChange Condition="'$(Configuration)' == 'Debug' AND '$(BlazorRebuildOnFileChange)' == ''">true</BlazorRebuildOnFileChange>
|
|
||||||
|
|
||||||
<!-- By default, enable debugging for debug builds. -->
|
|
||||||
<BlazorEnableDebugging Condition="'$(Configuration)' == 'Debug' AND '$(BlazorEnableDebugging)' == ''">true</BlazorEnableDebugging>
|
|
||||||
|
|
||||||
<!-- When using IISExpress with a standalone app, there's no point restarting IISExpress after build. It slows things unnecessarily and breaks in-flight HTTP requests. -->
|
<!-- When using IISExpress with a standalone app, there's no point restarting IISExpress after build. It slows things unnecessarily and breaks in-flight HTTP requests. -->
|
||||||
<NoRestartServerOnBuild>true</NoRestartServerOnBuild>
|
<NoRestartServerOnBuild>true</NoRestartServerOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
<!-- The Blazor build code can only find your referenced assemblies if they are in the output directory -->
|
<!-- The Blazor build code can only find your referenced assemblies if they are in the output directory -->
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
|
||||||
|
<!-- By default, enable debugging for debug builds. -->
|
||||||
|
<BlazorEnableDebugging Condition="'$(Configuration)' == 'Debug' AND '$(BlazorEnableDebugging)' == ''">true</BlazorEnableDebugging>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="Blazor.MonoRuntime.targets" />
|
<Import Project="Blazor.MonoRuntime.targets" />
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.E2ETesting;
|
using Microsoft.AspNetCore.E2ETesting;
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using Templates.Test.Helpers;
|
using Templates.Test.Helpers;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -28,11 +28,11 @@ namespace Templates.Test
|
||||||
public async Task BlazorWasmStandaloneTemplate_Works()
|
public async Task BlazorWasmStandaloneTemplate_Works()
|
||||||
{
|
{
|
||||||
var project = await ProjectFactory.GetOrCreateProject("blazorstandalone", Output);
|
var project = await ProjectFactory.GetOrCreateProject("blazorstandalone", Output);
|
||||||
|
project.TargetFramework = "netstandard2.1";
|
||||||
|
|
||||||
var createResult = await project.RunDotNetNewAsync("blazorwasm");
|
var createResult = await project.RunDotNetNewAsync("blazorwasm");
|
||||||
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
|
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
|
||||||
|
|
||||||
// We can't run a published standalone app, but let's just make sure it publishes fine
|
|
||||||
var publishResult = await project.RunDotNetPublishAsync();
|
var publishResult = await project.RunDotNetPublishAsync();
|
||||||
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult));
|
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult));
|
||||||
|
|
||||||
|
|
@ -40,6 +40,18 @@ namespace Templates.Test
|
||||||
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult));
|
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult));
|
||||||
|
|
||||||
await BuildAndRunTest(project.ProjectName, project);
|
await BuildAndRunTest(project.ProjectName, project);
|
||||||
|
|
||||||
|
var publishDir = Path.Combine(project.TemplatePublishDir, project.ProjectName, "dist");
|
||||||
|
AspNetProcess.EnsureDevelopmentCertificates();
|
||||||
|
|
||||||
|
Output.WriteLine("Running dotnet serve on published output...");
|
||||||
|
using var serveProcess = ProcessEx.Run(Output, publishDir, DotNetMuxer.MuxerPathOrDefault(), "serve -S");
|
||||||
|
|
||||||
|
// Todo: Use dynamic port assignment: https://github.com/natemcmaster/dotnet-serve/pull/40/files
|
||||||
|
var listeningUri = "https://localhost:8080";
|
||||||
|
Output.WriteLine($"Opening browser at {listeningUri}...");
|
||||||
|
Browser.Navigate().GoToUrl(listeningUri);
|
||||||
|
TestBasicNavigation(project.ProjectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -70,7 +82,7 @@ namespace Templates.Test
|
||||||
if (BrowserFixture.IsHostAutomationSupported())
|
if (BrowserFixture.IsHostAutomationSupported())
|
||||||
{
|
{
|
||||||
aspNetProcess.VisitInBrowser(Browser);
|
aspNetProcess.VisitInBrowser(Browser);
|
||||||
TestBasicNavigation(project.ProjectName, serverProject);
|
TestBasicNavigation(project.ProjectName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +102,7 @@ namespace Templates.Test
|
||||||
if (BrowserFixture.IsHostAutomationSupported())
|
if (BrowserFixture.IsHostAutomationSupported())
|
||||||
{
|
{
|
||||||
aspNetProcess.VisitInBrowser(Browser);
|
aspNetProcess.VisitInBrowser(Browser);
|
||||||
TestBasicNavigation(appName, project);
|
TestBasicNavigation(appName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +110,7 @@ namespace Templates.Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TestBasicNavigation(string appName, Project project)
|
private void TestBasicNavigation(string appName)
|
||||||
{
|
{
|
||||||
// Give components.server enough time to load so that it can replace
|
// Give components.server enough time to load so that it can replace
|
||||||
// the prerendered content before we start making assertions.
|
// the prerendered content before we start making assertions.
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,7 @@ namespace Templates.Test.Helpers
|
||||||
Timeout = TimeSpan.FromMinutes(2)
|
Timeout = TimeSpan.FromMinutes(2)
|
||||||
};
|
};
|
||||||
|
|
||||||
var now = DateTimeOffset.Now;
|
EnsureDevelopmentCertificates();
|
||||||
new CertificateManager().EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1));
|
|
||||||
|
|
||||||
output.WriteLine("Running ASP.NET application...");
|
output.WriteLine("Running ASP.NET application...");
|
||||||
|
|
||||||
|
|
@ -64,6 +63,12 @@ namespace Templates.Test.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void EnsureDevelopmentCertificates()
|
||||||
|
{
|
||||||
|
var now = DateTimeOffset.Now;
|
||||||
|
new CertificateManager().EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1));
|
||||||
|
}
|
||||||
|
|
||||||
public void VisitInBrowser(IWebDriver driver)
|
public void VisitInBrowser(IWebDriver driver)
|
||||||
{
|
{
|
||||||
_output.WriteLine($"Opening browser at {ListeningUri}...");
|
_output.WriteLine($"Opening browser at {ListeningUri}...");
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,10 @@ namespace Templates.Test.Helpers
|
||||||
{
|
{
|
||||||
private const string _urls = "http://127.0.0.1:0;https://127.0.0.1:0";
|
private const string _urls = "http://127.0.0.1:0;https://127.0.0.1:0";
|
||||||
|
|
||||||
public const string DefaultFramework = "netcoreapp5.0";
|
|
||||||
|
|
||||||
public static bool IsCIEnvironment => typeof(Project).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
|
public static bool IsCIEnvironment => typeof(Project).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
|
||||||
.Any(a => a.Key == "ContinuousIntegrationBuild");
|
.Any(a => a.Key == "ContinuousIntegrationBuild");
|
||||||
|
|
||||||
public static string ArtifactsLogDir => typeof(Project).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
|
public static string ArtifactsLogDir => GetAssemblyMetadata("ArtifactsLogDir");
|
||||||
.Single(a => a.Key == "ArtifactsLogDir")?.Value;
|
|
||||||
|
|
||||||
public SemaphoreSlim DotNetNewLock { get; set; }
|
public SemaphoreSlim DotNetNewLock { get; set; }
|
||||||
public SemaphoreSlim NodeLock { get; set; }
|
public SemaphoreSlim NodeLock { get; set; }
|
||||||
|
|
@ -35,14 +32,16 @@ namespace Templates.Test.Helpers
|
||||||
public string ProjectArguments { get; set; }
|
public string ProjectArguments { get; set; }
|
||||||
public string ProjectGuid { get; set; }
|
public string ProjectGuid { get; set; }
|
||||||
public string TemplateOutputDir { get; set; }
|
public string TemplateOutputDir { get; set; }
|
||||||
public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", DefaultFramework);
|
public string TargetFramework { get; set; } = GetAssemblyMetadata("Test.DefaultTargetFramework");
|
||||||
public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", DefaultFramework, "publish");
|
|
||||||
|
public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", TargetFramework);
|
||||||
|
public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", TargetFramework, "publish");
|
||||||
|
|
||||||
private string TemplateServerDir => Path.Combine(TemplateOutputDir, $"{ProjectName}.Server");
|
private string TemplateServerDir => Path.Combine(TemplateOutputDir, $"{ProjectName}.Server");
|
||||||
private string TemplateClientDir => Path.Combine(TemplateOutputDir, $"{ProjectName}.Client");
|
private string TemplateClientDir => Path.Combine(TemplateOutputDir, $"{ProjectName}.Client");
|
||||||
public string TemplateClientDebugDir => Path.Combine(TemplateClientDir, "bin", "Debug", DefaultFramework);
|
public string TemplateClientDebugDir => Path.Combine(TemplateClientDir, "bin", "Debug", TargetFramework);
|
||||||
public string TemplateClientReleaseDir => Path.Combine(TemplateClientDir, "bin", "Release", DefaultFramework, "publish");
|
public string TemplateClientReleaseDir => Path.Combine(TemplateClientDir, "bin", "Release", TargetFramework, "publish");
|
||||||
public string TemplateServerReleaseDir => Path.Combine(TemplateServerDir, "bin", "Release", DefaultFramework, "publish");
|
public string TemplateServerReleaseDir => Path.Combine(TemplateServerDir, "bin", "Release", TargetFramework, "publish");
|
||||||
|
|
||||||
public ITestOutputHelper Output { get; set; }
|
public ITestOutputHelper Output { get; set; }
|
||||||
public IMessageSink DiagnosticsMessageSink { get; set; }
|
public IMessageSink DiagnosticsMessageSink { get; set; }
|
||||||
|
|
@ -110,7 +109,7 @@ namespace Templates.Test.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<ProcessEx> RunDotNetPublishAsync(bool takeNodeLock = false, IDictionary<string,string> packageOptions = null, string additionalArgs = null)
|
internal async Task<ProcessEx> RunDotNetPublishAsync(bool takeNodeLock = false, IDictionary<string, string> packageOptions = null, string additionalArgs = null)
|
||||||
{
|
{
|
||||||
Output.WriteLine("Publishing ASP.NET application...");
|
Output.WriteLine("Publishing ASP.NET application...");
|
||||||
|
|
||||||
|
|
@ -132,7 +131,7 @@ namespace Templates.Test.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<ProcessEx> RunDotNetBuildAsync(bool takeNodeLock = false, IDictionary<string,string> packageOptions = null, string additionalArgs = null)
|
internal async Task<ProcessEx> RunDotNetBuildAsync(bool takeNodeLock = false, IDictionary<string, string> packageOptions = null, string additionalArgs = null)
|
||||||
{
|
{
|
||||||
Output.WriteLine("Building ASP.NET application...");
|
Output.WriteLine("Building ASP.NET application...");
|
||||||
|
|
||||||
|
|
@ -524,5 +523,18 @@ namespace Templates.Test.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{ProjectName}: {TemplateOutputDir}";
|
public override string ToString() => $"{ProjectName}: {TemplateOutputDir}";
|
||||||
|
|
||||||
|
private static string GetAssemblyMetadata(string key)
|
||||||
|
{
|
||||||
|
var attribute = typeof(Project).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
|
||||||
|
.FirstOrDefault(a => a.Key == key);
|
||||||
|
|
||||||
|
if (attribute is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"AssemblyMetadataAttribute with key {key} was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return attribute.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,10 @@
|
||||||
<_Parameter1>TestPackageRestorePath</_Parameter1>
|
<_Parameter1>TestPackageRestorePath</_Parameter1>
|
||||||
<_Parameter2>$(TestPackageRestorePath)</_Parameter2>
|
<_Parameter2>$(TestPackageRestorePath)</_Parameter2>
|
||||||
</AssemblyAttribute>
|
</AssemblyAttribute>
|
||||||
|
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||||
|
<_Parameter1>Test.DefaultTargetFramework</_Parameter1>
|
||||||
|
<_Parameter2>$(DefaultNetCoreTargetFramework)</_Parameter2>
|
||||||
|
</AssemblyAttribute>
|
||||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(ContinuousIntegrationBuild)' == 'true'">
|
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(ContinuousIntegrationBuild)' == 'true'">
|
||||||
<_Parameter1>ContinuousIntegrationBuild</_Parameter1>
|
<_Parameter1>ContinuousIntegrationBuild</_Parameter1>
|
||||||
<_Parameter2>true</_Parameter2>
|
<_Parameter2>true</_Parameter2>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue