Skip to content

Commit 14af9d9

Browse files
authored
Template tests: Create dev cert only once (#31012)
1 parent 89c2573 commit 14af9d9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/ProjectTemplates/Shared/AspNetProcess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class AspNetProcess : IDisposable
3535
internal ProcessEx Process { get; }
3636

3737
public AspNetProcess(
38+
DevelopmentCertificate cert,
3839
ITestOutputHelper output,
3940
string workingDirectory,
4041
string dllPath,
@@ -44,8 +45,7 @@ public AspNetProcess(
4445
bool usePublishedAppHost = false,
4546
ILogger logger = null)
4647
{
47-
_developmentCertificate = DevelopmentCertificate.Create(workingDirectory);
48-
48+
_developmentCertificate = cert;
4949
_output = output;
5050
_httpClient = new HttpClient(new HttpClientHandler()
5151
{

src/ProjectTemplates/Shared/Project.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class Project : IDisposable
4040
public string TemplateOutputDir { get; set; }
4141
public string TargetFramework { get; set; } = GetAssemblyMetadata("Test.DefaultTargetFramework");
4242
public string RuntimeIdentifier { get; set; } = string.Empty;
43+
public static DevelopmentCertificate DevCert { get; } = DevelopmentCertificate.Create(AppContext.BaseDirectory);
4344

4445
public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", TargetFramework, RuntimeIdentifier);
4546
public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", TargetFramework, RuntimeIdentifier, "publish");
@@ -178,7 +179,7 @@ internal AspNetProcess StartBuiltProjectAsync(bool hasListeningUri = true, ILogg
178179
}
179180

180181
var projectDll = Path.Combine(TemplateBuildDir, $"{ProjectName}.dll");
181-
return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger);
182+
return new AspNetProcess(DevCert, Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger);
182183
}
183184

184185
internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, bool usePublishedAppHost = false)
@@ -193,7 +194,7 @@ internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, b
193194
};
194195

195196
var projectDll = Path.Combine(TemplatePublishDir, $"{ProjectName}.dll");
196-
return new AspNetProcess(Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost);
197+
return new AspNetProcess(DevCert, Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost);
197198
}
198199

199200
internal async Task<ProcessResult> RunDotNetEfCreateMigrationAsync(string migrationName)

0 commit comments

Comments
 (0)