@@ -6,15 +6,11 @@ namespace TestMyCode.CSharp.Core.Compiler;
66
77public sealed class ProjectCompiler
88{
9- private const string BinPath = "bin" ;
10- private const string OutputPath = "TMC-output" ;
11-
129 private readonly ProjectCollection projectCollection ;
1310
1411 public ProjectCompiler ( )
1512 {
1613 this . projectCollection = new ProjectCollection ( ) ;
17- this . projectCollection . SetGlobalProperty ( "PublishDir" , Path . Combine ( ProjectCompiler . BinPath , ProjectCompiler . OutputPath ) ) ;
1814 }
1915
2016 public List < string > CompileTestProjects ( DirectoryInfo projectDir )
@@ -29,47 +25,22 @@ public List<string> CompileTestProjects(DirectoryInfo projectDir)
2925
3026 foreach ( string projectFile in Directory . EnumerateFiles ( projectDir . FullName , "*Tests.csproj" , enumerationOptions ) )
3127 {
32- string projectRoot = Path . GetDirectoryName ( projectFile ) ?? string . Empty ;
33-
34- //Cleanup before loading the project! It may use the files inside obj! That's no good
35- this . CleanOutput ( projectRoot ) ;
36-
3728 Project project = this . projectCollection . LoadProject ( projectFile ) ;
3829
39- if ( ! this . CompileTestProject ( project , out CompilerOutputLogger compilationErrors ) )
30+ if ( ! this . TryCompileTestProject ( project , out CompilerOutputLogger compilationErrors ) )
4031 {
4132 throw new CompilationFaultedException ( compilationErrors . CompileErrors ) ;
4233 }
4334
44- string assemblyName = project . GetPropertyValue ( "AssemblyName" ) ;
45- string assemblyPath = Path . Combine ( projectRoot , ProjectCompiler . BinPath , ProjectCompiler . OutputPath , $ "{ assemblyName } .dll") ;
35+ string assemblyPath = project . GetPropertyValue ( "TargetPath" ) ;
4636
4737 files . Add ( assemblyPath ) ;
4838 }
4939
5040 return files ;
5141 }
5242
53- private void CleanOutput ( string projectRoot )
54- {
55- string bin = Path . Combine ( projectRoot , "bin" ) ;
56- if ( Directory . Exists ( bin ) )
57- {
58- DirectoryInfo dir = new ( bin ) ;
59- dir . MoveTo ( Path . Combine ( projectRoot , "bin_OLD" ) ) ; //Workaround as Delete is non blocking
60- dir . Delete ( recursive : true ) ;
61- }
62-
63- string obj = Path . Combine ( projectRoot , "obj" ) ;
64- if ( Directory . Exists ( obj ) )
65- {
66- DirectoryInfo dir = new ( obj ) ;
67- dir . MoveTo ( Path . Combine ( projectRoot , "obj_OLD" ) ) ; //Workaround as Delete is non blocking
68- dir . Delete ( recursive : true ) ;
69- }
70- }
71-
72- private bool CompileTestProject ( Project project , out CompilerOutputLogger logger )
43+ private bool TryCompileTestProject ( Project project , out CompilerOutputLogger logger )
7344 {
7445 logger = new CompilerOutputLogger ( ) ;
7546
0 commit comments