@@ -65,22 +65,29 @@ public BuildResult RestoreThenBuild()
6565 if ( BuildPartition . IsCustomBuildConfiguration )
6666 return Build ( ) . ToBuildResult ( GenerateResult ) ;
6767
68- var restoreResult = Restore ( ) ;
69- if ( ! restoreResult . IsSuccess )
70- return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
71-
7268 // On our CI, Integration tests take too much time, because each benchmark run rebuilds BenchmarkDotNet itself.
7369 // To reduce the total duration of the CI workflows, we build all the projects without dependencies
7470 if ( BuildPartition . ForcedNoDependenciesForIntegrationTests )
7571 {
72+ var restoreResult = DotNetCliCommandExecutor . Execute ( WithArguments (
73+ GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , $ "{ Arguments } --no-dependencies", "restore-no-deps" , excludeOutput : true ) ) ) ;
74+ if ( ! restoreResult . IsSuccess )
75+ return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
76+
7677 return DotNetCliCommandExecutor . Execute ( WithArguments (
7778 GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , $ "{ Arguments } --no-restore --no-dependencies", "build-no-restore-no-deps" , excludeOutput : true ) ) )
7879 . ToBuildResult ( GenerateResult ) ;
7980 }
81+ else
82+ {
83+ var restoreResult = Restore ( ) ;
84+ if ( ! restoreResult . IsSuccess )
85+ return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
8086
81- // We no longer retry with --no-dependencies, because it fails with --output set at the same time,
82- // and the artifactsPaths.BinariesDirectoryPath is set before we try to build, so we cannot overwrite it.
83- return BuildNoRestore ( ) . ToBuildResult ( GenerateResult ) ;
87+ // We no longer retry with --no-dependencies, because it fails with --output set at the same time,
88+ // and the artifactsPaths.BinariesDirectoryPath is set before we try to build, so we cannot overwrite it.
89+ return BuildNoRestore ( ) . ToBuildResult ( GenerateResult ) ;
90+ }
8491 }
8592
8693 [ PublicAPI ]
@@ -144,14 +151,15 @@ public DotNetCliCommandResult PublishNoRestore()
144151 internal static IEnumerable < string > GetAddPackagesCommands ( BuildPartition buildPartition )
145152 => GetNuGetAddPackageCommands ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) ;
146153
147- internal static string GetRestoreCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string extraArguments = null , string binLogSuffix = null )
154+ internal static string GetRestoreCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string extraArguments = null , string binLogSuffix = null , bool excludeOutput = false )
148155 => new StringBuilder ( )
149156 . AppendArgument ( "restore" )
150157 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "--packages \" { artifactsPaths . PackagesDirectoryName } \" ")
151158 . AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
152159 . AppendArgument ( extraArguments )
153160 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
154161 . AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
162+ . MaybeAppendOutputPaths ( artifactsPaths , true , excludeOutput )
155163 . ToString ( ) ;
156164
157165 internal static string GetBuildCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string extraArguments = null , string binLogSuffix = null , bool excludeOutput = false )
@@ -162,7 +170,7 @@ internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildParti
162170 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
163171 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
164172 . AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
165- . MaybeAppendOutputPaths ( artifactsPaths , excludeOutput )
173+ . MaybeAppendOutputPaths ( artifactsPaths , excludeOutput : excludeOutput )
166174 . ToString ( ) ;
167175
168176 internal static string GetPublishCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string extraArguments = null , string binLogSuffix = null )
@@ -248,14 +256,14 @@ internal static class DotNetCliCommandExtensions
248256 // We force the project to output binaries to a new directory.
249257 // Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path),
250258 // so we don't include it if we're building no-deps (only supported for integration tests).
251- internal static StringBuilder MaybeAppendOutputPaths ( this StringBuilder stringBuilder , ArtifactsPaths artifactsPaths , bool excludeOutput = false )
259+ internal static StringBuilder MaybeAppendOutputPaths ( this StringBuilder stringBuilder , ArtifactsPaths artifactsPaths , bool isRestore = false , bool excludeOutput = false )
252260 => excludeOutput
253261 ? stringBuilder
254262 : stringBuilder
255263 . AppendArgument ( $ "/p:IntermediateOutputPath=\" { artifactsPaths . IntermediateDirectoryPath } \" \\ ")
256264 . AppendArgument ( $ "/p:OutDir=\" { artifactsPaths . BinariesDirectoryPath } \" ")
257265 // OutputPath is legacy, per-project version of OutDir. We set both just in case. https://github.com/dotnet/msbuild/issues/87
258266 . AppendArgument ( $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } \" ")
259- . AppendArgument ( $ "--output \" { artifactsPaths . BinariesDirectoryPath } \" ") ;
267+ . AppendArgument ( isRestore ? string . Empty : $ "--output \" { artifactsPaths . BinariesDirectoryPath } \" ") ;
260268 }
261269}
0 commit comments