-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpack.ps1
87 lines (75 loc) · 2.47 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# 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/KissU.AspNetCore",
"src/KissU.AspNetCore.Swagger",
"src/KissU.AspNetCore.Stage",
"src/KissU.AspNetCore.Kestrel",
"src/KissU.Codec.MessagePack",
"src/KissU.Codec.ProtoBuffer",
"src/KissU.Logging.NLog",
"src/KissU.Logging.Serilog",
"src/KissU.ServiceDiscovery.Consul",
"src/KissU.ServiceDiscovery.Zookeeper",
"src/KissU.DotNetty",
"src/KissU.DotNetty.DNS",
"src/KissU.DotNetty.Http",
"src/KissU.DotNetty.Mqtt",
"src/KissU.DotNetty.Udp",
"src/KissU.DotNetty.WebSocket",
"src/KissU.Grpc",
"src/KissU.Thrift",
"src/KissU.WebSocket",
"src/KissU.ApiGateWay",
"src/KissU.Apm.Skywalking",
"src/KissU.BackgroundServer",
"src/KissU.Core",
"src/KissU.Abp",
"src/KissU.CPlatform",
"src/KissU.ServiceProxy"
)
# Remove item
Set-Location $packFolder
Remove-Item (Join-Path $packFolder "*.nupkg")
# Rebuild solution
Set-Location $rootFolder
& dotnet restore -s http://package.kissu.com/nuget/nuget/v3/index.json
& dotnet build --configuration Release
# Create all packages
$i = 0
foreach($project in $projects) {
$i += 1
$projectFolder = Join-Path $rootFolder $project
$projectName = ($project -split '/')[-1]
# Create nuget pack
Write-Host ("-----===[ $i / " + $projects.length + " - " + $projectName + " ]===-----")
Set-Location $projectFolder
Remove-Item -Force -Recurse (Join-Path $projectFolder "bin/Release")
& dotnet pack -c Release
if (-Not $?) {
Write-Host ("Packaging failed for the project: " + $projectFolder)
exit $LASTEXITCODE
}
# Copy nuget package
$projectName = $project.Substring($project.LastIndexOf("/") + 1)
$projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $projectName + ".*.nupkg")
Move-Item -Force $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 http://package.kissu.com/nuget/nuget/v3/index.json --skip-duplicate --api-key "$apiKey"
}
# Go back to the root folder
Set-Location $rootFolder