Please provide a way to publish from a specific build directory (Azure pipelines)
See original GitHub issueIs your feature request related to a problem? Please describe.
Azure DevOps pipelines provide distinct directories for different build purposes that work out well in C++ projects, but not so much for .Net Core ones.
In a C++ project I can build source in Build.SourcesDirectory
, output to Build.BinariesDirectory
and package artifacts in Build.ArtifactStagingDirectory
. This allows me to maintain incremental builds on my own build agents because the build output directory keeps previous build object files and when new source is checked out, only changed source files are being compiled.
With dotnet
builds, I can either build in a different directory or publish to a different directory, but I don’t see a way to combine those. That is, a typical dotnet
build would look like this:
dotnet restore -p:Platform="Any CPU" myapp.sln
dotnet clean --configuration Release -p:Platform="Any CPU" myapp.sln
dotnet build --no-restore --configuration Release -p:Platform="Any CPU" myapp.sln
dotnet publish --no-self-contained --no-build `
--configuration Release -p:Platform="Any CPU" `
--output $(Build.ArtifactStagingDirectory) myapp.sln
This, however, builds right in the source directory, which gets cleaned with every checkout. What I want is to be able to tell dotnet publish
to output to Build.ArtifactStagingDirectory
, avoid building and instead use build output from Build.BinariesDirectory
for publishing.
Just to be clear, yes, there’s a way not to clean the source directory, but that’s a hack - I want the source directory behave as it is intended - get the fresh source on every check-out, so there are no lingering source files, as some of them may get deleted in development.
Describe the solution you’d like
I would like to be able to specify for dotnet publish
build output and publish output directories, like this:
dotnet build --no-restore --configuration Release -p:Platform="Any CPU" `
--output $(Build.BinariesDirectory) myapp.sln
dotnet publish --no-self-contained --no-build --configuration Release -p:Platform="Any CPU" `
--build-output $(Build.BinariesDirectory) `
--output $(Build.ArtifactStagingDirectory) myapp.sln
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Glad to hear it! Your final version doesn’t surprise me that it works - the
publish
command’s--output
option just sets thePublishDir
property, so I was pretty sure it would work. TheOutputPath
recommendation actually came from the same logic for thebuild
command’s--output
option. @rainersigwald should the SDK move to forwardingOutDir
instead ofOutputPath
fordotnet build --output <some random dir>
?@baronfel This sounds like a workaround for keeping these paths in the source, which will result in more complex build setups because these variables will need to be set up for all builds, including local ones, even if they are defaulted. Having paths passed in explicitly is a self-documenting approach that works for any path.
Anyway, having said that, it’s good to know that this approach is possible and maybe somebody who comes across of this thread will find it more usable for their purposes.
As far as this issue is concerned,
OutDir
solves this for me, if you want to close it. I would suggest documenting this on thedotnet publish
page. I useOutDir
for C++ builds, but it didn’t occur to me that it would work out here as well. Others may be in the same boat.Thanks again for your help.