@@ -33,9 +33,6 @@ public class DotNetCliCommand
33
33
34
34
[ PublicAPI ] public bool LogOutput { get ; }
35
35
36
- // Whether to use ArtifactsPath or IntermediateOutputPath. ArtifactsPath is only supported in dotnet sdk 8+.
37
- private readonly bool _useArtifactsPath ;
38
-
39
36
public DotNetCliCommand ( string cliPath , string arguments , GenerateResult generateResult , ILogger logger ,
40
37
BuildPartition buildPartition , IReadOnlyList < EnvironmentVariable > environmentVariables , TimeSpan timeout , bool logOutput = false )
41
38
{
@@ -47,8 +44,6 @@ public DotNetCliCommand(string cliPath, string arguments, GenerateResult generat
47
44
EnvironmentVariables = environmentVariables ;
48
45
Timeout = timeout ;
49
46
LogOutput = logOutput || ( buildPartition is not null && buildPartition . LogBuildOutput ) ;
50
-
51
- _useArtifactsPath = DotNetCliCommandExecutor . DotNetSdkSupportsArtifactsPath ( cliPath ) ;
52
47
}
53
48
54
49
public DotNetCliCommand WithArguments ( string arguments )
@@ -77,12 +72,12 @@ public BuildResult RestoreThenBuild()
77
72
if ( BuildPartition . ForcedNoDependenciesForIntegrationTests )
78
73
{
79
74
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 ) ) ) ;
81
76
if ( ! restoreResult . IsSuccess )
82
77
return BuildResult . Failure ( GenerateResult , restoreResult . AllInformation ) ;
83
78
84
79
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 ) ) )
86
81
. ToBuildResult ( GenerateResult ) ;
87
82
}
88
83
else
@@ -136,62 +131,59 @@ public DotNetCliCommandResult AddPackages()
136
131
137
132
public DotNetCliCommandResult Restore ( )
138
133
=> DotNetCliCommandExecutor . Execute ( WithArguments (
139
- GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , Arguments , "restore" ) ) ) ;
134
+ GetRestoreCommand ( GenerateResult . ArtifactsPaths , BuildPartition , Arguments , "restore" ) ) ) ;
140
135
141
136
public DotNetCliCommandResult Build ( )
142
137
=> DotNetCliCommandExecutor . Execute ( WithArguments (
143
- GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , Arguments , "build" ) ) ) ;
138
+ GetBuildCommand ( GenerateResult . ArtifactsPaths , BuildPartition , Arguments , "build" ) ) ) ;
144
139
145
140
public DotNetCliCommandResult BuildNoRestore ( )
146
141
=> 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" ) ) ) ;
148
143
149
144
public DotNetCliCommandResult Publish ( )
150
145
=> DotNetCliCommandExecutor . Execute ( WithArguments (
151
- GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , _useArtifactsPath , Arguments , "publish" ) ) ) ;
146
+ GetPublishCommand ( GenerateResult . ArtifactsPaths , BuildPartition , Arguments , "publish" ) ) ) ;
152
147
153
148
// PublishNoBuildAndNoRestore was removed because we set --output in the build step. We use the implicit build included in the publish command.
154
149
public DotNetCliCommandResult PublishNoRestore ( )
155
150
=> 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" ) ) ) ;
157
152
158
153
internal static IEnumerable < string > GetAddPackagesCommands ( BuildPartition buildPartition )
159
154
=> GetNuGetAddPackageCommands ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) ;
160
155
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 )
163
157
=> new StringBuilder ( )
164
158
. AppendArgument ( "restore" )
165
159
. AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "--packages \" { artifactsPaths . PackagesDirectoryName } \" ")
166
160
. AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
167
161
. AppendArgument ( extraArguments )
168
162
. AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
169
163
. AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
170
- . MaybeAppendOutputPaths ( artifactsPaths , useArtifactsPath , true , excludeOutput )
164
+ . MaybeAppendOutputPaths ( artifactsPaths , true , excludeOutput )
171
165
. ToString ( ) ;
172
166
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 )
175
168
=> new StringBuilder ( )
176
169
. AppendArgument ( $ "build -c { buildPartition . BuildConfiguration } ") // we don't need to specify TFM, our auto-generated project contains always single one
177
170
. AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
178
171
. AppendArgument ( extraArguments )
179
172
. AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
180
173
. AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
181
174
. AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
182
- . MaybeAppendOutputPaths ( artifactsPaths , useArtifactsPath , excludeOutput : excludeOutput )
175
+ . MaybeAppendOutputPaths ( artifactsPaths , excludeOutput : excludeOutput )
183
176
. ToString ( ) ;
184
177
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 )
187
179
=> new StringBuilder ( )
188
180
. AppendArgument ( $ "publish -c { buildPartition . BuildConfiguration } ") // we don't need to specify TFM, our auto-generated project contains always single one
189
181
. AppendArgument ( GetCustomMsBuildArguments ( buildPartition . RepresentativeBenchmarkCase , buildPartition . Resolver ) )
190
182
. AppendArgument ( extraArguments )
191
183
. AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
192
184
. AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
193
185
. AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
194
- . MaybeAppendOutputPaths ( artifactsPaths , useArtifactsPath )
186
+ . MaybeAppendOutputPaths ( artifactsPaths )
195
187
. ToString ( ) ;
196
188
197
189
private static string GetMsBuildBinLogArgument ( BuildPartition buildPartition , string suffix )
@@ -266,18 +258,12 @@ internal static class DotNetCliCommandExtensions
266
258
// We force the project to output binaries to a new directory.
267
259
// Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path),
268
260
// 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 )
270
262
=> excludeOutput
271
263
? stringBuilder
272
264
: stringBuilder
273
265
// 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 } \" ")
281
267
. AppendArgument ( $ "/p:OutDir=\" { artifactsPaths . BinariesDirectoryPath } { Path . AltDirectorySeparatorChar } \" ")
282
268
// OutputPath is legacy, per-project version of OutDir. We set both just in case. https://github.com/dotnet/msbuild/issues/87
283
269
. AppendArgument ( $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } { Path . AltDirectorySeparatorChar } \" ")
0 commit comments