@@ -53,7 +53,7 @@ public DotNetCliCommand WithCliPath(string cliPath)
5353 => new ( cliPath , Arguments , GenerateResult , Logger , BuildPartition , EnvironmentVariables , Timeout , logOutput : LogOutput ) ;
5454
5555 [ PublicAPI ]
56- public BuildResult RestoreThenBuild ( )
56+ public BuildResult RestoreThenBuild ( bool useArtifactsPathIfSupported = true )
5757 {
5858 DotNetCliCommandExecutor . LogEnvVars ( WithArguments ( null ) ) ;
5959
@@ -65,35 +65,35 @@ public BuildResult RestoreThenBuild()
6565 // so when users go with custom build configuration, we must perform full build
6666 // which will internally restore for the right configuration
6767 if ( BuildPartition . IsCustomBuildConfiguration )
68- return Build ( ) . ToBuildResult ( GenerateResult ) ;
68+ return Build ( useArtifactsPathIfSupported ) . ToBuildResult ( GenerateResult ) ;
6969
7070 // On our CI, Integration tests take too much time, because each benchmark run rebuilds BenchmarkDotNet itself.
7171 // To reduce the total duration of the CI workflows, we build all the projects without dependencies
7272 if ( BuildPartition . ForcedNoDependenciesForIntegrationTests )
7373 {
7474 var restoreResult = DotNetCliCommandExecutor . Execute ( WithArguments (
75- GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , $ "{ Arguments } --no-dependencies", "restore-no-deps" , excludeOutput : true ) ) ) ;
75+ GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , $ "{ Arguments } --no-dependencies", "restore-no-deps" , excludeOutput : true ) ) ) ;
7676 if ( ! restoreResult . IsSuccess )
7777 return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
7878
7979 return DotNetCliCommandExecutor . Execute ( WithArguments (
80- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , $ "{ Arguments } --no-restore --no-dependencies", "build-no-restore-no-deps" , excludeOutput : true ) ) )
80+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , $ "{ Arguments } --no-restore --no-dependencies", "build-no-restore-no-deps" , excludeOutput : true ) ) )
8181 . ToBuildResult ( GenerateResult ) ;
8282 }
8383 else
8484 {
85- var restoreResult = Restore ( ) ;
85+ var restoreResult = Restore ( useArtifactsPathIfSupported ) ;
8686 if ( ! restoreResult . IsSuccess )
8787 return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
8888
8989 // We no longer retry with --no-dependencies, because it fails with --output set at the same time,
9090 // and the artifactsPaths.BinariesDirectoryPath is set before we try to build, so we cannot overwrite it.
91- return BuildNoRestore ( ) . ToBuildResult ( GenerateResult ) ;
91+ return BuildNoRestore ( useArtifactsPathIfSupported ) . ToBuildResult ( GenerateResult ) ;
9292 }
9393 }
9494
9595 [ PublicAPI ]
96- public BuildResult RestoreThenBuildThenPublish ( )
96+ public BuildResult RestoreThenBuildThenPublish ( bool useArtifactsPathIfSupported = true )
9797 {
9898 DotNetCliCommandExecutor . LogEnvVars ( WithArguments ( null ) ) ;
9999
@@ -105,14 +105,14 @@ public BuildResult RestoreThenBuildThenPublish()
105105 // so when users go with custom build configuration, we must perform full publish
106106 // which will internally restore and build for the right configuration
107107 if ( BuildPartition . IsCustomBuildConfiguration )
108- return Publish ( ) . ToBuildResult ( GenerateResult ) ;
108+ return Publish ( useArtifactsPathIfSupported ) . ToBuildResult ( GenerateResult ) ;
109109
110- var restoreResult = Restore ( ) ;
110+ var restoreResult = Restore ( useArtifactsPathIfSupported ) ;
111111 if ( ! restoreResult . IsSuccess )
112112 return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
113113
114114 // We use the implicit build in the publish command. We stopped doing a separate build step because we set the --output.
115- return PublishNoRestore ( ) . ToBuildResult ( GenerateResult ) ;
115+ return PublishNoRestore ( useArtifactsPathIfSupported ) . ToBuildResult ( GenerateResult ) ;
116116 }
117117
118118 public DotNetCliCommandResult AddPackages ( )
@@ -129,28 +129,28 @@ public DotNetCliCommandResult AddPackages()
129129 return DotNetCliCommandResult . Success ( executionTime , stdOutput . ToString ( ) ) ;
130130 }
131131
132- private bool GetWithArtifactsPath ( ) => DotNetCliCommandExecutor . DotNetSdkSupportsArtifactsPath ( CliPath ) ;
132+ private bool GetWithArtifactsPath ( bool useArtifactsPathIfSupported ) => useArtifactsPathIfSupported && DotNetCliCommandExecutor . DotNetSdkSupportsArtifactsPath ( CliPath ) ;
133133
134- public DotNetCliCommandResult Restore ( )
134+ public DotNetCliCommandResult Restore ( bool useArtifactsPathIfSupported = true )
135135 => DotNetCliCommandExecutor . Execute ( WithArguments (
136- GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , Arguments , "restore" ) ) ) ;
136+ GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , Arguments , "restore" ) ) ) ;
137137
138- public DotNetCliCommandResult Build ( )
138+ public DotNetCliCommandResult Build ( bool useArtifactsPathIfSupported = true )
139139 => DotNetCliCommandExecutor . Execute ( WithArguments (
140- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , Arguments , "build" ) ) ) ;
140+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , Arguments , "build" ) ) ) ;
141141
142- public DotNetCliCommandResult BuildNoRestore ( )
142+ public DotNetCliCommandResult BuildNoRestore ( bool useArtifactsPathIfSupported = true )
143143 => DotNetCliCommandExecutor . Execute ( WithArguments (
144- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , $ "{ Arguments } --no-restore", "build-no-restore" ) ) ) ;
144+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , $ "{ Arguments } --no-restore", "build-no-restore" ) ) ) ;
145145
146- public DotNetCliCommandResult Publish ( )
146+ public DotNetCliCommandResult Publish ( bool useArtifactsPathIfSupported = true )
147147 => DotNetCliCommandExecutor . Execute ( WithArguments (
148- GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , Arguments , "publish" ) ) ) ;
148+ GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , Arguments , "publish" ) ) ) ;
149149
150150 // PublishNoBuildAndNoRestore was removed because we set --output in the build step. We use the implicit build included in the publish command.
151- public DotNetCliCommandResult PublishNoRestore ( )
151+ public DotNetCliCommandResult PublishNoRestore ( bool useArtifactsPathIfSupported = true )
152152 => DotNetCliCommandExecutor . Execute ( WithArguments (
153- GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( ) , $ "{ Arguments } --no-restore", "publish-no-restore" ) ) ) ;
153+ GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , GetWithArtifactsPath ( useArtifactsPathIfSupported ) , $ "{ Arguments } --no-restore", "publish-no-restore" ) ) ) ;
154154
155155 internal static IEnumerable < string > GetAddPackagesCommands ( BuildPartition buildPartition )
156156 => GetNuGetAddPackageCommands ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) ;
0 commit comments