In Azure DevOps pipelines, you can use the DotNetCoreCLI task to build, test, or publish a .NET Core application. If you want to specify the output folder for your artifact when using the DotNetCoreCLI task, you can do so using the –output option or by configuring the build/publish properties in your project file. Here’s how you can do it:

Option 1: Using –output Option in DotNetCoreCLI Task

In your Azure DevOps pipeline YAML file, define the DotNetCoreCLI task. Here’s an example:

- task: DotNetCoreCLI@2 
inputs: 
    command: 'publish' 
    publishWebProjects: true 
    projects: '**/*.csproj' 
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/my-artifact' 
    modifyOutputPath: true

In this example, we’re using the –output argument to specify the output folder where the published artifacts will be placed. $(Build.ArtifactStagingDirectory) is a predefined variable in Azure DevOps that points to the staging directory for your build artifacts.

Option 2: Configuring Output Folder in Your Project File

If you want more fine-grained control over the output folder for your .NET Core application, you can configure it in your project file (e.g., .csproj for a .NET Core project). Open the .csproj file in a text editor and add an < OutputPath > element:

<PropertyGroup> 
        <OutputPath>$(ArtifactsDir)\my-artifact</OutputPath>
    </PropertyGroup>

This configuration specifies the output path for the project. You can replace $(ArtifactsDir)\my-artifact with the desired output path. This approach allows you to control the output location for all build/publish actions without needing to specify it in each DotNetCoreCLI task individually.
Remember to make sure your Azure DevOps pipeline YAML is set up to build and publish your .NET Core project correctly.
By using one of these options, you can control where your .NET Core build artifacts will be placed in your Azure DevOps pipeline.

Support On Demand!

.Net