Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectoryNotFoundException when extracting downloaded .NET 9 SDK by Powershell in the UseDotNet2Task #20469

Closed
4 of 7 tasks
bartvanhoey opened this issue Sep 25, 2024 · 2 comments
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug

Comments

@bartvanhoey
Copy link

New issue checklist

Task name

UseDotNet@2

Task version

No response

Issue Description

DirectoryNotFoundException when extracting downloaded .NET 9 SDK by Powershell in the UseDotNet2Task

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

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows

Relevant log output

Zu installierendes Tool: .NET Core sdk Version 9.0.100-preview.1.24101.2.
Version 9.0.100-preview.1.24101.2 in Kanal "9.0" für benutzerseitig angegebene Versionsspezifikation gefunden: 9.0.100-preview.1.24101.2
Die Version 9.0.100-preview.1.24101.2 wurde nicht im Cache gefunden.
URL zum Herunterladen von .NET Core sdk, Version 9.0.100-preview.1.24101.2 wird abgerufen.
Die Betriebssystemplattform wird ermittelt, um das richtige Downloadpaket für das Betriebssystem zu finden.
[command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'C:\Users\WlodarczykD\Desktop\Agent\_work\_tasks\UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6\2.0.7\externals\get-os-platform.ps1'"
Primary:win-x64
Erkannte Plattform (primär): win-x64
Wird heruntergeladen: https://download.visualstudio.microsoft.com/download/pr/4c55bc67-e478-4fdc-abe3-08b8dd64f4e4/9cf46c3018f477a93a8498850e6c122b/dotnet-sdk-9.0.100-preview.1.24101.2-win-x64.zip
Das heruntergeladene Paket C:\Users\WlodarczykD\Desktop\Agent\_work\_temp\a99876a3-aa84-433e-bf83-64fc670a2c62 wird extrahiert.
Archiv wird extrahiert
[command]C:\Windows\system32\chcp.com 65001
Active code page: 65001
[command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WlodarczykD\Desktop\Agent\_work\_temp\a99876a3-aa84-433e-bf83-64fc670a2c62', 'C:\Users\WlodarczykD\Desktop\Agent\_work\_temp\a846e048-8cb7-48a7-b9a1-6592eece6719')"
Exception calling "ExtractToDirectory" with "2" argument(s): "Could not find a part of the path 'C:\Users\WlodarczykD\D
esktop\Agent\_work\_temp\a846e048-8cb7-48a7-b9a1-6592eece6719\sdk\9.0.100-preview.1.24101.2\DotnetTools\dotnet-watch\9.
0.100-preview.1.24101.1\tools\net9.0\any\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe.confi
g'."
At line:1 char:111
+ ... catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\U ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DirectoryNotFoundException
 
##[error]Fehler beim Installieren der Version 9.0.100-preview.1.24101.2 in Pfad "C:\Users\WlodarczykD\Desktop\Agent\_work\_tool/dotnet". Fehler: Fehler beim Extrahieren des heruntergeladenen Pakets. Fehler: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
##[section]Abschließen: Install .NET9

Full task logs with system.debug enabled

dd

Repro steps

trigger:
- main

pool: 'Default'
 
variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'
    
    
- task: UseDotNet@2
  displayName: 'Install .NET9'
  inputs:
    version: 9.0.100-preview.1.24101.2

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
@ivanduplenskikh
Copy link
Contributor

@bartvanhoey, thank you for bringing this to our attention.
It seems the issue with the UseDotNet@2 task may stem from an underlying environment
or background settings that cannot be identified explicitly from the error output.

You have linked your problem in the related issue #10879 and I have found another one issue #7692.
The similarity between your issue and issue #10879 seems remarkably notable:
both error outputs contain the exception type DirectoryNotFoundException
I think that it might related to the long path, despite the ExtractToDirectory method has the distinct exception PathTooLongException

Could you consider relocating your agent to the root of C drive, or running a specific cmd in Powershell with elevated privileges?

Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1

@ivanduplenskikh ivanduplenskikh added Area: ABTT Akvelon Build Tasks Team area of work and removed triage Area: Release Area: Artifacts labels Sep 25, 2024
@bartvanhoey
Copy link
Author

@ivanduplenskikh Thanks!

This task in AzureDevops Build Pipeline before the UseDotNet@2 fixed the issue for me:

  • task: PowerShell@2
    displayName: Execute Powershell to fix PathTooLongException
    inputs:
    targetType: inline
    script: Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ABTT Akvelon Build Tasks Team area of work bug
Projects
None yet
Development

No branches or pull requests

2 participants