Skip to content

Commit

Permalink
clean up local packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
phillip-haydon committed Feb 8, 2024
1 parent 5b287ad commit 8066b44
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 48 deletions.
5 changes: 2 additions & 3 deletions pack-all.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
set EnableNuGetPackageRestore=true
call .\packages\psake.4.9.0\tools\psake\psake.cmd pack-all.ps1 %*
pause
@echo off
powershell -NoProfile -ExecutionPolicy Bypass -File ".\pack-all.ps1" %*
76 changes: 31 additions & 45 deletions pack-all.ps1
Original file line number Diff line number Diff line change
@@ -1,63 +1,49 @@
# This causes psake to use the VS 2019 build tool:
Framework "4.8"

properties {
$root = $psake.build_script_dir
$build_dir = "$root\build"
$nuget_dir = "$root\.nuget"
$nuspec_folder = "$root\nuspecs"
# Assembly Info should stay the same until there's an API change and we increment it
$assemblyVersion = "8.0.0"
$version = "8.0.0"
$include_signed = $false
$global_assembly_info = ".\GlobalAssemblyInfo.cs"
$is_pre_release = $true
$pre_release_counter = 1
}

task default -depends Pack
$root = Get-Location
$build_dir = "$root\build"
$assembly_version = "9.0.0"
$version = "9.0.0"
$is_pre_release = $true
$pre_release_counter = 1

task Clean {
remove-item -force -recurse $build_dir -ErrorAction SilentlyContinue | Out-Null
}
function CleanAndBuild {
Remove-Item -Force -Recurse $build_dir -ErrorAction SilentlyContinue | Out-Null

task Build -depends Clean {
# Replace AssemblyVersion and AssemblyFileVersion
(Get-Content $global_assembly_info) -replace 'Version\("[^"]*"\)\]', "Version(`"$assemblyVersion`")]" | Set-Content $global_assembly_info
(Get-Content $global_assembly_info) -replace 'AssemblyInformationalVersion\("[^"]*"\)\]', "AssemblyInformationalVersion(`"$version`")]" | Set-Content $global_assembly_info
if (-not (Test-Path $build_dir)) {
New-Item -ItemType Directory -Path $build_dir | Out-Null
}

& dotnet clean $root\Raygun.CrashReporting.sln -c Release
& dotnet build $root\Raygun.CrashReporting.sln -c Release -p:FileVersion=$version -p:Version=$version -p:AssemblyVersion=$assemblyVersion
& dotnet build $root\Raygun.CrashReporting.sln -c Release -p:FileVersion=$version -p:Version=$version -p:assembly_version=$assembly_version
}

task Pack -depends Build {
function PackAll {

$package_version = $version
if ($is_pre_release) {
$package_version = "$version-pre-$pre_release_counter"
}

# Pack .NET SDK Projects (these use the project files and not nuspecs)
# Because of old style projects we need to pack the specific projects directly
& dotnet pack $root\Mindscape.Raygun4Net.AspNetCore\Mindscape.Raygun4Net.AspNetCore.csproj -c Release -o $build_dir -p:PackageVersion=$package_version -p:FileVersion=$version -p:Version=$version -p:AssemblyVersion=$assemblyVersion
& dotnet pack $root\Mindscape.Raygun4Net.NetCore\Mindscape.Raygun4Net.NetCore.csproj -c Release -o $build_dir -p:PackageVersion=$package_version -p:FileVersion=$version -p:Version=$version -p:AssemblyVersion=$assemblyVersion
& dotnet pack $root\Mindscape.Raygun4Net.NetCore.Common\Mindscape.Raygun4Net.NetCore.Common.csproj -c Release -o $build_dir -p:PackageVersion=$package_version -p:FileVersion=$version -p:Version=$version -p:AssemblyVersion=$assemblyVersion

# Pack nuspecs
$nuspecs;

if ($include_signed) {
$nuspecs = Get-ChildItem -Path $nuspec_folder -Filter *.nuspec -Recurse
} else {
$nuspecs = Get-ChildItem -Path $nuspec_folder -Filter *.nuspec
}

foreach ($nuspec in $nuspecs) {
Write-Output "Building $($nuspec.Name)"
& $nuget_dir\nuget.exe pack $nuspec.FullName -OutputDirectory $build_dir -Properties Configuration=Release -Version $package_version -Verbosity quiet
}
# Pack .NET SDK Projects
PackProject -project_path "$root\Mindscape.Raygun4Net.AspNetCore\Mindscape.Raygun4Net.AspNetCore.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net.NetCore\Mindscape.Raygun4Net.NetCore.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net.NetCore.Common\Mindscape.Raygun4Net.NetCore.Common.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net.Core\Mindscape.Raygun4Net.Core.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net.Mvc\Mindscape.Raygun4Net.Mvc.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net.WebApi\Mindscape.Raygun4Net.WebApi.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net4\Mindscape.Raygun4Net4.csproj" -package_version $package_version
PackProject -project_path "$root\Mindscape.Raygun4Net.Azure.WebJob\Mindscape.Raygun4Net.Azure.WebJob.csproj" -package_version $package_version

# count the number of packages produced and write out
$packageCount = (Get-ChildItem -Path $build_dir -Filter *.nupkg).Count
Write-Output "Created $packageCount packages"

}

function PackProject([string]$project_path, [string]$package_version) {
Write-Output "Packing $project_path"
& dotnet pack $project_path -c Release -o $build_dir -p:PackageVersion=$package_version -p:FileVersion=$version -p:Version=$version -p:assembly_version=$assembly_version
}

& CleanAndBuild
& PackAll

0 comments on commit 8066b44

Please sign in to comment.