microsoft / azure-pipelines-tasks

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

SDK changes incorrectly/unexpectedly #16683

Open BMurri opened 1 year ago

BMurri commented 1 year ago

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug or Question

Enter Task Name: DotNetCoreCLI@2

Environment

Issue Description

Different instances of this task are running different versions of dotnet.exe, even though the settings are the same and only one SDK is expected for the entire pipeline.

All *proj files start out this same way:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

Compare the task dotnet build and dotnet publish TesApi and TriggerService

yaml:

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    arguments: '-c release -o $(Build.ArtifactStagingDirectory)'

Beginning of log:

Starting: dotnet build
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.202.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
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" build "-dl:CentralLogger,\"D:\a\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.202.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"*ForwardingLogger,\"D:\a\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.202.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"" -c release -o D:\a\1\a
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

to

yaml:

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet publish TesApi and TriggerService'
  inputs:
    command: publish
    publishWebProjects: false
    projects: |
     **/TesApi.Web.csproj
     **/TriggerService.csproj

    arguments: '-r linux-x64 -c release -o $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: false

Beginning of log:

Starting: dotnet publish TesApi and TriggerService
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.202.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
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:\hostedtoolcache\windows\dotnet\dotnet.exe publish D:\a\1\s\src\TesApi.Web\TesApi.Web.csproj -r linux-x64 -c release -o D:\a\1\a\TesApi.Web

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.201

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Task logs

See above

BMurri commented 1 year ago

Turns out adding the UseDotNet@2 task to the pipeline causes the desired SDK to be used by both tasks, but it doesn't alter the fact that both invocations of the exact same task-name/version employ two different paths to the dotnet binary. It's completely unexpected that two subsequent invocations of the exact same task would result in different binaries being run.

rachel-wright commented 1 year ago

Adding the UseDotNet@2 task did not resolve this issue for me. The DotNetCoreCLI@2 seems to always use an older version of the CLI. The project in question here was built with Azure Function Core Tools. The publish task works when run as a script, but fails when run using DotNetCoreCLI@2

yaml:

steps:
- task: UseDotNet@2
  inputs:
    version: '6.x'

- task: DotNetCoreCLI@2
  inputs:
    command: build

- script: |
    dotnet publish
  continueOnError: true

- task: DotNetCoreCLI@2
  inputs:
    command: publish
  continueOnError: true

Start of logs for both the build and publish tasks using the DotNetCoreCLI@2 task:

==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.208.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
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.
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

scottpidzarko commented 1 year ago

Commenting so this won't go state. I am encountering this as well.

BMurri commented 1 year ago

In actions/runner-images#7218 it was discovered that the order of directories in PATH seems to change randomly with NO changes to any pipeline job anything. That issue was closed as a duplicate of another issue that doesn't appear to have anything to do with PATH, but that's a soapbox for another day.

I think it would be prudent to consider that PATH is suddenly changing between builds with no changes that should warrant any change to PATH. Furthermore, it appears that most of the pipeline components look for their binaries via PATH and never verify that the correct binary is actually invoked.

github-actions[bot] commented 10 months ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

BMurri commented 10 months ago

Commenting so this won't go state. This needs attention from someone in Azure.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

scottpidzarko commented 4 months ago

Commenting again so this won't go stale.

On Fri, Mar 15, 2024, 9:06 p.m. github-actions[bot] < @.***> wrote:

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

— Reply to this email directly, view it on GitHub https://github.com/microsoft/azure-pipelines-tasks/issues/16683#issuecomment-2001343868, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASCFEUL2Z7W7RUH4K6K5VLYYOZMFAVCNFSM55K3TPUKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBQGEZTIMZYGY4A . You are receiving this because you commented.Message ID: @.***>

Flija0 commented 1 month ago

Commenting again so this won't go stale.