-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathpack-local.ps1
More file actions
51 lines (45 loc) · 1.85 KB
/
Copy pathpack-local.ps1
File metadata and controls
51 lines (45 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Packs DiffEngine into ./nugets under a version no feed will ever publish, so a consumer in
# another repo can reference the working tree rather than the last release.
#
# The version is fixed rather than stamped with the time, so the consumer's pin stays put across
# rebuilds. That only works because the cached copy is deleted first: NuGet caches by id and
# version, and would otherwise keep serving the package from the previous run forever.
#
# ./pack-local.ps1 pack as 20.0.0-local
# ./pack-local.ps1 -Version 1.2.3 pack as 1.2.3
#
# Consuming it from Verify is two lines, both in src: a local <add> in nuget.config pointing at
# this folder, and the DiffEngine PackageVersion set to the same version.
[CmdletBinding()]
param(
[string] $Version = '20.0.0-local'
)
$ErrorActionPreference = 'Stop'
$root = $PSScriptRoot
$output = Join-Path $root 'nugets'
# The cached copy of a version already restored once, which is what makes a fixed version safe
$cached = Join-Path $env:USERPROFILE ".nuget\packages\diffengine\$Version"
if (Test-Path $cached)
{
Write-Host "Removing cached $Version"
Remove-Item $cached -Recurse -Force
}
$package = Join-Path $output "DiffEngine.$Version.nupkg"
if (Test-Path $package)
{
Remove-Item $package -Force
}
# A build rather than a pack: ProjectDefaults sets GeneratePackageOnBuild for Release, and the
# viewer heads DiffEngine bundles are published by targets that only run on the way through.
Write-Host "Packing $Version"
dotnet build (Join-Path $root 'src\DiffEngine\DiffEngine.csproj') --configuration Release -p:Version=$Version
if ($LASTEXITCODE -ne 0)
{
throw "Build failed with $LASTEXITCODE"
}
if (-not (Test-Path $package))
{
throw "No package at $package"
}
Write-Host "Packed $package"
Write-Host 'Consumers should clear obj/ or restore with --no-cache if they had this version already.'