{"id":9032,"date":"2023-11-23T06:46:15","date_gmt":"2023-11-23T06:46:15","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=9032"},"modified":"2023-11-23T06:46:15","modified_gmt":"2023-11-23T06:46:15","slug":"azure-pipeline-task-dotnetcorecli2","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/dot-net\/azure-pipeline-task-dotnetcorecli2","title":{"rendered":"Azure Pipeline Task DotNetCoreCLI@2 &#8211; Output Folder of Artifact"},"content":{"rendered":"<p>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 &#8211;output option or by configuring the build\/publish properties in your project file. Here&#8217;s how you can do it:<\/p>\n<h3>Option 1: Using &#8211;output Option in DotNetCoreCLI Task<\/h3>\n<p>In your Azure DevOps pipeline YAML file, define the DotNetCoreCLI task. Here&#8217;s an example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">- task: DotNetCoreCLI@2 \r\ninputs: \r\n    command: 'publish' \r\n    publishWebProjects: true \r\n    projects: '**\/*.csproj' \r\n    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\/my-artifact' \r\n    modifyOutputPath: true<\/pre>\n<p>In this example, we&#8217;re using the &#8211;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.<\/p>\n<h3>Option 2: Configuring Output Folder in Your Project File<\/h3>\n<p>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 &lt; OutputPath &gt; element:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;PropertyGroup&gt; \r\n        &lt;OutputPath&gt;$(ArtifactsDir)\\my-artifact&lt;\/OutputPath&gt;\r\n    &lt;\/PropertyGroup&gt;<\/pre>\n<p>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.<br \/>\nRemember to make sure your Azure DevOps pipeline YAML is set up to build and publish your .NET Core project correctly.<br \/>\nBy using one of these options, you can control where your .NET Core build artifacts will be placed in your Azure DevOps pipeline.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8211;output option or by configuring the build\/publish properties in your project file. Here&#8217;s how [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9034,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[20],"tags":[],"class_list":["post-9032","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9032"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=9032"}],"version-history":[{"count":1,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9032\/revisions"}],"predecessor-version":[{"id":9033,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/9032\/revisions\/9033"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/9034"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=9032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=9032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=9032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}