@@ -33,9 +33,6 @@ public class DotNetCliCommand
3333
3434 [ PublicAPI ] public bool LogOutput { get ; }
3535
36- // Whether to use ArtifactsPath or IntermediateOutputPath. ArtifactsPath is only supported in dotnet sdk 8+.
37- private readonly bool _useArtifactsPath ;
38-
3936 public DotNetCliCommand ( string cliPath , string arguments , GenerateResult generateResult , ILogger logger ,
4037 BuildPartition buildPartition , IReadOnlyList < EnvironmentVariable > environmentVariables , TimeSpan timeout , bool logOutput = false )
4138 {
@@ -47,8 +44,6 @@ public DotNetCliCommand(string cliPath, string arguments, GenerateResult generat
4744 EnvironmentVariables = environmentVariables ;
4845 Timeout = timeout ;
4946 LogOutput = logOutput || ( buildPartition is not null && buildPartition . LogBuildOutput ) ;
50-
51- _useArtifactsPath = DotNetCliCommandExecutor . DotNetSdkSupportsArtifactsPath ( cliPath ) ;
5247 }
5348
5449 public DotNetCliCommand WithArguments ( string arguments )
@@ -77,12 +72,12 @@ public BuildResult RestoreThenBuild()
7772 if ( BuildPartition . ForcedNoDependenciesForIntegrationTests )
7873 {
7974 var restoreResult = DotNetCliCommandExecutor . Execute ( WithArguments (
80- GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , $ "{ Arguments } --no-dependencies", "restore-no-deps" , excludeOutput : true ) ) ) ;
75+ GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , $ "{ Arguments } --no-dependencies", "restore-no-deps" , excludeOutput : true ) ) ) ;
8176 if ( ! restoreResult . IsSuccess )
8277 return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
8378
8479 return DotNetCliCommandExecutor . Execute ( WithArguments (
85- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , $ "{ Arguments } --no-restore --no-dependencies", "build-no-restore-no-deps" , excludeOutput : true ) ) )
80+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , $ "{ Arguments } --no-restore --no-dependencies", "build-no-restore-no-deps" , excludeOutput : true ) ) )
8681 . ToBuildResult ( GenerateResult ) ;
8782 }
8883 else
@@ -136,62 +131,59 @@ public DotNetCliCommandResult AddPackages()
136131
137132 public DotNetCliCommandResult Restore ( )
138133 => DotNetCliCommandExecutor . Execute ( WithArguments (
139- GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , Arguments , "restore" ) ) ) ;
134+ GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , Arguments , "restore" ) ) ) ;
140135
141136 public DotNetCliCommandResult Build ( )
142137 => DotNetCliCommandExecutor . Execute ( WithArguments (
143- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , Arguments , "build" ) ) ) ;
138+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , Arguments , "build" ) ) ) ;
144139
145140 public DotNetCliCommandResult BuildNoRestore ( )
146141 => DotNetCliCommandExecutor . Execute ( WithArguments (
147- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , $ "{ Arguments } --no-restore", "build-no-restore" ) ) ) ;
142+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , $ "{ Arguments } --no-restore", "build-no-restore" ) ) ) ;
148143
149144 public DotNetCliCommandResult Publish ( )
150145 => DotNetCliCommandExecutor . Execute ( WithArguments (
151- GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , Arguments , "publish" ) ) ) ;
146+ GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , Arguments , "publish" ) ) ) ;
152147
153148 // PublishNoBuildAndNoRestore was removed because we set --output in the build step. We use the implicit build included in the publish command.
154149 public DotNetCliCommandResult PublishNoRestore ( )
155150 => DotNetCliCommandExecutor . Execute ( WithArguments (
156- GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , $ "{ Arguments } --no-restore", "publish-no-restore" ) ) ) ;
151+ GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , $ "{ Arguments } --no-restore", "publish-no-restore" ) ) ) ;
157152
158153 internal static IEnumerable < string > GetAddPackagesCommands ( BuildPartition buildPartition )
159154 => GetNuGetAddPackageCommands ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) ;
160155
161- internal static string GetRestoreCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition ,
162- bool useArtifactsPath , string ? extraArguments = null , string ? binLogSuffix = null , bool excludeOutput = false )
156+ internal static string GetRestoreCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string ? extraArguments = null , string ? binLogSuffix = null , bool excludeOutput = false )
163157 => new StringBuilder ( )
164158 . AppendArgument ( "restore" )
165159 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "--packages \" { artifactsPaths . PackagesDirectoryName } \" ")
166160 . AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
167161 . AppendArgument ( extraArguments )
168162 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
169163 . AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
170- . MaybeAppendOutputPaths ( artifactsPaths , useArtifactsPath , true , excludeOutput )
164+ . MaybeAppendOutputPaths ( artifactsPaths , true , excludeOutput )
171165 . ToString ( ) ;
172166
173- internal static string GetBuildCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition ,
174- bool useArtifactsPath , string ? extraArguments = null , string ? binLogSuffix = null , bool excludeOutput = false )
167+ internal static string GetBuildCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string ? extraArguments = null , string ? binLogSuffix = null , bool excludeOutput = false )
175168 => new StringBuilder ( )
176169 . AppendArgument ( $ "build -c { buildPartition . BuildConfiguration } ") // we don't need to specify TFM, our auto-generated project contains always single one
177170 . AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
178171 . AppendArgument ( extraArguments )
179172 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
180173 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
181174 . AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
182- . MaybeAppendOutputPaths ( artifactsPaths , useArtifactsPath , excludeOutput : excludeOutput )
175+ . MaybeAppendOutputPaths ( artifactsPaths , excludeOutput : excludeOutput )
183176 . ToString ( ) ;
184177
185- internal static string GetPublishCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition ,
186- bool useArtifactsPath , string ? extraArguments = null , string ? binLogSuffix = null )
178+ internal static string GetPublishCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string ? extraArguments = null , string ? binLogSuffix = null )
187179 => new StringBuilder ( )
188180 . AppendArgument ( $ "publish -c { buildPartition . BuildConfiguration } ") // we don't need to specify TFM, our auto-generated project contains always single one
189181 . AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
190182 . AppendArgument ( extraArguments )
191183 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
192184 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
193185 . AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
194- . MaybeAppendOutputPaths ( artifactsPaths , useArtifactsPath )
186+ . MaybeAppendOutputPaths ( artifactsPaths )
195187 . ToString ( ) ;
196188
197189 private static string GetMsBuildBinLogArgument ( BuildPartition buildPartition , string suffix )
@@ -266,18 +258,12 @@ internal static class DotNetCliCommandExtensions
266258 // We force the project to output binaries to a new directory.
267259 // Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path),
268260 // so we don't include it if we're building no-deps (only supported for integration tests).
269- internal static StringBuilder MaybeAppendOutputPaths ( this StringBuilder stringBuilder , ArtifactsPaths artifactsPaths , bool useArtifactsPath , bool isRestore = false , bool excludeOutput = false )
261+ internal static StringBuilder MaybeAppendOutputPaths ( this StringBuilder stringBuilder , ArtifactsPaths artifactsPaths , bool isRestore = false , bool excludeOutput = false )
270262 => excludeOutput
271263 ? stringBuilder
272264 : stringBuilder
273265 // Use AltDirectorySeparatorChar so it's not interpreted as an escaped quote `\"`.
274- . AppendArgument ( useArtifactsPath
275- // We set ArtifactsPath for dotnet sdk 8+, fallback to IntermediateOutputPath for older sdks.
276- ? $ "/p:ArtifactsPath=\" { artifactsPaths . BuildArtifactsDirectoryPath } { Path . AltDirectorySeparatorChar } \" "
277- // This is technically incorrect (#2664, #2425), but it's the best we can do for older sdks.
278- // MSBuild does not support setting BaseIntermediateOutputPath from command line. https://github.com/dotnet/sdk/issues/2003#issuecomment-369408964
279- : $ "/p:IntermediateOutputPath=\" { artifactsPaths . IntermediateDirectoryPath } { Path . AltDirectorySeparatorChar } \" "
280- )
266+ . AppendArgument ( $ "/p:ArtifactsPath=\" { artifactsPaths . BuildArtifactsDirectoryPath } { Path . AltDirectorySeparatorChar } \" ")
281267 . AppendArgument ( $ "/p:OutDir=\" { artifactsPaths . BinariesDirectoryPath } { Path . AltDirectorySeparatorChar } \" ")
282268 // OutputPath is legacy, per-project version of OutDir. We set both just in case. https://github.com/dotnet/msbuild/issues/87
283269 . AppendArgument ( $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } { Path . AltDirectorySeparatorChar } \" ")
0 commit comments