@@ -162,13 +162,7 @@ internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildParti
162
162
. AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
163
163
. AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
164
164
. AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
165
- // Fix #1377 (see comments in #1773).
166
- // We force the project to output binaries to a new directory.
167
- // Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path),
168
- // so we don't include it if we're building no-deps (only supported for integration tests).
169
- . AppendArgument ( excludeOutput ? string . Empty : $ "--output \" { artifactsPaths . BinariesDirectoryPath } \" ")
170
- . AppendArgument ( excludeOutput ? string . Empty : $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } \" ")
171
- . AppendArgument ( excludeOutput ? string . Empty : $ "/p:IntermediateOutputPath=\" { artifactsPaths . IntermediateDirectoryPath } \" \\ ")
165
+ . MaybeAppendOutputPaths ( artifactsPaths , excludeOutput )
172
166
. ToString ( ) ;
173
167
174
168
internal static string GetPublishCommand ( ArtifactsPaths artifactsPaths , BuildPartition buildPartition , string extraArguments = null , string binLogSuffix = null )
@@ -179,9 +173,7 @@ internal static string GetPublishCommand(ArtifactsPaths artifactsPaths, BuildPar
179
173
. AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
180
174
. AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
181
175
. AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
182
- . AppendArgument ( $ "--output \" { artifactsPaths . BinariesDirectoryPath } \" ")
183
- . AppendArgument ( $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } \" ")
184
- . AppendArgument ( $ "/p:IntermediateOutputPath=\" { artifactsPaths . IntermediateDirectoryPath } \" \\ ")
176
+ . MaybeAppendOutputPaths ( artifactsPaths )
185
177
. ToString ( ) ;
186
178
187
179
private static string GetMsBuildBinLogArgument ( BuildPartition buildPartition , string suffix )
@@ -249,4 +241,21 @@ private static string BuildAddPackageCommand(NuGetReference reference)
249
241
return commandBuilder . ToString ( ) ;
250
242
}
251
243
}
244
+
245
+ internal static class DotNetCliCommandExtensions
246
+ {
247
+ // Fix #1377 (see comments in #1773).
248
+ // We force the project to output binaries to a new directory.
249
+ // Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path),
250
+ // 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 )
252
+ => excludeOutput
253
+ ? stringBuilder
254
+ : stringBuilder
255
+ . AppendArgument ( $ "/p:IntermediateOutputPath=\" { artifactsPaths . IntermediateDirectoryPath } \" \\ ")
256
+ . AppendArgument ( $ "/p:OutDir=\" { artifactsPaths . BinariesDirectoryPath } \" ")
257
+ // OutputPath is legacy version of OutDir, we set both just in case. https://github.com/dotnet/msbuild/issues/87
258
+ . AppendArgument ( $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } \" ")
259
+ . AppendArgument ( $ "--output \" { artifactsPaths . BinariesDirectoryPath } \" ") ;
260
+ }
252
261
}
0 commit comments