Skip to content

Commit 345595a

Browse files
authored
Merge pull request #905 from dotnet/dev/andre/libtemplateUpdate
Merge latest Library.Template
2 parents 02bd709 + 8be2d8c commit 345595a

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Best practices
44

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

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

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

4040
## Releases
4141

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

8686
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:
87-
`
87+
8888
```ps1
8989
git fetch
9090
git checkout origin/main

azurepipelines-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests?view=azure-devops
1+
# https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests
22
coverage:
33
status:
44
comments: on # add comment to PRs reporting diff in coverage of modified files

tools/Install-NuGetPackage.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
.PARAMETER ConfigFile
13+
The nuget.config file to use. By default, it uses :/nuget.config.
14+
.OUTPUTS
15+
System.String. The path to the installed package.
16+
#>
17+
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
18+
Param(
19+
[Parameter(Position=1,Mandatory=$true)]
20+
[string]$PackageId,
21+
[Parameter()]
22+
[string]$Version,
23+
[Parameter()]
24+
[string]$Source,
25+
[Parameter()]
26+
[switch]$Prerelease,
27+
[Parameter()]
28+
[string]$PackagesDir="$PSScriptRoot\..\packages",
29+
[Parameter()]
30+
[string]$ConfigFile="$PSScriptRoot\..\nuget.config",
31+
[Parameter()]
32+
[ValidateSet('Quiet','Normal','Detailed')]
33+
[string]$Verbosity='normal'
34+
)
35+
36+
$nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"
37+
38+
try {
39+
Write-Verbose "Installing $PackageId..."
40+
$nugetArgs = "Install",$PackageId,"-OutputDirectory",$PackagesDir,'-ConfigFile',$ConfigFile
41+
if ($Version) { $nugetArgs += "-Version",$Version }
42+
if ($Source) { $nugetArgs += "-FallbackSource",$Source }
43+
if ($Prerelease) { $nugetArgs += "-Prerelease" }
44+
$nugetArgs += '-Verbosity',$Verbosity
45+
46+
if ($PSCmdlet.ShouldProcess($PackageId, 'nuget install')) {
47+
$p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
48+
if ($null -ne $p.ExitCode -and $p.ExitCode -ne 0) { throw }
49+
}
50+
51+
# Provide the path to the installed package directory to our caller.
52+
Write-Output (Get-ChildItem "$PackagesDir\$PackageId.*")[0].FullName
53+
} finally {
54+
Pop-Location
55+
}

0 commit comments

Comments
 (0)