HodorNV / ALOps

ALOps
59 stars 24 forks source link

Update for changes on DownloadFile.ps1 logic #637

Closed Arthurvdv closed 1 year ago

Arthurvdv commented 1 year ago

The logic of the DownloadFile.ps1 on https://github.com/StefanMaron/vsc-lintercop/blob/master/DownloadFile.ps1 has been updated today. There's a small change required to make the example working again.

@StefanMaron was a great help on this, thank you!

NAVFreak commented 1 year ago

Sure! I'm not a PowerShell-guru, so please be gentle about the quality ;-)

steps:
- task: PowerShell@2
  displayName: 'Download BusinessCentral.LinterCop.dll'
  inputs:
    targetType: 'inline'
    script: |
      $FileName = "DownloadFile.ps1"
      $GitHubUri = "https://raw.githubusercontent.com/StefanMaron/vsc-lintercop/master/$FileName"
      $BCLinterCopFileName = "BusinessCentral.LinterCop.dll"

      try
      {
          Write-Host "Downloading PowerShell script $GitHubFileName from $GitHubUri..." -ForegroundColor Yellow
          Invoke-WebRequest -Uri $GitHubUri -OutFile $env:AGENT_BUILDDIRECTORY\$FileName
      } 
      catch [System.Net.WebException] 
      {
          Write-Host "Error connecting to $GitHubUri. Please check your file name or repo name and try again." -ForegroundColor Red
      }

      Write-Host "Success. Now executing $FileName" -ForegroundColor Green

      & $env:AGENT_BUILDDIRECTORY\$FileName $env:BUILD_SOURCESDIRECTORY\$BCLinterCopFileName $false

@Arthurvdv , if I understand you right we need to change the URL

$GitHubUri = "https://raw.githubusercontent.com/StefanMaron/vsc-lintercop/master/$FileName" to $GitHubUri = "https://github.com/StefanMaron/vsc-lintercop/blob/master/$FileName"

But this doesn't seem to do the trick 🤔 image

Arthurvdv commented 1 year ago

@NAVFreak, no the changes are in the LinterCop filename area. I'll try to explain a bit more here.

There are two changes necessary to have it working again.

A) Completely remove this line

$BCLinterCopFileName = "BusinessCentral.LinterCop.dll"

B) Remove the '$BCLinterCopFileName' property (and backslash) from the last line to this:

& $env:AGENT_BUILDDIRECTORY\$FileName $env:BUILD_SOURCESDIRECTORY $false

The result should look like this

steps:
- task: PowerShell@2
  displayName: 'Download BusinessCentral.LinterCop.dll'
  inputs:
    targetType: 'inline'
    script: |
      $FileName = "DownloadFile.ps1"
      $GitHubUri = "https://raw.githubusercontent.com/StefanMaron/vsc-lintercop/master/$FileName"

      try
      {
          Write-Host "Downloading PowerShell script $GitHubFileName from $GitHubUri..." -ForegroundColor Yellow
          Invoke-WebRequest -Uri $GitHubUri -OutFile $env:AGENT_BUILDDIRECTORY\$FileName
      } 
      catch [System.Net.WebException] 
      {
          Write-Host "Error connecting to $GitHubUri. Please check your file name or repo name and try again." -ForegroundColor Red
      }

      Write-Host "Success. Now executing $FileName" -ForegroundColor Green

      & $env:AGENT_BUILDDIRECTORY\$FileName $env:BUILD_SOURCESDIRECTORY $false
NAVFreak commented 1 year ago

It works! 🎉🥳 Thank you so much for the quick response!

waldo1001 commented 1 year ago

Thank you so much!!

waldo1001 commented 1 year ago

Big thanks, Arthur.