Skip to content
This repository was archived by the owner on Aug 4, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lang/cs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ TestResults
**/*.suo
**/*.csproj.user
**/obj
**/.nuget/nuspec
**/.nuget/packages


53 changes: 51 additions & 2 deletions lang/cs/.nuget/NuGet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ under the License.
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Nuspec file -->
<FinalizedNuspecFile>$(SolutionDir)\.nuget\nuspec\$(AssemblyName).nuspec</FinalizedNuspecFile>

<!-- Project path -->
<NugetProjectPath>$(SolutionDir)\$(RootNamespace)</NugetProjectPath>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
<BuildCommand>$(NuGetCommand) pack "$(FinalizedNuspecFile)" -BasePath $(NugetProjectPath) -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" </BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
Expand All @@ -96,6 +102,11 @@ under the License.
</BuildDependsOn>
</PropertyGroup>

<!-- Make sure clean will clean up .nuget/packages and .nuget/nuspec directories -->
<PropertyGroup>
<CleanDependsOn>$(CleanDependsOn);CleanNugetPackages</CleanDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
Expand All @@ -120,7 +131,10 @@ under the License.
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Target Name="BuildPackage" DependsOnTargets="BuildNupkg; MoveNuGetPackage">
</Target>

<Target Name="BuildNupkg" DependsOnTargets="CheckPrerequisites; FinalizeNuspecFiles">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

Expand All @@ -129,6 +143,41 @@ under the License.
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<Target Name="FinalizeNuspecFiles">
<PropertyGroup>
<FinalizeNuspecScript>$(SolutionDir)\.nuget\finalizeNuspec.ps1</FinalizeNuspecScript>
<ScriptCommand Condition="'$(IsSnapshot)' == 'true'">$(FinalizeNuspecScript) -SolutionDir $(SolutionDir) -Snapshot -SnapshotNumber $(SnapshotNumber)</ScriptCommand>
<ScriptCommand Condition="'$(IsSnapshot)' == 'false'">$(FinalizeNuspecScript) -SolutionDir $(SolutionDir)</ScriptCommand>
</PropertyGroup>
<Message Text="===SCRIPT: $(ScriptCommand)" />

<Exec Command="powershell -NonInteractive -NoProfile -Command $(ScriptCommand)" >
</Exec>
</Target>

<Target Name="MoveNuGetPackage" DependsOnTargets="BuildNupkg">
<ItemGroup>
<NugetPackageFiles Include="$(SolutionDir)\bin\$(Platform)\$(Configuration)\$(RootNamespace)\*.nupkg" />
</ItemGroup>

<PropertyGroup>
<NugetPackageOutputDir>$(SolutionDir)\.nuget\packages</NugetPackageOutputDir>
</PropertyGroup>

<Copy SourceFiles="@(NugetPackageFiles)" DestinationFolder="$(NugetPackageOutputDir)" />
</Target>

<Target Name="CleanNugetPackages">
<PropertyGroup>
<NuspecFilesDir>$(SolutionDir)\.nuget\nuspec</NuspecFilesDir>
<PackagesDir>$(SolutionDir)\.nuget\packages</PackagesDir>
</PropertyGroup>

<RemoveDir Directories="$(NuspecFilesDir);$(PackagesDir)" />
</Target>



<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
Expand Down
92 changes: 92 additions & 0 deletions lang/cs/.nuget/finalizeNuspec.ps1
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions lang/cs/build.props
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ under the License.
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<!-- REEF NuGet properties -->
<PropertyGroup>
<IsSnapshot>true</IsSnapshot>
<SnapshotNumber>0</SnapshotNumber>
</PropertyGroup>

<!-- Package versions -->
<PropertyGroup>
<AvroVersion>1.4.0.0</AvroVersion>
<NewtonsoftJsonVersion>6.0.8</NewtonsoftJsonVersion>
<ProtobufVersion>2.0.0.668</ProtobufVersion>
<RxVersion>2.2.5</RxVersion>
</PropertyGroup>

</Project>