dotnet / format

Home for the dotnet-format command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hangs at Loading workspace. in ubuntu docker container

dazinator opened this issue · comments

I am running dotnet format as part of an azure devops yaml pipeline, on a self hosted build agent, which is running as an ubuntu docker container.

Here is the yaml task:

 - task: DotNetCoreCLI@2      
      condition: ne(variables['Build.Reason'], 'PullRequest')
      continueOnError: true
      displayName: 'dotnet format'     
      inputs:
        command: 'custom'
        custom: 'format'
        workingDirectory: '$(Build.SourcesDirectory)/src'
        arguments: '--verbosity diagnostic --verify-no-changes'

Here is the AzDO task output - it just hangs at "loading workspace.":

Starting: dotnet format
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.221.0
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.
/usr/bin/dotnet format --verbosity diagnostic --verify-no-changes
  The dotnet runtime version is '6.0.19'.
  The dotnet CLI version is '6.0.411'.
  Using MSBuild.exe located in '/usr/share/dotnet/sdk/6.0.411/'.
  Formatting code files in workspace '/azp/_work/1/s/src/foo.sln'.
  Loading workspace.

This task eventually times out

The same pipeline running in a non dockerised setup is working, can see minor difference in version of cli and runtime version used in working environment - here is an example of successful output from same pipeline in this other env:

Starting: dotnet format
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.221.0
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.
/usr/bin/dotnet format --verbosity diagnostic --verify-no-changes
  The dotnet runtime version is '6.0.16'.
  The dotnet CLI version is '6.0.408'.
  Using MSBuild.exe located in '/usr/share/dotnet/sdk/6.0.408/'.
  Formatting code files in workspace '/home/foo/agent/_work/2/s/src/foo.sln'.
  Loading workspace.
    Determining projects to restore...
// shortened for brevity this goes on to succeed

Likewise if I establish an interactive terminal inside of the problematic container, cd into the directory /azp/_work/1/s/src/ and run dotnet format . I get the same hang

image

I think this comes down to dotnet format doing an impliciit restore:

 error NU1301: Unable to load the service index for source https://some-feed.com/v3/ind
ex.json. [/azp/_work/1/s/src/foo.sln]

In my pipeline if I install nuget, use a nuget authenticate step, and an explicit dotnet restore step, prior to running dotnet format with a no restore option, the hang is gone.

   - task: NuGetToolInstaller@1
      displayName: 'Install nuget'
      inputs:
        versionSpec: '5.8.0'    
   
   - task: NuGetAuthenticate@0
      displayName: 'nuget authenticate'

   - task: DotNetCoreCLI@2
      displayName: Restore
      inputs:
        command: custom
        custom: restore
        arguments: $(solutionDir) --configfile $(Build.SourcesDirectory)/src/NuGet.config /property:Configuration=$(buildConfiguration) 
      
   - task: DotNetCoreCLI@2           
      continueOnError: true
      displayName: 'dotnet format'
      timeoutInMinutes: 6
      inputs:
        command: 'custom'
        custom: 'format'
        workingDirectory: '$(Build.SourcesDirectory)/src'
        arguments: '--no-restore --verify-no-changes --verbosity diagnostic'