question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please provide a way to publish from a specific build directory (Azure pipelines)

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
baronfelcommented, May 4, 2022

Glad to hear it! Your final version doesn’t surprise me that it works - the publish command’s --output option just sets the PublishDir property, so I was pretty sure it would work. The OutputPath recommendation actually came from the same logic for the build command’s --output option. @rainersigwald should the SDK move to forwarding OutDir instead of OutputPath for dotnet build --output <some random dir>?

0reactions
gh-andrecommented, May 4, 2022

@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 the dotnet publish page. I use OutDir 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish and download build artifacts - Azure Pipelines
You can use Azure Pipelines to publish and download different types of artifacts as part of your CI/CD workflow.
Read more >
Azure build pipeline publish to specific folder
How do I publish without creating this directory? Microsoft Azure Collective. CI/CD Collective. azure · azure-devops · azure-pipelines ...
Read more >
Configuring CI/CD Pipelines as Code with YAML in Azure ...
Place the cursor on a blank line at the end of the build stage. Search the tasks for “publish build” and select the...
Read more >
PublishBuildArtifacts appears to publish sub-directories
Doc says Subdirectories of the specified path will not be published. Wildcards in the path are not supported. but from my testing that ......
Read more >
How to only include directory contents in Azure Publish ...
I've been using Azure Pipelines and Releases to build and publish artifacts. In SolutionX, there are projects ProjectY and ProjectYTests.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found