diff --git a/src/ProjectTemplates/Shared/AspNetProcess.cs b/src/ProjectTemplates/Shared/AspNetProcess.cs index 5187af7fff19..ad8fc892215b 100644 --- a/src/ProjectTemplates/Shared/AspNetProcess.cs +++ b/src/ProjectTemplates/Shared/AspNetProcess.cs @@ -35,6 +35,7 @@ public class AspNetProcess : IDisposable internal ProcessEx Process { get; } public AspNetProcess( + DevelopmentCertificate cert, ITestOutputHelper output, string workingDirectory, string dllPath, @@ -44,8 +45,7 @@ public AspNetProcess( bool usePublishedAppHost = false, ILogger logger = null) { - _developmentCertificate = DevelopmentCertificate.Create(workingDirectory); - + _developmentCertificate = cert; _output = output; _httpClient = new HttpClient(new HttpClientHandler() { diff --git a/src/ProjectTemplates/Shared/Project.cs b/src/ProjectTemplates/Shared/Project.cs index bf2d1082587b..32910329d056 100644 --- a/src/ProjectTemplates/Shared/Project.cs +++ b/src/ProjectTemplates/Shared/Project.cs @@ -40,6 +40,7 @@ public class Project : IDisposable public string TemplateOutputDir { get; set; } public string TargetFramework { get; set; } = GetAssemblyMetadata("Test.DefaultTargetFramework"); public string RuntimeIdentifier { get; set; } = string.Empty; + public static DevelopmentCertificate DevCert { get; } = DevelopmentCertificate.Create(AppContext.BaseDirectory); public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", TargetFramework, RuntimeIdentifier); public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", TargetFramework, RuntimeIdentifier, "publish"); @@ -178,7 +179,7 @@ internal AspNetProcess StartBuiltProjectAsync(bool hasListeningUri = true, ILogg } var projectDll = Path.Combine(TemplateBuildDir, $"{ProjectName}.dll"); - return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger); + return new AspNetProcess(DevCert, Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger); } internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, bool usePublishedAppHost = false) @@ -193,7 +194,7 @@ internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, b }; var projectDll = Path.Combine(TemplatePublishDir, $"{ProjectName}.dll"); - return new AspNetProcess(Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost); + return new AspNetProcess(DevCert, Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost); } internal async Task RunDotNetEfCreateMigrationAsync(string migrationName)