forked from thoemmi/7Zip4Powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.ps1
More file actions
35 lines (28 loc) · 1.28 KB
/
Copy pathpublish.ps1
File metadata and controls
35 lines (28 loc) · 1.28 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
[CmdLetBinding()]
param(
[Parameter(Mandatory=$false)]
[string]$Configuration = "Release",
[Parameter(Mandatory=$true)]
[string]$NuGetApiKey
)
# compile
& dotnet build --configuration $Configuration
# For publishing we need a folder with the same name as the module
$moduleTargetPath = Join-Path $PSScriptRoot "Module" "7Zip4Powershell"
if (Test-Path $moduleTargetPath) {
Remove-Item $moduleTargetPath -Recurse
}
New-Item $moduleTargetPath -ItemType Directory | Out-Null
# copy all required files to that folder
Copy-Item -Path (Join-Path $PSScriptRoot "7Zip4Powershell" "bin" $configuration "netstandard2.0" "*.*") -Exclude "JetBrains.Annotations.dll" -Destination $moduleTargetPath
# determine the version
dotnet tool restore
$versionInfo = dotnet tool run dotnet-gitversion | ConvertFrom-Json
$version = "$($versionInfo.Major).$($versionInfo.Minor).$($versionInfo.Patch)"
$prerelease = $versionInfo.NuGetPreReleaseTagV2
# patch the version in the .PSD1 file
$psd1File = Join-Path $moduleTargetPath "7Zip4PowerShell.psd1"
Write-Host "Patching version in $psd1File file to $version"
(((Get-Content $psd1File -Raw) -replace '\$version\$',$version) -replace '\$prerelease\$',$prerelease) | Set-Content $psd1File
# finally publish the
Publish-Module -Path $moduleTargetPath -NuGetApiKey $NuGetApiKey