Skip to content

Commit 93f6c03

Browse files
committed
init: Check if nanoFramework is already installed
1 parent 62c00f3 commit 93f6c03

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Build/init.ps1

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,31 @@ if (-not (Test-Path "$root/Tools/reportgenerator.exe")) {
1414
Write-Host -Foreground Green "Download dotnet-reportgenerator-globaltool...OK."
1515
}
1616

17+
$VsWherePath = "${env:PROGRAMFILES(X86)}\Microsoft Visual Studio\Installer\vswhere.exe"
18+
$VsPath = $(&$VsWherePath -latest -property installationPath)
19+
$msbuildPath = Join-Path -Path $VsPath -ChildPath "\MSBuild"
20+
1721
# Install .NET nanoFramework build components
22+
if (!(Test-Path "$msbuildPath/nanoFramework")) {
23+
Write-Host "Installing .NET nanoFramework VS extension..."
1824

19-
Write-Host "Installing .NET nanoFramework VS extension..."
25+
[System.Net.WebClient]$webClient = New-Object System.Net.WebClient
26+
$webClient.UseDefaultCredentials = $true
2027

21-
[System.Net.WebClient]$webClient = New-Object System.Net.WebClient
22-
$webClient.UseDefaultCredentials = $true
28+
$vsixFeedXml = Join-Path -Path $tempDir -ChildPath "vs-extension-feed.xml"
29+
$webClient.DownloadFile("http://vsixgallery.com/feed/author/nanoframework", $vsixFeedXml)
30+
[xml]$feedDetails = Get-Content $vsixFeedXml
2331

24-
$vsixFeedXml = Join-Path -Path $tempDir -ChildPath "vs-extension-feed.xml"
25-
$webClient.DownloadFile("http://vsixgallery.com/feed/author/nanoframework", $vsixFeedXml)
26-
[xml]$feedDetails = Get-Content $vsixFeedXml
32+
$extensionUrl = $feedDetails.feed.entry[1].content.src
33+
$vsixPath = Join-Path -Path $tempDir -ChildPath "nf-extension.zip"
34+
$extensionVersion = $feedDetails.feed.entry[0].Vsix.Version
35+
$webClient.DownloadFile($extensionUrl,$vsixPath)
36+
Expand-Archive -LiteralPath $vsixPath -DestinationPath $tempDir\nf-extension\ | Write-Host
2737

28-
$extensionUrl = $feedDetails.feed.entry[1].content.src
29-
$vsixPath = Join-Path -Path $tempDir -ChildPath "nf-extension.zip"
30-
$extensionVersion = $feedDetails.feed.entry[0].Vsix.Version
31-
$webClient.DownloadFile($extensionUrl,$vsixPath)
32-
Expand-Archive -LiteralPath $vsixPath -DestinationPath $tempDir\nf-extension\ | Write-Host
38+
Copy-Item -Path "$tempDir\nf-extension\`$MSBuild\nanoFramework" -Destination $msbuildPath -Recurse
3339

34-
$VsWherePath = "${env:PROGRAMFILES(X86)}\Microsoft Visual Studio\Installer\vswhere.exe"
35-
$VsPath = $(&$VsWherePath -latest -property installationPath)
36-
$msbuildPath = Join-Path -Path $VsPath -ChildPath "\MSBuild"
37-
Copy-Item -Path "$tempDir\nf-extension\`$MSBuild\nanoFramework" -Destination $msbuildPath -Recurse
38-
39-
Write-Host "Installed VS extension v$extensionVersion"
40+
Write-Host "Installed VS extension v$extensionVersion"
41+
}
4042

4143
# Cleanup
4244
[system.io.Directory]::Delete($tempDir, $true) | out-null

0 commit comments

Comments
 (0)