@@ -21,28 +21,27 @@ public class Project
21
21
{
22
22
private const string _urls = "http://127.0.0.1:0;https://127.0.0.1:0" ;
23
23
24
- public const string DefaultFramework = "netcoreapp3.1" ;
25
-
26
24
public static bool IsCIEnvironment => typeof ( Project ) . Assembly . GetCustomAttributes < AssemblyMetadataAttribute > ( )
27
25
. Any ( a => a . Key == "ContinuousIntegrationBuild" ) ;
28
26
29
- public static string ArtifactsLogDir => typeof ( Project ) . Assembly . GetCustomAttributes < AssemblyMetadataAttribute > ( )
30
- . Single ( a => a . Key == "ArtifactsLogDir" ) ? . Value ;
27
+ public static string ArtifactsLogDir => GetAssemblyMetadata ( "ArtifactsLogDir" ) ;
31
28
32
29
public SemaphoreSlim DotNetNewLock { get ; set ; }
33
30
public SemaphoreSlim NodeLock { get ; set ; }
34
31
public string ProjectName { get ; set ; }
35
32
public string ProjectArguments { get ; set ; }
36
33
public string ProjectGuid { get ; set ; }
37
34
public string TemplateOutputDir { get ; set ; }
38
- public string TemplateBuildDir => Path . Combine ( TemplateOutputDir , "bin" , "Debug" , DefaultFramework ) ;
39
- public string TemplatePublishDir => Path . Combine ( TemplateOutputDir , "bin" , "Release" , DefaultFramework , "publish" ) ;
35
+ public string TargetFramework { get ; set ; } = GetAssemblyMetadata ( "Test.DefaultTargetFramework" ) ;
36
+
37
+ public string TemplateBuildDir => Path . Combine ( TemplateOutputDir , "bin" , "Debug" , TargetFramework ) ;
38
+ public string TemplatePublishDir => Path . Combine ( TemplateOutputDir , "bin" , "Release" , TargetFramework , "publish" ) ;
40
39
41
40
private string TemplateServerDir => Path . Combine ( TemplateOutputDir , $ "{ ProjectName } .Server") ;
42
41
private string TemplateClientDir => Path . Combine ( TemplateOutputDir , $ "{ ProjectName } .Client") ;
43
- public string TemplateClientDebugDir => Path . Combine ( TemplateClientDir , "bin" , "Debug" , DefaultFramework ) ;
44
- public string TemplateClientReleaseDir => Path . Combine ( TemplateClientDir , "bin" , "Release" , DefaultFramework , "publish" ) ;
45
- public string TemplateServerReleaseDir => Path . Combine ( TemplateServerDir , "bin" , "Release" , DefaultFramework , "publish" ) ;
42
+ public string TemplateClientDebugDir => Path . Combine ( TemplateClientDir , "bin" , "Debug" , TargetFramework ) ;
43
+ public string TemplateClientReleaseDir => Path . Combine ( TemplateClientDir , "bin" , "Release" , TargetFramework , "publish" ) ;
44
+ public string TemplateServerReleaseDir => Path . Combine ( TemplateServerDir , "bin" , "Release" , TargetFramework , "publish" ) ;
46
45
47
46
public ITestOutputHelper Output { get ; set ; }
48
47
public IMessageSink DiagnosticsMessageSink { get ; set ; }
@@ -110,7 +109,7 @@ internal async Task<ProcessEx> RunDotNetNewAsync(
110
109
}
111
110
}
112
111
113
- internal async Task < ProcessEx > RunDotNetPublishAsync ( bool takeNodeLock = false , IDictionary < string , string > packageOptions = null , string additionalArgs = null )
112
+ internal async Task < ProcessEx > RunDotNetPublishAsync ( bool takeNodeLock = false , IDictionary < string , string > packageOptions = null , string additionalArgs = null )
114
113
{
115
114
Output . WriteLine ( "Publishing ASP.NET application..." ) ;
116
115
@@ -132,7 +131,7 @@ internal async Task<ProcessEx> RunDotNetPublishAsync(bool takeNodeLock = false,
132
131
}
133
132
}
134
133
135
- internal async Task < ProcessEx > RunDotNetBuildAsync ( bool takeNodeLock = false , IDictionary < string , string > packageOptions = null , string additionalArgs = null )
134
+ internal async Task < ProcessEx > RunDotNetBuildAsync ( bool takeNodeLock = false , IDictionary < string , string > packageOptions = null , string additionalArgs = null )
136
135
{
137
136
Output . WriteLine ( "Building ASP.NET application..." ) ;
138
137
@@ -524,5 +523,18 @@ private void CaptureBinLogOnFailure(ProcessEx result)
524
523
}
525
524
526
525
public override string ToString ( ) => $ "{ ProjectName } : { TemplateOutputDir } ";
526
+
527
+ private static string GetAssemblyMetadata ( string key )
528
+ {
529
+ var attribute = typeof ( Project ) . Assembly . GetCustomAttributes < AssemblyMetadataAttribute > ( )
530
+ . FirstOrDefault ( a => a . Key == key ) ;
531
+
532
+ if ( attribute is null )
533
+ {
534
+ throw new ArgumentException ( $ "AssemblyMetadataAttribute with key { key } was not found.") ;
535
+ }
536
+
537
+ return attribute . Value ;
538
+ }
527
539
}
528
540
}
0 commit comments