|
|
@@ -1,10 +1,8 @@
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
|
-using System.Threading.Tasks;
|
|
|
using Microsoft.AspNetCore.Testing;
|
|
|
using Templates.Test.Helpers;
|
|
|
-using Xunit;
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
namespace Templates.Test;
|
|
|
@@ -32,17 +30,38 @@ public class WorkerTemplateTest : LoggedTest
|
|
|
|
|
|
[ConditionalTheory]
|
|
|
[InlineData("C#", null)]
|
|
|
- [InlineData("C#", new [] { ArgConstants.UseProgramMain })]
|
|
|
+ [InlineData("C#", new[] { ArgConstants.UseProgramMain })]
|
|
|
[InlineData("F#", null)]
|
|
|
public async Task WorkerTemplateAsync(string language, string[] args)
|
|
|
{
|
|
|
+ await WorkerTemplateCoreAsync(language, args);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ [ConditionalTheory(Skip = "Unskip when Helix supports native AOT. https://github.com/dotnet/aspnetcore/pull/47247/")]
|
|
|
+ [InlineData("C#")]
|
|
|
+ [InlineData("F#")]
|
|
|
+ public async Task WorkerTemplateNativeAotAsync(string language)
|
|
|
+ {
|
|
|
+ await WorkerTemplateCoreAsync(language, args: new[] { ArgConstants.PublishNativeAot });
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task WorkerTemplateCoreAsync(string language, string[] args)
|
|
|
+ {
|
|
|
+ var nativeAot = args?.Contains(ArgConstants.PublishNativeAot) ?? false;
|
|
|
+
|
|
|
var project = await ProjectFactory.CreateProject(Output);
|
|
|
+ if (nativeAot)
|
|
|
+ {
|
|
|
+ project.SetCurrentRuntimeIdentifier();
|
|
|
+ }
|
|
|
|
|
|
await project.RunDotNetNewAsync("worker", language: language, args: args);
|
|
|
|
|
|
await project.VerifyHasProperty("InvariantGlobalization", "true");
|
|
|
|
|
|
- await project.RunDotNetPublishAsync();
|
|
|
+ // Force a restore if native AOT so that RID-specific assets are restored
|
|
|
+ await project.RunDotNetPublishAsync(noRestore: !nativeAot);
|
|
|
|
|
|
// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
|
|
|
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
|
|
|
@@ -57,7 +76,7 @@ public class WorkerTemplateTest : LoggedTest
|
|
|
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process));
|
|
|
}
|
|
|
|
|
|
- using (var aspNetProcess = project.StartPublishedProjectAsync(hasListeningUri: false))
|
|
|
+ using (var aspNetProcess = project.StartPublishedProjectAsync(hasListeningUri: false, usePublishedAppHost: nativeAot))
|
|
|
{
|
|
|
Assert.False(
|
|
|
aspNetProcess.Process.HasExited,
|