Description
Is 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