@@ -10,15 +10,15 @@ internal static class MsBuildCommandExtensions
10
10
/// <summary>
11
11
/// Appends a call to msbuild.
12
12
/// </summary>
13
- /// <param name="cmdBuilder"></param>
14
- /// <param name="builder"></param>
15
13
/// <returns></returns>
16
- public static CommandBuilder MsBuildCommand ( this CommandBuilder cmdBuilder , IAutobuilder < AutobuildOptionsShared > builder )
14
+ public static CommandBuilder MsBuildCommand ( this CommandBuilder cmdBuilder , IAutobuilder < AutobuildOptionsShared > builder , bool preferDotnet )
17
15
{
18
16
// mono doesn't ship with `msbuild` on Arm-based Macs, but we can fall back to
19
17
// msbuild that ships with `dotnet` which can be invoked with `dotnet msbuild`
20
18
// perhaps we should do this on all platforms?
21
- return builder . Actions . IsRunningOnAppleSilicon ( )
19
+ // Similarly, there's no point in trying to rely on mono if it's not installed.
20
+ // In which case we can still fall back to `dotnet msbuild`.
21
+ return preferDotnet
22
22
? cmdBuilder . RunCommand ( "dotnet" ) . Argument ( "msbuild" )
23
23
: cmdBuilder . RunCommand ( "msbuild" ) ;
24
24
}
@@ -75,13 +75,16 @@ BuildScript GetNugetRestoreScript() =>
75
75
QuoteArgument ( projectOrSolution . FullPath ) .
76
76
Argument ( "-DisableParallelProcessing" ) .
77
77
Script ;
78
+
79
+ var preferDotnet = builder . Actions . IsRunningOnAppleSilicon ( ) || ! builder . Actions . IsWindows ( ) && ! builder . Actions . IsMonoInstalled ( ) ;
80
+
78
81
var nugetRestore = GetNugetRestoreScript ( ) ;
79
82
var msbuildRestoreCommand = new CommandBuilder ( builder . Actions ) .
80
- MsBuildCommand ( builder ) .
83
+ MsBuildCommand ( builder , preferDotnet ) .
81
84
Argument ( "/t:restore" ) .
82
85
QuoteArgument ( projectOrSolution . FullPath ) ;
83
86
84
- if ( builder . Actions . IsRunningOnAppleSilicon ( ) )
87
+ if ( preferDotnet )
85
88
{
86
89
// On Apple Silicon, only try package restore with `dotnet msbuild /t:restore`
87
90
ret &= BuildScript . Try ( msbuildRestoreCommand . Script ) ;
@@ -119,7 +122,7 @@ BuildScript GetNugetRestoreScript() =>
119
122
command . RunCommand ( "set Platform=&& type NUL" , quoteExe : false ) ;
120
123
}
121
124
122
- command . MsBuildCommand ( builder ) ;
125
+ command . MsBuildCommand ( builder , preferDotnet ) ;
123
126
command . QuoteArgument ( projectOrSolution . FullPath ) ;
124
127
125
128
var target = "rebuild" ;
0 commit comments