Action now uses extension releases from GitHub

- Replacing previous approach with downloading from VSIX gallery.
- Update readme to note the need to set GitHub token.
This commit is contained in:
josesimoes 2022-04-21 13:09:22 +01:00
Родитель 7c5ff8974c
Коммит 6874931742
2 изменённых файлов: 39 добавлений и 55 удалений

Просмотреть файл

@ -10,12 +10,17 @@ This action installs .NET **nanoFramework** build components required to build p
It doesn't require any configurations, simply installs the components.
>Note: in order to run properly this action requires setting up the GitHub token. There are numerous ways of doing this.
On the examples below it's being set on the action itself. If that's done elsewhere before the action runs, there is no need to do it again.
## Example usage
Install .NET **nanoFramework** build components as part of a GitHub Action building a project/solution.
```yaml
- uses: nanoframework/nanobuild@v1
env:
GITHUB_TOKEN: ${{ github.token }}
```
## Feedback and documentation

Просмотреть файл

@ -8,7 +8,7 @@ $webClient.UseDefaultCredentials = $true
function DownloadVsixFile($fileUrl, $downloadFileName)
{
Write-Host "Download VSIX file from $fileUrl to $downloadFileName"
# Write-Host "Download VSIX file from $fileUrl to $downloadFileName"
$webClient.DownloadFile($fileUrl,$downloadFileName)
}
@ -16,75 +16,54 @@ function DownloadVsixFile($fileUrl, $downloadFileName)
$tempDir = $env:RUNNER_TEMP
# Get extension information from VSIX Gallery feed
$vsixFeedXml = Join-Path -Path $tempDir -ChildPath "vs-extension-feed.xml"
$webClient.DownloadFile("http://vsixgallery.com/feed/author/nanoframework", $vsixFeedXml)
[xml]$feedDetails = Get-Content $vsixFeedXml
# Get latest releases of nanoFramework VS extension
$releaseList = [string]::Concat($(gh release list --limit 10 --repo nanoframework/nf-Visual-Studio-extension))
# Find which VS version is installed
$vsWherePath = "${env:PROGRAMFILES(X86)}\Microsoft Visual Studio\Installer\vswhere.exe"
# Write-Output "INFO: vsWherePath is '$vsWherePath'"
$vsInstance = $(&$vsWherePath -latest -property displayName)
$vsInstance | Write-Host
# find which entry corresponds to which VS version
for ($i = 0; $i -lt $feedDetails.feed.entry.Count; $i++) {
if($feedDetails.feed.entry[$i].id -eq '455f2be5-bb07-451e-b351-a9faf3018dc9')
{
# Write-Output "VS2019->$i"
$idVS2019 = $i
}
elseif($feedDetails.feed.entry[$i].id -eq 'bf694e17-fa5f-4877-9317-6d3664b2689a')
{
# Write-Output "VS2022->$i"
$idVS2022 = $i
}
elseif($feedDetails.feed.entry[$i].id -eq '47973986-ed3c-4b64-ba40-a9da73b44ef7')
{
# Write-Output "VS2017->$i"
$idVS2017 = $i
}
else {
# Write-Output "?????[$i]"
}
if($releaseList -match '\s\s(?<VS2022_version>v2022\.\d+\.\d+\.\d+)')
{
$vs2022Tag = $Matches.VS2022_version
}
# grab extension details according to VS version, starting from VS2022 down to VS2017
if($releaseList -match '\s\s(?<VS2019_version>v2019\.\d+\.\d+\.\d+)')
{
$vs2019Tag = $Matches.VS2019_version
}
# Find which VS version is installed
$VsWherePath = "${env:PROGRAMFILES(X86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$VsInstance = $(&$VSWherePath -latest -property displayName)
Write-Output "INFO: Latest VS is: $VsInstance"
# Get extension details according to VS version, starting from VS2022 down to VS2019
if($vsInstance.Contains('2022'))
{
$extensionUrl = $feedDetails.feed.entry[$idVS2022].content.src
$vsixPath = Join-Path $($tempDir) "nanoFramework.Tools.VS2022.Extension.zip"
$extensionVersion = $feedDetails.feed.entry[$idVS2022].Vsix.Version
$extensionUrl = "https://github.com/nanoframework/nf-Visual-Studio-extension/releases/download/$vs2022Tag/nanoFramework.Tools.VS2022.Extension.vsix"
$vsixPath = Join-Path $tempDir "nanoFramework.Tools.VS2022.Extension.zip"
$extensionVersion = $vs2022Tag
}
elseif($vsInstance.Contains('2019'))
{
$extensionUrl = $feedDetails.feed.entry[$idVS2019].content.src
$vsixPath = Join-Path $($tempDir) "nanoFramework.Tools.VS2019.Extension.zip"
$extensionVersion = $feedDetails.feed.entry[$idVS2019].Vsix.Version
}
elseif($vsInstance.Contains('2017'))
{
$extensionUrl = $feedDetails.feed.entry[$idVS2017].content.src
$vsixPath = Join-Path $($tempDir) "nanoFramework.Tools.VS2017.Extension.zip"
$extensionVersion = $feedDetails.feed.entry[$idVS2017].Vsix.Version
$extensionUrl = "https://github.com/nanoframework/nf-Visual-Studio-extension/releases/download/$vs2019Tag/nanoFramework.Tools.VS2019.Extension.vsix"
$vsixPath = Join-Path $tempDir "nanoFramework.Tools.VS2019.Extension.zip"
$extensionVersion = $vs2019Tag
}
# Download VS extension
DownloadVsixFile $extensionUrl $vsixPath
# unzip extension
# Write-Host "INFO: Unzip extension content"
Expand-Archive -LiteralPath $vsixPath -DestinationPath $tempDir\nf-extension\ | Write-Host
# Unzip extension
Write-Host "INFO: Unzip VS extension content"
Expand-Archive -LiteralPath $vsixPath -DestinationPath $tempDir\nf-extension\
# Copy build files to msbuild location
$vsPath = $(&$vsWherePath -latest -property installationPath)
# copy build files to msbuild location
$VsPath = $(&$VsWherePath -latest -property installationPath)
Write-Host "INFO: Copying build files to msbuild location"
$msbuildPath = Join-Path -Path $vsPath -ChildPath "\MSBuild"
$msbuildPath = $VsPath + "\MSBuild"
Copy-Item -Path "$tempDir\nf-extension\`$MSBuild\nanoFramework" -Destination $msbuildPath -Recurse
Write-Host ""
Write-Host "Installed .NET nanoFramework build components fom extension v$extensionVersion"
Write-Output "INFO: Installed VS extension $extensionVersion"