pkg_push.ps1 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. )
  34. Write-Host "dotnet pack -- start"
  35. foreach($project in $projects) {
  36. $projectFolder = Join-Path $rootFolder $project
  37. Write-Host "projectFolder:" $projectFolder
  38. dotnet pack $projectFolder -p:TargetFrameworks=net6.0 --no-build -c Release /p:SourceLinkCreate=true /p:SolutionDir=$rootFolder -o $nuGetOutputFolder;
  39. }
  40. Write-Host "dotnet pack -- end"
  41. # pause
  42. Write-Host "dotnet nuget push -- start"
  43. $allNuget = Join-Path $nuGetOutputFolder "/*.nupkg"
  44. dotnet nuget push $allNuget -s $sourceUrl -k $apiKey --skip-duplicate
  45. Write-Host "dotnet nuget push -- end"
  46. pause