pkg_push.ps1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #定义全局变量
  2. $buildFolder = (Get-Item -Path "./" -Verbose).FullName
  3. $rootFolder = Join-Path $buildFolder "../"
  4. $apiKey = $args[0]
  5. if ([System.String]::IsNullOrWhiteSpace($apiKey))
  6. {
  7. $apiKey = $env:NUGET_KEY
  8. }
  9. $sourceUrl = "http://localhost:5000/v3/index.json"
  10. Write-Host "buildFolder:" $buildFolder
  11. Write-Host "rootFolder:" $rootFolder
  12. $nuGetOutputFolder = Join-Path $buildFolder "/packages"
  13. Write-Host "NuGetOutputFolder:" $nuGetOutputFolder
  14. #编译解决方案
  15. $solutionPath = "../ZhonTai.sln";
  16. # Write-Host $solutionPath
  17. # pause
  18. Write-Host "dotnet build -- start"
  19. dotnet build $solutionPath -c Release
  20. Write-Host "dotnet build -- end"
  21. if($LASTEXITCODE -eq 0){
  22. #success
  23. }
  24. else{
  25. throw "Build Error!";
  26. }
  27. # pause
  28. #打包之前先删除nuget包
  29. Remove-Item "$nuGetOutputFolder/*" -recurse
  30. # 指定项目打包
  31. $projects = (
  32. "src\platform\ZhonTai.Admin",
  33. "src\platform\ZhonTai.ApiUI",
  34. "src\platform\ZhonTai.Common",
  35. "src\platform\ZhonTai.DynamicApi"
  36. )
  37. Write-Host "dotnet pack -- start"
  38. foreach($project in $projects) {
  39. $projectFolder = Join-Path $rootFolder $project
  40. Write-Host "projectFolder:" $projectFolder
  41. dotnet pack $projectFolder -p:TargetFrameworks=net7.0 --no-build -c Release /p:SourceLinkCreate=true /p:SolutionDir=$rootFolder -o $nuGetOutputFolder;
  42. }
  43. Write-Host "dotnet pack -- end"
  44. # pause
  45. Write-Host "dotnet nuget push -- start"
  46. $allNuget = Join-Path $nuGetOutputFolder "/*.nupkg"
  47. dotnet nuget push $allNuget -s $sourceUrl -k $apiKey --skip-duplicate
  48. Write-Host "dotnet nuget push -- end"
  49. pause