99 Direct version string to use for packages (used by add-ons)
1010. PARAMETER Revision
1111 Revision number to append to date-based version (used by bindings)
12+ . PARAMETER VersionSuffix
13+ Optional suffix to append to the final version (e.g., "nightly" for "2025.11.3.123-nightly")
1214. PARAMETER Projects
1315 Array of .csproj paths to pack. For single project, can be a string.
16+ . PARAMETER DependencyProjects
17+ Array of .csproj paths that need to be built first (dependencies) but won't generate NuGet packages.
1418. PARAMETER OutputFolderBase
1519 Base folder for NuGet package output
1620. PARAMETER BuildVerbosity
3539. EXAMPLE
3640 # Using legacy symbol format
3741 .\Generate-NuGets-DotNet.ps1 -Version "1.0.0" -Projects "test.csproj" -SymbolsFormat "symbols.nupkg"
42+ . EXAMPLE
43+ # Using version suffix for nightly builds
44+ .\Generate-NuGets-DotNet.ps1 -Revision 123 -Projects "test.csproj" -VersionSuffix "nightly"
45+ . EXAMPLE
46+ # Using version suffix with direct version
47+ .\Generate-NuGets-DotNet.ps1 -Version "2025.1.0.0-alpha" -Projects "test.csproj" -VersionSuffix "nightly"
48+ . EXAMPLE
49+ # Building dependency projects but only packing main projects
50+ .\Generate-NuGets-DotNet.ps1 -Revision 123 -Projects "Main.csproj" -DependencyProjects "Dependency1.csproj","Dependency2.csproj"
3851. LINK
3952 https://evergine.com/
4053#>
4154
4255param (
4356 [string ]$Version ,
4457 [string ]$Revision ,
58+ [string ]$VersionSuffix ,
4559 [Parameter (Mandatory = $true )]$Projects ,
60+ $DependencyProjects = @ (),
4661 [string ]$OutputFolderBase = " nupkgs" ,
4762 [string ]$BuildVerbosity = " normal" ,
4863 [string ]$BuildConfiguration = " Release" ,
@@ -61,14 +76,6 @@ else {
6176}
6277
6378# Parameter validation
64- if ([string ]::IsNullOrEmpty($Version ) -and [string ]::IsNullOrEmpty($Revision )) {
65- throw " Either -Version or -Revision parameter must be provided"
66- }
67-
68- if (! [string ]::IsNullOrEmpty($Version ) -and ! [string ]::IsNullOrEmpty($Revision )) {
69- throw " Cannot specify both -Version and -Revision parameters"
70- }
71-
7279if ($Projects -eq $null -or $Projects.Count -eq 0 -or ($Projects -is [array ] -and $Projects.Length -eq 0 )) {
7380 throw " Projects parameter cannot be empty"
7481}
@@ -78,21 +85,23 @@ if ($Projects -is [string]) {
7885 $Projects = @ ($Projects )
7986}
8087
81- # Calculate version
82- if (! [ string ]::IsNullOrEmpty( $Revision ) ) {
83- $Version = " $ ( Get-Date - Format " yyyy.M.d " ) . $Revision "
88+ # Convert DependencyProjects to array if it's a single string or null
89+ if ($null -eq $DependencyProjects ) {
90+ $DependencyProjects = @ ()
8491}
85-
86- # Validate version format (NuGet semantic versioning)
87- # See: https://docs.microsoft.com/en-us/nuget/concepts/package-versioning
88- if ($Version -notmatch ' ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-([a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)(?:\.([a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?))*)?$' ) {
89- throw " Invalid version format: '$Version '. NuGet version must follow semantic versioning (e.g., '1.0.0', '1.0.0-alpha', '1.0.0.123')."
92+ elseif ($DependencyProjects -is [string ]) {
93+ $DependencyProjects = @ ($DependencyProjects )
9094}
9195
96+ # Resolve version from parameters (including suffix)
97+ $Version = Resolve-Version - version $Version - revision $Revision - versionSuffix $VersionSuffix
98+
9299# Show variables
93100$parameters = @ {
94101 " Version" = $Version
102+ " VersionSuffix" = if ([string ]::IsNullOrWhiteSpace($VersionSuffix )) { " (none)" } else { $VersionSuffix }
95103 " Projects" = ($Projects -join " , " )
104+ " DependencyProjects" = if ($DependencyProjects.Count -eq 0 ) { " (none)" } else { ($DependencyProjects -join " , " ) }
96105 " BuildConfiguration" = $BuildConfiguration
97106 " BuildVerbosity" = $BuildVerbosity
98107 " OutputFolderBase" = $OutputFolderBase
@@ -105,6 +114,24 @@ ShowVariables $parameters
105114# Create output folder
106115$absoluteOutputFolder = CreateOutputFolder $OutputFolderBase
107116
117+ # Build all projects (dependencies + main projects) first to resolve dependencies automatically
118+ $allProjectsToBuild = $DependencyProjects + $Projects
119+ LogDebug " START building all projects to resolve dependencies"
120+ foreach ($projectPath in $allProjectsToBuild ) {
121+ LogDebug " Building project: $projectPath "
122+
123+ if (! (Test-Path $projectPath )) {
124+ throw " Project file not found: $projectPath "
125+ }
126+
127+ & dotnet build $projectPath -- verbosity $BuildVerbosity -- configuration $BuildConfiguration
128+
129+ if ($LASTEXITCODE -ne 0 ) {
130+ throw " dotnet build failed for $projectPath "
131+ }
132+ }
133+ LogDebug " END building all projects"
134+
108135# Generate packages
109136LogDebug " START packaging process"
110137
0 commit comments