-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpack.ps1
59 lines (47 loc) · 1.58 KB
/
pack.ps1
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
52
53
54
55
56
57
58
59
# apiKey
$apiKey = $args[0]
# Paths
$rootFolder = (Get-Item -Path "./" -Verbose).FullName
$packFolder = Join-Path $rootFolder "output"
$hasPath = Test-Path($packFolder)
if (-Not $hasPath) {
new-item -path $rootFolder -name "output" -type directory
}
Write-Host ("PackFolder: " + $packFolder)
# List of projects
$projects = (
"src/KissUtil"
)
# Remove item
Set-Location $packFolder
Remove-Item (Join-Path $packFolder "*.nupkg")
# Rebuild solution
Set-Location $rootFolder
& dotnet restore
# Create all packages
foreach($project in $projects) {
$projectFolder = Join-Path $rootFolder $project
$i += 1
$projectName = ($project -split '/')[-1]
# Create nuget pack
Write-Host ("-----===[ $i / " + $projects.count + " - " + $projectName + " ]===-----")
Set-Location $projectFolder
& dotnet msbuild /t:pack /p:Configuration=Release /p:SourceLinkCreate=true
if (-Not $?) {
Write-Host ("Packaging failed for the project: " + $projectFolder)
exit $LASTEXITCODE
}
# Copy nuget package
$projectName = $project.Substring($project.LastIndexOf("/") + 1)
$projectPackPath = Join-Path $rootFolder ("/output/release/" + $projectName + ".*.nupkg")
Move-Item $projectPackPath $packFolder
}
# Go back to the pack folder
Set-Location $packFolder
# Publish all packages
$projectPacks = Get-ChildItem (Join-Path $packFolder "*.nupkg")
foreach($pack in $projectPacks) {
& dotnet nuget push ($pack) -s https://nexus.sycdev.com/repository/nuget-hosted/ --skip-duplicate --api-key "$apiKey"
}
# Go back to the root folder
Set-Location $rootFolder