From 06d6faf4e62070bc19d654d5579badc397332403 Mon Sep 17 00:00:00 2001 From: tmajest Date: Thu, 19 Feb 2015 14:08:52 -0800 Subject: [PATCH 1/5] Pull reef version from pom file --- lang/cs/.nuget/NuGet.targets | 2 +- lang/cs/build.props | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lang/cs/.nuget/NuGet.targets b/lang/cs/.nuget/NuGet.targets index 401dcddd6c..b5f3ada9bc 100644 --- a/lang/cs/.nuget/NuGet.targets +++ b/lang/cs/.nuget/NuGet.targets @@ -81,7 +81,7 @@ under the License. $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) - $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -Version $(ReefVersion) -symbols diff --git a/lang/cs/build.props b/lang/cs/build.props index 2bf3cea95f..f132393697 100644 --- a/lang/cs/build.props +++ b/lang/cs/build.props @@ -66,6 +66,13 @@ under the License. 4 + + + __POM_VERSION__ + 0 + $(PomFileVersion)-SNAPSHOT-$(SnapshotVersion) + + 1.4.0.0 @@ -73,5 +80,6 @@ under the License. 2.0.0.668 2.2.5 + From 1ee6627bb6ff2479ecfc3753ce97aa25f84c0985 Mon Sep 17 00:00:00 2001 From: tmajest Date: Thu, 26 Feb 2015 11:35:52 -0800 Subject: [PATCH 2/5] Add script to copy temp nuspec files over --- lang/cs/.nuget/NuGet.targets | 12 ++++++++++-- lang/cs/.nuget/finalizeNuspec.ps1 | 13 +++++++++++++ lang/cs/build.props | 7 ------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 lang/cs/.nuget/finalizeNuspec.ps1 diff --git a/lang/cs/.nuget/NuGet.targets b/lang/cs/.nuget/NuGet.targets index b5f3ada9bc..820e38150b 100644 --- a/lang/cs/.nuget/NuGet.targets +++ b/lang/cs/.nuget/NuGet.targets @@ -81,7 +81,7 @@ under the License. $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) - $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -Version $(ReefVersion) -symbols + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols @@ -120,7 +120,7 @@ under the License. Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> - + @@ -129,6 +129,14 @@ under the License. Condition=" '$(OS)' == 'Windows_NT' " /> + + + $(SolutionDir)\.nuget\finalizeNuspec.ps1 + + + + + diff --git a/lang/cs/.nuget/finalizeNuspec.ps1 b/lang/cs/.nuget/finalizeNuspec.ps1 new file mode 100644 index 0000000000..accdd2b465 --- /dev/null +++ b/lang/cs/.nuget/finalizeNuspec.ps1 @@ -0,0 +1,13 @@ +$nuspecdir = "nuspec" + +# Delete the directory if it already exists +rmdir -Force -Recurse $nuspecdir + +# Create directory for finalized nuspec files to live +mkdir -Force $nuspecdir + +# copy over temporary nuspec files into new nuspec directory +$nuspecfiles = Get-Childitem -Recurse .. *.nuspec +$nuspecfiles | foreach { cp $_.FullName $nuspecDir } + +# Replace package version token with actual version diff --git a/lang/cs/build.props b/lang/cs/build.props index f132393697..9bbde61695 100644 --- a/lang/cs/build.props +++ b/lang/cs/build.props @@ -66,13 +66,6 @@ under the License. 4 - - - __POM_VERSION__ - 0 - $(PomFileVersion)-SNAPSHOT-$(SnapshotVersion) - - 1.4.0.0 From 6fba5146a77bea489a430e33a6906fc39d2e0318 Mon Sep 17 00:00:00 2001 From: tmajest Date: Fri, 27 Feb 2015 10:43:53 -0800 Subject: [PATCH 3/5] Completed work for pulling nuget version from pom file --- lang/cs/.gitignore | 2 + lang/cs/.nuget/NuGet.targets | 47 +++++++++++++++- lang/cs/.nuget/finalizeNuspec.ps1 | 92 ++++++++++++++++++++++++++++--- 3 files changed, 129 insertions(+), 12 deletions(-) diff --git a/lang/cs/.gitignore b/lang/cs/.gitignore index aeaff291d5..3da4cf849a 100644 --- a/lang/cs/.gitignore +++ b/lang/cs/.gitignore @@ -6,5 +6,7 @@ TestResults **/*.suo **/*.csproj.user **/obj +**/.nuget/nuspec +**/.nuget/packages diff --git a/lang/cs/.nuget/NuGet.targets b/lang/cs/.nuget/NuGet.targets index 820e38150b..a7487a2d90 100644 --- a/lang/cs/.nuget/NuGet.targets +++ b/lang/cs/.nuget/NuGet.targets @@ -79,9 +79,15 @@ under the License. "$(SolutionDir) " "$(SolutionDir)" + + $(SolutionDir)\.nuget\nuspec\$(AssemblyName).nuspec + + + $(SolutionDir)\$(RootNamespace) + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) - $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + $(NuGetCommand) pack "$(FinalizedNuspecFile)" -BasePath $(NugetProjectPath) -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" @@ -96,6 +102,11 @@ under the License. + + + $(CleanDependsOn);CleanNugetPackages + + @@ -120,7 +131,10 @@ under the License. Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> - + + + + @@ -131,12 +145,39 @@ under the License. + $true + 0 $(SolutionDir)\.nuget\finalizeNuspec.ps1 + $(FinalizeNuspecScript) $(SolutionDir) $(IsSnapshot) $(SnapshotNumber) + + + + + + + + + + + + + $(SolutionDir)\.nuget\packages + + + + + + + + $(SolutionDir)\.nuget\nuspec + $(SolutionDir)\.nuget\packages - + + + diff --git a/lang/cs/.nuget/finalizeNuspec.ps1 b/lang/cs/.nuget/finalizeNuspec.ps1 index accdd2b465..21c864055f 100644 --- a/lang/cs/.nuget/finalizeNuspec.ps1 +++ b/lang/cs/.nuget/finalizeNuspec.ps1 @@ -1,13 +1,87 @@ -$nuspecdir = "nuspec" +Param( + [Parameter(Mandatory=$true)] + [string]$solutionDir, -# Delete the directory if it already exists -rmdir -Force -Recurse $nuspecdir + [Parameter(Mandatory=$true)] + [bool]$isSnapshot, -# Create directory for finalized nuspec files to live -mkdir -Force $nuspecdir + [int]$snapshotNumber +) -# copy over temporary nuspec files into new nuspec directory -$nuspecfiles = Get-Childitem -Recurse .. *.nuspec -$nuspecfiles | foreach { cp $_.FullName $nuspecDir } +Function Get-Nuspec-Version { + <# + .DESCRIPTION + Extracts the NuGet version number from the pom.xml file in the source directory. + #> -# Replace package version token with actual version + $pomPath = "$solutionDir\pom.xml" + $pom = [xml] (Get-Content $pomPath) + $version = $pom.project.parent.version -replace '-incubating-SNAPSHOT','' + return $version +} + +Function Prep-Nuspec-Files { + <# + .DESCRIPTION + Creates a directory for the finalized nuspec files to live. Next, + the temporary nuspec files in each source directory will get copied + to the new nuspec directory. + #> + + $nuspecDir = "$solutionDir\.nuget\nuspec" + + # Delete the directory if it already exists + if (Test-Path $nuspecDir) { + rmdir -Force -Recurse $nuspecDir + } + + # Create directory for finalized nuspec files to live + mkdir -Force $nuspecDir + + # Copy over temporary nuspec files into new nuspec directory + $tempNuspecFiles = Get-ChildItem $solutionDir\**\*.nuspec + foreach ($tempNuspecFile in $tempNuspecFiles) { + Copy-Item $tempNuspecFile.FullName $nuspecDir + } +} + +Function Finalize-Nuspec-Version { + <# + .DESCRIPTION + Replaces the $version$ token in each nuspec file with the actual version string. + #> + + param([string]$version) + + if ($isSnapshot) { + $fullVersion = "$version-SNAPSHOT-$snapshotNumber" + } + else { + $fullVersion = $version + } + + $nuspecDir = "$solutionDir\.nuget\nuspec" + $nuspecFiles = Get-ChildItem $nuspecDir + + # Replace the $version$ token with the specified version in each nuspec file + foreach ($nuspec in $nuspecFiles) { + $finalizedNuspec = Get-Content $nuspec.FullName | foreach { $_ -replace '\$version\$',"$fullVersion" } + Set-Content -Path $nuspec.FullName -Value $finalizedNuspec + } +} + +function ExitWithCode +{ + param ( + $exitcode + ) + + $host.SetShouldExit($exitcode) + exit +} + + +Prep-Nuspec-Files +$version = Get-Nuspec-Version +Finalize-Nuspec-Version($version) +ExitWithCode -exitcode $LASTEXITCODE From dd8606757359140e0fefe132c55f9f9039ad3ec5 Mon Sep 17 00:00:00 2001 From: tmajest Date: Fri, 27 Feb 2015 11:03:10 -0800 Subject: [PATCH 4/5] Added license header to finalizeNuspec.ps1 --- lang/cs/.nuget/finalizeNuspec.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lang/cs/.nuget/finalizeNuspec.ps1 b/lang/cs/.nuget/finalizeNuspec.ps1 index 21c864055f..dc9e38a0f8 100644 --- a/lang/cs/.nuget/finalizeNuspec.ps1 +++ b/lang/cs/.nuget/finalizeNuspec.ps1 @@ -1,3 +1,20 @@ +<# +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +#> + Param( [Parameter(Mandatory=$true)] [string]$solutionDir, From 1da57a25eff27a814290378b52dc9c74b3ff1d18 Mon Sep 17 00:00:00 2001 From: tmajest Date: Fri, 27 Feb 2015 11:35:16 -0800 Subject: [PATCH 5/5] Moved IsSnapshot variables and snapshot number properties to build.props --- lang/cs/.nuget/NuGet.targets | 6 +++--- lang/cs/.nuget/finalizeNuspec.ps1 | 32 ++++++++++--------------------- lang/cs/build.props | 6 ++++++ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/lang/cs/.nuget/NuGet.targets b/lang/cs/.nuget/NuGet.targets index a7487a2d90..0a5b958318 100644 --- a/lang/cs/.nuget/NuGet.targets +++ b/lang/cs/.nuget/NuGet.targets @@ -145,11 +145,11 @@ under the License. - $true - 0 $(SolutionDir)\.nuget\finalizeNuspec.ps1 - $(FinalizeNuspecScript) $(SolutionDir) $(IsSnapshot) $(SnapshotNumber) + $(FinalizeNuspecScript) -SolutionDir $(SolutionDir) -Snapshot -SnapshotNumber $(SnapshotNumber) + $(FinalizeNuspecScript) -SolutionDir $(SolutionDir) + diff --git a/lang/cs/.nuget/finalizeNuspec.ps1 b/lang/cs/.nuget/finalizeNuspec.ps1 index dc9e38a0f8..69683d8ba7 100644 --- a/lang/cs/.nuget/finalizeNuspec.ps1 +++ b/lang/cs/.nuget/finalizeNuspec.ps1 @@ -17,12 +17,11 @@ under the License. Param( [Parameter(Mandatory=$true)] - [string]$solutionDir, + [string]$SolutionDir, - [Parameter(Mandatory=$true)] - [bool]$isSnapshot, + [switch]$Snapshot, - [int]$snapshotNumber + [int]$SnapshotNumber ) Function Get-Nuspec-Version { @@ -31,7 +30,7 @@ Function Get-Nuspec-Version { Extracts the NuGet version number from the pom.xml file in the source directory. #> - $pomPath = "$solutionDir\pom.xml" + $pomPath = "$SolutionDir\pom.xml" $pom = [xml] (Get-Content $pomPath) $version = $pom.project.parent.version -replace '-incubating-SNAPSHOT','' return $version @@ -45,7 +44,7 @@ Function Prep-Nuspec-Files { to the new nuspec directory. #> - $nuspecDir = "$solutionDir\.nuget\nuspec" + $nuspecDir = "$SolutionDir\.nuget\nuspec" # Delete the directory if it already exists if (Test-Path $nuspecDir) { @@ -56,7 +55,7 @@ Function Prep-Nuspec-Files { mkdir -Force $nuspecDir # Copy over temporary nuspec files into new nuspec directory - $tempNuspecFiles = Get-ChildItem $solutionDir\**\*.nuspec + $tempNuspecFiles = Get-ChildItem $SolutionDir\**\*.nuspec foreach ($tempNuspecFile in $tempNuspecFiles) { Copy-Item $tempNuspecFile.FullName $nuspecDir } @@ -70,14 +69,14 @@ Function Finalize-Nuspec-Version { param([string]$version) - if ($isSnapshot) { - $fullVersion = "$version-SNAPSHOT-$snapshotNumber" + if ($Snapshot) { + $fullVersion = "$version-SNAPSHOT-$SnapshotNumber" } else { $fullVersion = $version } - $nuspecDir = "$solutionDir\.nuget\nuspec" + $nuspecDir = "$SolutionDir\.nuget\nuspec" $nuspecFiles = Get-ChildItem $nuspecDir # Replace the $version$ token with the specified version in each nuspec file @@ -87,18 +86,7 @@ Function Finalize-Nuspec-Version { } } -function ExitWithCode -{ - param ( - $exitcode - ) - - $host.SetShouldExit($exitcode) - exit -} - - Prep-Nuspec-Files $version = Get-Nuspec-Version Finalize-Nuspec-Version($version) -ExitWithCode -exitcode $LASTEXITCODE +Exit $LASTEXITCODE diff --git a/lang/cs/build.props b/lang/cs/build.props index 9bbde61695..88c8a1bb5a 100644 --- a/lang/cs/build.props +++ b/lang/cs/build.props @@ -66,6 +66,12 @@ under the License. 4 + + + true + 0 + + 1.4.0.0