Skip to content

Commit e160ecb

Browse files
committed
Merge branch 'master' into allow-major-precision
2 parents ac108d0 + 4e4bc2d commit e160ecb

File tree

7 files changed

+119
-17
lines changed

7 files changed

+119
-17
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and you are running Windows PowerShell, the command is:
3131
.\init.ps1
3232

3333
Everything in the repo may be built via building the solution file
34-
either from Visual Studio 2015 or the command line:
34+
either from Visual Studio 2015 or the VS2015 Developer Command Prompt:
3535

3636
.\build.ps1
3737

appveyor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ environment:
1515
secure: Ql19CstT9GvFNeSIAjXvgHXZg+/pNaYJ2jVkzde4LT2vwSyjiQgQ+M332wVYtu+r
1616
install:
1717
- ps: >-
18-
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/install-nuget-3-3-0.ps1'))
19-
2018
npm install npm -g
2119
before_build:
2220
- ps: >-

init.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
powershell.exe -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %*

init.ps1

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,37 @@ Restores all NuGet, NPM and Typings packages necessary to build this repository.
66
Param(
77
)
88

9-
Write-Host "Restoring NuGet packages..." -ForegroundColor Yellow
10-
if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src", "nuget restore")) {
11-
nuget restore "$PSScriptRoot\src" -Verbosity quiet
12-
}
9+
Push-Location $PSScriptRoot
10+
try {
11+
$toolsPath = "$PSScriptRoot\tools"
1312

14-
Write-Host "Restoring NPM packages..." -ForegroundColor Yellow
15-
Push-Location "$PSScriptRoot\src\nerdbank-gitversioning.npm"
16-
if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src\nerdbank-gitversioning.npm", "npm install")) {
17-
npm install --loglevel error
18-
}
13+
# First restore NuProj packages since the solution restore depends on NuProj evaluation succeeding.
14+
gci "$PSScriptRoot\src\project.json" -rec |? { $_.FullName -imatch 'nuget' } |% {
15+
& "$toolsPath\Restore-NuGetPackages.ps1" -Path $_ -Verbosity Quiet
16+
}
1917

20-
Write-Host "Restoring Typings..." -ForegroundColor Yellow
21-
if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src\nerdbank-gitversioning.npm", "typings install")) {
22-
.\node_modules\.bin\typings install
23-
}
18+
# Restore VS solution dependencies
19+
gci "$PSScriptRoot\src" -rec |? { $_.FullName.EndsWith('.sln') } |% {
20+
& "$toolsPath\Restore-NuGetPackages.ps1" -Path $_.FullName -Verbosity Quiet
21+
}
22+
23+
Write-Host "Restoring NPM packages..." -ForegroundColor Yellow
24+
Push-Location "$PSScriptRoot\src\nerdbank-gitversioning.npm"
25+
if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src\nerdbank-gitversioning.npm", "npm install")) {
26+
npm install --loglevel error
27+
}
2428

25-
Pop-Location
29+
Write-Host "Restoring Typings..." -ForegroundColor Yellow
30+
if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src\nerdbank-gitversioning.npm", "typings install")) {
31+
.\node_modules\.bin\typings install
32+
}
33+
34+
Write-Host "Successfully restored all dependencies" -ForegroundColor Yellow
35+
}
36+
catch {
37+
Write-Error "Aborting script due to error"
38+
exit $lastexitcode
39+
}
40+
finally {
41+
Pop-Location
42+
}

tools/Get-NuGetTool.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<#
2+
.SYNOPSIS
3+
Downloads the NuGet.exe tool and returns the path to it.
4+
#>
5+
6+
function Expand-ZIPFile($file, $destination) {
7+
if (!(Test-Path $destination)) { $null = mkdir $destination }
8+
$shell = new-object -com shell.application
9+
$zip = $shell.NameSpace((Resolve-Path $file).Path)
10+
foreach ($item in $zip.items()) {
11+
$shell.Namespace((Resolve-Path $destination).Path).copyhere($item)
12+
}
13+
}
14+
15+
$binaryToolsPath = "$PSScriptRoot\..\obj\tools"
16+
if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath }
17+
$nugetPath = "$binaryToolsPath\nuget.exe"
18+
if (!(Test-Path $nugetPath)) {
19+
$NuGetVersion = "3.3.0"
20+
Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow
21+
Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe" -OutFile $nugetPath
22+
}
23+
24+
$nugetPath

tools/Install-NuGetPackage.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<#
2+
.SYNOPSIS
3+
Installs a NuGet package.
4+
.PARAMETER PackageID
5+
The Package ID to install.
6+
.PARAMETER Version
7+
The version of the package to install. If unspecified, the latest stable release is installed.
8+
.PARAMETER Source
9+
The package source feed to find the package to install from.
10+
.PARAMETER PackagesDir
11+
The directory to install the package to. By default, it uses the Packages folder at the root of the repo.
12+
#>
13+
Param(
14+
[Parameter(Position=1,Mandatory=$true)]
15+
[string]$PackageId,
16+
[Parameter()]
17+
[string]$Version,
18+
[Parameter()]
19+
[string]$Source,
20+
[Parameter()]
21+
[switch]$Prerelease,
22+
[Parameter()]
23+
[ValidateSet('Quiet','Normal','Detailed')]
24+
[string]$Verbosity='normal'
25+
)
26+
27+
$nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"
28+
29+
try {
30+
Write-Verbose "Installing $PackageId..."
31+
$args = "Install",$PackageId
32+
if ($Version) { $args += "-Version",$Version }
33+
if ($Source) { $args += "-Source",$Source }
34+
if ($Prerelease) { $args += "-Prerelease" }
35+
$args += '-Verbosity',$Verbosity
36+
37+
$p = Start-Process $nugetPath $args -NoNewWindow -Wait -PassThru
38+
if ($p.ExitCode -ne 0) { throw }
39+
} finally {
40+
Pop-Location
41+
}

tools/Restore-NuGetPackages.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<#
2+
.SYNOPSIS
3+
Restores NuGet packages.
4+
.PARAMETER Path
5+
The path of the solution, directory, packages.config or project.json file to restore packages from.
6+
If not specified, the current directory is used.
7+
.PARAMETER Verbosity
8+
#>
9+
Param(
10+
[Parameter(Position=1)]
11+
[string]$Path=(Get-Location),
12+
[Parameter()]
13+
[ValidateSet('Quiet','Normal','Detailed')]
14+
[string]$Verbosity='normal'
15+
)
16+
17+
$nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"
18+
19+
Write-Verbose "Restoring NuGet packages for $Path"
20+
& $nugetPath restore $Path -Verbosity $Verbosity
21+
if ($lastexitcode -ne 0) { throw }

0 commit comments

Comments
 (0)