Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Best practices

* Use Windows PowerShell or [PowerShell Core][pwsh] (including on Linux/OSX) to run .ps1 scripts.
- Use Windows PowerShell or [PowerShell Core][pwsh] (including on Linux/OSX) to run .ps1 scripts.
Some scripts set environment variables to help you, but they are only retained if you use PowerShell as your shell.

## Prerequisites
Expand Down Expand Up @@ -35,7 +35,7 @@ Building, testing, and packing this repository can be done by using the standard
The `nerdbank-streams` NPM package builds out of the `src/nerdbank-streams` directory.
Please review the [CONTRIBUTING.md](src/nerdbank-streams/CONTRIBUTING.md) document in that directory for instructions.

[pwsh]: https://docs.microsoft.com/powershell/scripting/install/installing-powershell?view=powershell-6
[pwsh]: https://learn.microsoft.com/powershell/scripting/install/installing-powershell

## Releases

Expand Down Expand Up @@ -84,7 +84,7 @@ If Renovate is not creating pull requests when you expect it to, check that the
### Maintaining your repo based on this template

The best way to keep your repo in sync with Library.Template's evolving features and best practices is to periodically merge the template into your repo:
`

```ps1
git fetch
git checkout origin/main
Expand Down
2 changes: 1 addition & 1 deletion azurepipelines-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests?view=azure-devops
# https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests
coverage:
status:
comments: on # add comment to PRs reporting diff in coverage of modified files
Expand Down
55 changes: 55 additions & 0 deletions tools/Install-NuGetPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
Installs a NuGet package.
.PARAMETER PackageID
The Package ID to install.
.PARAMETER Version
The version of the package to install. If unspecified, the latest stable release is installed.
.PARAMETER Source
The package source feed to find the package to install from.
.PARAMETER PackagesDir
The directory to install the package to. By default, it uses the Packages folder at the root of the repo.
.PARAMETER ConfigFile
The nuget.config file to use. By default, it uses :/nuget.config.
.OUTPUTS
System.String. The path to the installed package.
#>
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
Param(
[Parameter(Position=1,Mandatory=$true)]
[string]$PackageId,
[Parameter()]
[string]$Version,
[Parameter()]
[string]$Source,
[Parameter()]
[switch]$Prerelease,
[Parameter()]
[string]$PackagesDir="$PSScriptRoot\..\packages",
[Parameter()]
[string]$ConfigFile="$PSScriptRoot\..\nuget.config",
[Parameter()]
[ValidateSet('Quiet','Normal','Detailed')]
[string]$Verbosity='normal'
)

$nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"

try {
Write-Verbose "Installing $PackageId..."
$nugetArgs = "Install",$PackageId,"-OutputDirectory",$PackagesDir,'-ConfigFile',$ConfigFile
if ($Version) { $nugetArgs += "-Version",$Version }
if ($Source) { $nugetArgs += "-FallbackSource",$Source }
if ($Prerelease) { $nugetArgs += "-Prerelease" }
$nugetArgs += '-Verbosity',$Verbosity

if ($PSCmdlet.ShouldProcess($PackageId, 'nuget install')) {
$p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
if ($null -ne $p.ExitCode -and $p.ExitCode -ne 0) { throw }
}

# Provide the path to the installed package directory to our caller.
Write-Output (Get-ChildItem "$PackagesDir\$PackageId.*")[0].FullName
} finally {
Pop-Location
}
Loading