microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.51k stars 2.62k forks source link

[BUG]: DotNetCoreCLI@2 publish task always publishes all projects #19565

Open dloukola opened 9 months ago

dloukola commented 9 months ago

New issue checklist

Task name

DotNetCoreCLI@2

Task version

2

Issue Description

Issue: This task ALWAYS attempts to publish all executable projects in the solution, no matter what is specified in the "projects" argument. It runs them as separate commands per project.

- task: DotNetCoreCLI@2
  displayName: "Build and Publish"
  inputs:
    command: publish
    projects: ${{ parameters.projects }}    
    arguments: '--configuration ${{ parameters.buildConfiguration }} --output $(Build.ArtifactStagingDirectory)/publish_output'
    zipAfterPublish: true

Expected: Only the projects specified in the "projects" argument should be built and published.

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

windows-latest

Relevant log output

C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.

"C:\Program Files\dotnet\dotnet.exe" publish [ProjectFilePath1] --configuration release --output D:\a\1\a\publish_output\[ProjectFileName1]
MSBuild version 17.9.4+90725d08d for .NET
  Determining projects to restore...
  Restored [ProjectFilePath1] (in 757 ms).

"C:\Program Files\dotnet\dotnet.exe" publish [ProjectFilePath2] --configuration release --output D:\a\1\a\publish_output\[ProjectFileName2]
MSBuild version 17.9.4+90725d08d for .NET
  Determining projects to restore...
  Restored [ProjectFilePath2] (in 468 ms).

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

stages:
  - stage: Build
    displayName: Build

    jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: 'windows-latest'

        steps:
          - task: DotNetCoreCLI@2
            displayName: "Build and Publish"
            inputs:
              command: publish
              projects: [PathToProjectFile]  
              arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)/publish_output'
              zipAfterPublish: true
ivanduplenskikh commented 9 months ago

Hi @dloukola thanks for reporting! The documentation does not indicate that this command works with the projects input. I'm not sure if this may be identified as a bug.

dloukola commented 9 months ago

I did notice that in the documentation. Is the intention of this task to publish all with no control of which project to publish at all?

benborra commented 7 months ago

Documentation clearly states a projects format in the example. https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2?view=azure-pipelines#publish-projects-to-specified-folder

Since this is just a wrapper around the 'dotnet publish' command and this can also anticipate a projects parameter, I'd suspect this to work. Trying with just running powershell commands in pipeline which does seem to work. Will continue with flow for the time being.