Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/DevCheck/DevCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,14 @@ function Install-NugetExe

$url = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'
$file = [IO.Path]::GetFullPath($NugetExe)

# Create directory if it doesn't exist
$fileDir = [IO.Path]::GetDirectoryName($file)
if (-not(Test-Path -Path $fileDir -PathType Container))
{
$null = New-Item -ItemType Directory -Path $fileDir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...\.user directory's created by DevCheck but could be a timing thing, or simply one tells DevCheck to only download nuget.exe and not do other things (which happen to create .user)

function Get-UserPath creates the .user directory but as $NugetExe could be anywhere (not just there) we have 2 choices

  1. Create the target dir for the caller
  2. Expect the target dir exists (caller's job to ensure it exists) AND ensure .user (and .temp) are created before doing any Nuget processing

I'm kinda partial to #2. Helps avoid human error if you typo your desired target dir DevCheck won't know any better and create it for you. That could have unintentional undesirable side effects.

RECOMMEND: Change line 1972 to

        Write-Host "...ERROR: $fileDir doesn't exist" -ForegroundColor Red -BackgroundColor Black
        $global:issues++
        return $false

and add at line 2050.5

# Ensure .temp and .user exist
$null = Get-TempPath
$null = Get-UserPath

}

Write-Host "Downloading nuget.exe from $url..."
Write-Verbose "Executing: curl.exe --output $file -L -# $url"
$null = Start-Process curl.exe -ArgumentList "--output $file -L -# $url" -Wait -NoNewWindow -PassThru
Expand Down
Loading