From 2cf0c7df544d0ccf1e857c4638b00f9c672a4bd6 Mon Sep 17 00:00:00 2001 From: zhontai <361243234@qq.com> Date: Tue, 14 Dec 2021 19:03:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Nuget=E5=8C=85=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=92=8C=E6=8E=A8=E9=80=81=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/pack&push.ps1 | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 build/pack&push.ps1 diff --git a/build/pack&push.ps1 b/build/pack&push.ps1 new file mode 100644 index 00000000..b8868fd5 --- /dev/null +++ b/build/pack&push.ps1 @@ -0,0 +1,60 @@ +#定义全局变量 + +$buildFolder = (Get-Item -Path "./" -Verbose).FullName +$rootFolder = Join-Path $buildFolder "../" +$apiKey = "" +$sourceUrl = "http://localhost:5000/v3/index.json" + +Write-Host "buildFolder:" $buildFolder +Write-Host "rootFolder:" $rootFolder + +$nuGetOutputFolder = Join-Path $buildFolder "/packages" +Write-Host "NuGetOutputFolder:" $nuGetOutputFolder + +#编译解决方案 +$solutionPath = "../ZhonTai.sln"; +# Write-Host $solutionPath +# pause + +Write-Host "dotnet build -- start" +dotnet build $solutionPath -c Release +Write-Host "dotnet build -- end" + +if($LASTEXITCODE -eq 0){ + #success +} +else{ + throw "Build Error!"; +} +# pause + +#打包之前先删除nuget包 +Remove-Item "$nuGetOutputFolder/*" -recurse + +# 指定项目打包 +$projects = ( + "src\plates\ZhonTai.Plate.Admin\ZhonTai.Plate.Admin.Domain", + "src\plates\ZhonTai.Plate.Admin\ZhonTai.Plate.Admin.HttpApi", + "src\plates\ZhonTai.Plate.Admin\ZhonTai.Plate.Admin.Repository", + "src\plates\ZhonTai.Plate.Admin\ZhonTai.Plate.Admin.Service", + "src\plates\ZhonTai.Plate.Personal\ZhonTai.Plate.Personnel.Domain", + "src\plates\ZhonTai.Plate.Personal\ZhonTai.Plate.Personnel.HttpApi", + "src\plates\ZhonTai.Plate.Personal\ZhonTai.Plate.Personnel.Repository", + "src\plates\ZhonTai.Plate.Personal\ZhonTai.Plate.Personnel.Service" +) + +Write-Host "dotnet pack -- start" +foreach($project in $projects) { +$projectFolder = Join-Path $rootFolder $project +Write-Host "projectFolder:" $projectFolder +dotnet pack $projectFolder --no-build -c Release /p:SourceLinkCreate=true /p:SolutionDir=$rootFolder -o $nuGetOutputFolder; +} +Write-Host "dotnet pack -- end" +# pause + +Write-Host "dotnet nuget push -- start" +$allNuget = Join-Path $nuGetOutputFolder "/*.nupkg" +dotnet nuget push $allNuget -s $sourceUrl -k $apiKey --skip-duplicate +Write-Host "dotnet nuget push -- end" + +pause \ No newline at end of file