@@ -46,6 +46,11 @@ bool IBuildActions.FileExists(string file)
4646
4747 public IList < string > RunProcessIn { get ; } = new List < string > ( ) ;
4848 public IDictionary < string , int > RunProcess { get ; } = new Dictionary < string , int > ( ) ;
49+
50+ /// <summary>
51+ /// (process-exit code) pairs for commands that are executed during the assembly of the autobuild script.
52+ /// </summary>
53+ public IDictionary < string , int > RunProcessExecuteDuring { get ; } = new Dictionary < string , int > ( ) ;
4954 public IDictionary < string , string > RunProcessOut { get ; } = new Dictionary < string , string > ( ) ;
5055 public IDictionary < string , string > RunProcessWorkingDirectory { get ; } = new Dictionary < string , string > ( ) ;
5156 public HashSet < string > CreateDirectories { get ; } = new HashSet < string > ( ) ;
@@ -66,7 +71,7 @@ int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory,
6671 if ( wd != workingDirectory )
6772 throw new ArgumentException ( $ "Unexpected RunProcessWorkingDirectory, got { wd ?? "null" } expected { workingDirectory ?? "null" } in { pattern } ") ;
6873
69- if ( ! RunProcess . TryGetValue ( pattern , out var ret ) )
74+ if ( ! RunProcess . TryGetValue ( pattern , out var ret ) && ! RunProcessExecuteDuring . TryGetValue ( pattern , out ret ) )
7075 throw new ArgumentException ( "Missing RunProcess " + pattern ) ;
7176
7277 return ret ;
@@ -81,7 +86,7 @@ int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory,
8186 if ( wd != workingDirectory )
8287 throw new ArgumentException ( $ "Unexpected RunProcessWorkingDirectory, got { wd ?? "null" } expected { workingDirectory ?? "null" } in { pattern } ") ;
8388
84- if ( ! RunProcess . TryGetValue ( pattern , out var ret ) )
89+ if ( ! RunProcess . TryGetValue ( pattern , out var ret ) && ! RunProcessExecuteDuring . TryGetValue ( pattern , out ret ) )
8590 throw new ArgumentException ( "Missing RunProcess " + pattern ) ;
8691
8792 return ret ;
@@ -797,11 +802,32 @@ public void TestDirsProjWindows()
797802 }
798803
799804 [ Fact ]
800- public void TestDirsProjLinux ( )
805+ public void TestDirsProjLinux_WithMono ( )
801806 {
807+ actions . RunProcessExecuteDuring [ @"mono --version" ] = 0 ;
808+
802809 actions . RunProcess [ @"nuget restore C:\Project/dirs.proj -DisableParallelProcessing" ] = 1 ;
803810 actions . RunProcess [ @"mono scratch/.nuget/nuget.exe restore C:\Project/dirs.proj -DisableParallelProcessing" ] = 0 ;
804811 actions . RunProcess [ @"msbuild C:\Project/dirs.proj /t:rebuild" ] = 0 ;
812+
813+ var autobuilder = TestDirsProjLinux ( ) ;
814+ TestAutobuilderScript ( autobuilder , 0 , 3 ) ;
815+ }
816+
817+ [ Fact ]
818+ public void TestDirsProjLinux_WithoutMono ( )
819+ {
820+ actions . RunProcessExecuteDuring [ @"mono --version" ] = 1 ;
821+
822+ actions . RunProcess [ @"dotnet msbuild /t:restore C:\Project/dirs.proj" ] = 0 ;
823+ actions . RunProcess [ @"dotnet msbuild C:\Project/dirs.proj /t:rebuild" ] = 0 ;
824+
825+ var autobuilder = TestDirsProjLinux ( ) ;
826+ TestAutobuilderScript ( autobuilder , 0 , 2 ) ;
827+ }
828+
829+ private CSharpAutobuilder TestDirsProjLinux ( )
830+ {
805831 actions . FileExists [ "csharp.log" ] = true ;
806832 actions . FileExists [ @"C:\Project/a/test.csproj" ] = true ;
807833 actions . FileExists [ @"C:\Project/dirs.proj" ] = true ;
@@ -830,8 +856,7 @@ public void TestDirsProjLinux()
830856</Project>" ) ;
831857 actions . LoadXml [ @"C:\Project/dirs.proj" ] = dirsproj ;
832858
833- var autobuilder = CreateAutoBuilder ( false ) ;
834- TestAutobuilderScript ( autobuilder , 0 , 3 ) ;
859+ return CreateAutoBuilder ( false ) ;
835860 }
836861
837862 [ Fact ]
0 commit comments