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 401dcddd6c..0a5b958318 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)')" />
-
+
+
+
+
@@ -129,6 +143,41 @@ under the License.
Condition=" '$(OS)' == 'Windows_NT' " />
+
+
+ $(SolutionDir)\.nuget\finalizeNuspec.ps1
+ $(FinalizeNuspecScript) -SolutionDir $(SolutionDir) -Snapshot -SnapshotNumber $(SnapshotNumber)
+ $(FinalizeNuspecScript) -SolutionDir $(SolutionDir)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(SolutionDir)\.nuget\packages
+
+
+
+
+
+
+
+ $(SolutionDir)\.nuget\nuspec
+ $(SolutionDir)\.nuget\packages
+
+
+
+
+
+
+
diff --git a/lang/cs/.nuget/finalizeNuspec.ps1 b/lang/cs/.nuget/finalizeNuspec.ps1
new file mode 100644
index 0000000000..69683d8ba7
--- /dev/null
+++ b/lang/cs/.nuget/finalizeNuspec.ps1
@@ -0,0 +1,92 @@
+<#
+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,
+
+ [switch]$Snapshot,
+
+ [int]$SnapshotNumber
+)
+
+Function Get-Nuspec-Version {
+ <#
+ .DESCRIPTION
+ Extracts the NuGet version number from the pom.xml file in the source directory.
+ #>
+
+ $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 ($Snapshot) {
+ $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
+ }
+}
+
+Prep-Nuspec-Files
+$version = Get-Nuspec-Version
+Finalize-Nuspec-Version($version)
+Exit $LASTEXITCODE
diff --git a/lang/cs/build.props b/lang/cs/build.props
index 2bf3cea95f..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
@@ -73,5 +79,6 @@ under the License.
2.0.0.668
2.2.5
+