@@ -162,13 +162,7 @@ internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildParti
162162 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
163163 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
164164 . 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 )
172166 . ToString ( ) ;
173167
174168 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
179173 . AppendArgument ( GetMandatoryMsBuildSettings ( buildPartition . BuildConfiguration ) )
180174 . AppendArgument ( string . IsNullOrEmpty ( artifactsPaths . PackagesDirectoryName ) ? string . Empty : $ "/p:NuGetPackageRoot=\" { artifactsPaths . PackagesDirectoryName } \" ")
181175 . AppendArgument ( GetMsBuildBinLogArgument ( buildPartition , binLogSuffix ) )
182- . AppendArgument ( $ "--output \" { artifactsPaths . BinariesDirectoryPath } \" ")
183- . AppendArgument ( $ "/p:OutputPath=\" { artifactsPaths . BinariesDirectoryPath } \" ")
184- . AppendArgument ( $ "/p:IntermediateOutputPath=\" { artifactsPaths . IntermediateDirectoryPath } \" \\ ")
176+ . MaybeAppendOutputPaths ( artifactsPaths )
185177 . ToString ( ) ;
186178
187179 private static string GetMsBuildBinLogArgument ( BuildPartition buildPartition , string suffix )
@@ -249,4 +241,21 @@ private static string BuildAddPackageCommand(NuGetReference reference)
249241 return commandBuilder . ToString ( ) ;
250242 }
251243 }
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, per-project 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+ }
252261}
0 commit comments