Skip to content

Commit

Permalink
dotnet.py: --output is no longer supported with `dotnet build/publi…
Browse files Browse the repository at this point in the history
…sh` (#2774)

.. with .sln files. Instead, pass `/p:PublishDir=..` to the build
command.

This changed in dotnet/sdk#29065, and broke
`dotnet-runtime-perf` pipeline's blazor scenarios.

```
$ dotnet publish /home/helixbot/work/A8850905/p/performance/src/scenarios/blazorpizza/app/BlazingPizza.sln --configuration Release --output pub /p:NuGetPackageRoot=/home/helixbot/work/A8850905/w/A9A608EA/u/artifacts/packages/ /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 --framework net7.0 /p:_TrimmerDumpDependencies=true -bl:./traces/blazor_publish.binlog -p:WasmNativeWorkload=false
MSBuild version 17.5.0-preview-22601-03+a2490dd3f for .NET

/home/helixbot/work/A8850905/p/dotnet/sdk/8.0.100-alpha.1.22606.3/Current/SolutionFile/ImportAfter/Microsoft.NET.Sdk.Solution.targets(36,5):
    error NETSDK1194: The "--output" option isn't supported when building a solution. [/home/helixbot/work/A8850905/p/performance/src/scenarios/blazorpizza/app/BlazingPizza.sln]
```

Details:

When building a solution, passing a relative path to `PublishDir` gets
evaluated per-project. So, if we pass `-p:PublishDir=pub` then we get
`pub/` sub-directories for each of the projects.

But when used with `--output pub`, output for all the projects goes to
the same directory. To have the same behavior use an absolute path.
  • Loading branch information
radical authored Dec 7, 2022
1 parent 13715bb commit def4ce2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/dotnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def build(self,
]

if output_to_bindir:
cmdline = cmdline + ['--output', self.__bin_directory]
cmdline += self.__get_output_build_arg(self.__bin_directory)

if runtime_identifier:
cmdline = cmdline + ['--runtime', runtime_identifier]
Expand All @@ -362,7 +362,7 @@ def build(self,
]

if output_to_bindir:
cmdline = cmdline + ['--output', self.__bin_directory]
cmdline += self.__get_output_build_arg(self.__bin_directory)

if runtime_identifier:
cmdline = cmdline + ['--runtime', runtime_identifier]
Expand Down Expand Up @@ -436,10 +436,10 @@ def publish(self,
'dotnet', 'publish',
self.csproj_file,
'--configuration', configuration,
'--output', output_dir,
"/p:NuGetPackageRoot={}".format(packages_path),
'/p:UseSharedCompilation=false', '/p:BuildInParallel=false', '/m:1'
]
cmdline += self.__get_output_build_arg(output_dir)
if runtime_identifier:
cmdline += ['--runtime', runtime_identifier]

Expand All @@ -456,6 +456,14 @@ def publish(self,
self.working_directory
)

def __get_output_build_arg(self, outdir) -> list:
# dotnet build/publish does not support `--output` with sln files
if path.splitext(self.csproj_file)[1] == '.sln':
outdir = outdir if path.isabs(outdir) else path.abspath(outdir)
return ['/p:PublishDir=' + outdir]
else:
return ['--output', outdir]

@staticmethod
def __print_complus_environment() -> None:
getLogger().info('-' * 50)
Expand Down

0 comments on commit def4ce2

Please sign in to comment.