Closed Arthurvdv closed 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 🤔
@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
It works! 🎉🥳 Thank you so much for the quick response!
Thank you so much!!
Big thanks, Arthur.
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!