Skip to content

Commit 32b79e8

Browse files
authored
Set PackageVersion in MSBuild to allow different versions at pack time (#10124)
1 parent 19ee5b1 commit 32b79e8

38 files changed

Lines changed: 61 additions & 16 deletions

File tree

build.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ Invoke-BuildStep 'Signing the binaries' {
144144
-skip:$SkipArtifacts `
145145
-ev +BuildErrors
146146

147+
$packageVersions = "/p:CommonPackageVersion=$CommonPackageVersion;GalleryPackageVersion=$GalleryPackageVersion;JobsPackageVersion=$JobsPackageVersion"
148+
147149
Invoke-BuildStep 'Creating common artifacts' {
148150
$CommonPackages = $CommonProjects | Where-Object { $_.IsSrc }
149151
$CommonPackages | ForEach-Object {
150-
New-ProjectPackage $_.Path -Configuration $Configuration -BuildNumber $BuildNumber -Version $CommonPackageVersion
152+
New-ProjectPackage $_.Path -Configuration $Configuration -Symbols -Options $packageVersions
151153
}
152154
} `
153155
-skip:($SkipCommon -or $SkipArtifacts) `
@@ -160,7 +162,7 @@ Invoke-BuildStep 'Creating gallery artifacts' { `
160162
"src\NuGetGallery.Core\NuGetGallery.Core.csproj",
161163
"src\NuGetGallery.Services\NuGetGallery.Services.csproj"
162164
$GalleryProjects | ForEach-Object {
163-
New-ProjectPackage (Join-Path $PSScriptRoot $_) -Configuration $Configuration -BuildNumber $BuildNumber -Version $GalleryPackageVersion -Branch $Branch -Symbols
165+
New-ProjectPackage (Join-Path $PSScriptRoot $_) -Configuration $Configuration -Symbols -Options $packageVersions
164166
}
165167

166168
$GalleryNuspecProjects =
@@ -197,7 +199,7 @@ Invoke-BuildStep 'Creating jobs artifacts' {
197199
"src\Validation.ScanAndSign.Core\Validation.ScanAndSign.Core.csproj",
198200
"src\Validation.Symbols.Core\Validation.Symbols.Core.csproj"
199201
$JobsProjects | ForEach-Object {
200-
New-ProjectPackage (Join-Path $PSScriptRoot $_) -Configuration $Configuration -BuildNumber $BuildNumber -Version $JobsPackageVersion -Branch $Branch -Symbols
202+
New-ProjectPackage (Join-Path $PSScriptRoot $_) -Configuration $Configuration -Symbols -Options $packageVersions
201203
}
202204

203205
$JobsNuspecProjects =

build/common.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ Function New-ProjectPackage {
762762
[string]$Branch,
763763
[switch]$IncludeReferencedProjects,
764764
[switch]$Sign,
765-
[switch]$BinLog
765+
[switch]$BinLog,
766+
[string[]]$Options
766767
)
767768
Trace-Log "Creating package from @""$TargetFilePath"""
768769

@@ -789,6 +790,8 @@ Function New-ProjectPackage {
789790
}
790791
elseif ($ReleaseLabel) {
791792
$PackageVersion = Get-PackageVersion $ReleaseLabel $BuildNumber
793+
} else {
794+
$PackageVersion = $null
792795
}
793796

794797
if ($PackageVersion) {
@@ -811,6 +814,10 @@ Function New-ProjectPackage {
811814
$opts += "/bl"
812815
}
813816

817+
if ($Options) {
818+
$opts += $Options
819+
}
820+
814821
if (-not (Test-Path $Artifacts)) {
815822
New-Item $Artifacts -Type Directory
816823
}

src/Catalog/NuGet.Services.Metadata.Catalog.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\..\SdkProjects.props" />
44

55
<PropertyGroup>
66
<TargetFrameworks>net472;netstandard2.1</TargetFrameworks>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(JobsPackageVersion)</PackageVersion>
78
<Description>Create, edit, or read the package metadata catalog.</Description>
89
<PackageTags>nuget;services;search;catalog;metadata;collector</PackageTags>
910
</PropertyGroup>

src/Microsoft.PackageManagement.Search.Web/Microsoft.PackageManagement.Search.Web.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\..\SdkProjects.props" />
44

55
<PropertyGroup>
66
<TargetFramework>net6.0</TargetFramework>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(JobsPackageVersion)</PackageVersion>
78
</PropertyGroup>
89

910
<ItemGroup>

src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<PropertyGroup>
66
<TargetFrameworks>net472;netstandard2.1</TargetFrameworks>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(JobsPackageVersion)</PackageVersion>
78
<RootNamespace>NuGet.Jobs</RootNamespace>
89
<Description>Common infrastructure for running the NuGetGallery back-end jobs.</Description>
910
</PropertyGroup>

src/NuGet.Protocol.Catalog/NuGet.Protocol.Catalog.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\..\SdkProjects.props" />
44

55
<PropertyGroup>
66
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(JobsPackageVersion)</PackageVersion>
78
<Description>A .NET library for consuming the NuGet API's catalog resource.</Description>
89
</PropertyGroup>
910

src/NuGet.Services.AzureSearch/NuGet.Services.AzureSearch.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\..\SdkProjects.props" />
44

55
<PropertyGroup>
66
<TargetFrameworks>net472;netstandard2.1</TargetFrameworks>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(JobsPackageVersion)</PackageVersion>
78
<Description>Push NuGetGallery DB packages or catalog leaves to Azure Search.</Description>
89
<PackageTags>nuget azure search catalog leaf details incremental collector</PackageTags>
910
</PropertyGroup>

src/NuGet.Services.Build/NuGet.Services.Build.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<PropertyGroup>
66
<TargetFramework>net472</TargetFramework>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(CommonPackageVersion)</PackageVersion>
78
<Description>Shared component to assist NuGet build scripts.</Description>
89

910
<!--

src/NuGet.Services.Configuration/NuGet.Services.Configuration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<PropertyGroup>
66
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(CommonPackageVersion)</PackageVersion>
78
<Description>Shared configuration management NuGet services.</Description>
89
</PropertyGroup>
910

src/NuGet.Services.Contracts/NuGet.Services.Contracts.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="..\..\SdkProjects.props" />
44

55
<PropertyGroup>
66
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
7+
<PackageVersion Condition="'$(PackageVersion)' == ''">$(CommonPackageVersion)</PackageVersion>
78
<Description>Interfaces used for NuGet services</Description>
89
</PropertyGroup>
910

0 commit comments

Comments
 (0)