You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by fo...@apache.org on 2019/02/04 08:55:13 UTC

[avro] branch master updated: AVRO-1381: Generate NuGet package for main Avro library (#428)

This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new e03f9d4  AVRO-1381: Generate NuGet package for main Avro library (#428)
e03f9d4 is described below

commit e03f9d44faaaa5fd0908f9402340164972415c0d
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Mon Feb 4 03:55:08 2019 -0500

    AVRO-1381: Generate NuGet package for main Avro library (#428)
---
 .editorconfig                                      |  5 ++
 lang/csharp/Avro.sln                               | 10 ++++
 lang/csharp/build.ps1                              | 27 ++++++++++-
 lang/csharp/common.props                           | 56 ++++++++++++++++++++++
 lang/csharp/src/apache/main/Avro.main.csproj       | 19 +++++++-
 .../src/apache/main/Properties/AssemblyInfo.cs     | 33 -------------
 6 files changed, 114 insertions(+), 36 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 4efdf7d..15556db 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -25,6 +25,11 @@ indent_style = space
 indent_size = 2
 trim_trailing_whitespace=true
 
+[*.{cs,ps1}]
+indent_style = space
+indent_size = 4
+trim_trailing_whitespace=true
+
 #[*.scala]
 #indent_style = space
 #indent_size = 2
diff --git a/lang/csharp/Avro.sln b/lang/csharp/Avro.sln
index 6a88459..4f95c2f 100644
--- a/lang/csharp/Avro.sln
+++ b/lang/csharp/Avro.sln
@@ -20,6 +20,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avro.perf", "src\apache\per
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avro.ipc.test", "src\apache\ipc.test\Avro.ipc.test.csproj", "{A5C8B22C-BC43-4763-8B92-EB0CEA739ED1}"
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8A671DF3-BC71-4E1A-BB06-0A225799A274}"
+	ProjectSection(SolutionItems) = preProject
+		..\..\.editorconfig = ..\..\.editorconfig
+		.gitignore = .gitignore
+		build.ps1 = build.ps1
+		build.sh = build.sh
+		common.props = common.props
+		README.md = README.md
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
diff --git a/lang/csharp/build.ps1 b/lang/csharp/build.ps1
index edb8411..1871d97 100644
--- a/lang/csharp/build.ps1
+++ b/lang/csharp/build.ps1
@@ -24,7 +24,19 @@ param(
     [Parameter()]
     [ValidateSet('Release', 'Debug')]
     [string]
-    $Configuration = 'Release'
+    $Configuration = 'Release',
+
+    [Parameter()]
+    [int]
+    $BuildNumber = 0,
+
+    [Parameter()]
+    [string]
+    $VersionSuffix,
+
+    [Parameter()]
+    [string]
+    $RepositoryUrl
 )
 
 # Catch any PowerShell errors and exit with a non-zero exit code.
@@ -47,7 +59,18 @@ try {
 
     switch ($Target) {
         "Test" {
-            dotnet build --configuration $Configuration
+            $buildCmd = "dotnet build --configuration $Configuration -p:BuildNumber=$BuildNumber " +
+                "-p:RepositoryCommit=$(git rev-parse HEAD) "
+
+            if ($VersionSuffix) {
+                $buildCmd += "-p:VersionSuffix=$VersionSuffix "
+            }
+
+            if ($RepositoryUrl) {
+                $buildCmd += "-p:RepositoryUrl=$RepositoryUrl "
+            }
+
+            Invoke-Expression $buildCmd
             checkExitCode
 
             dotnet test --configuration $Configuration --no-build ./src/apache/test/Avro.test.csproj
diff --git a/lang/csharp/common.props b/lang/csharp/common.props
new file mode 100644
index 0000000..8013be4
--- /dev/null
+++ b/lang/csharp/common.props
@@ -0,0 +1,56 @@
+<!--
+   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.
+-->
+<Project>
+  <PropertyGroup Label="Common Versions">
+    <!-- Read version from shared VERSION.txt file -->
+    <AvroVersionFilePath>$(MSBuildThisFileDirectory)/../../share/VERSION.txt</AvroVersionFilePath>
+    <AvroVersion>$([System.IO.File]::ReadAllText($(AvroVersionFilePath)).Trim())</AvroVersion>
+
+    <!-- Parse out parts of the version -->
+    <MajorVersion>$(AvroVersion.Split('.')[0])</MajorVersion>
+    <MinorVersion>$(AvroVersion.Split('.')[1])</MinorVersion>
+    <Patch>$(AvroVersion.Split('-')[0].Split('.')[2])</Patch>
+    <BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
+
+    <!-- Set CSPROJ version properties -->
+    <VersionPrefix>$(MajorVersion).$(MinorVersion).$(Patch)</VersionPrefix>
+    <VersionSuffix Condition="'$(VersionSuffix)' == '' AND $(AvroVersion.Contains('-'))">$(AvroVersion.Split('-')[1])</VersionSuffix>
+    <AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
+    <FileVersion>$(MajorVersion).$(MinorVersion).$(BuildNumber).0</FileVersion>
+  </PropertyGroup>
+
+  <PropertyGroup Label="Common NuGet Properties">
+    <!-- Reference: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target -->
+    <Copyright>Copyright © 2012 The Apache Software Foundation.</Copyright>
+    <PackageIconUrl>http://avro.apache.org/images/avro-logo.png</PackageIconUrl>
+    <PackageLicenseFile>LICENSE</PackageLicenseFile>
+    <PackageProjectUrl>http://avro.apache.org/</PackageProjectUrl>
+    <PackageTags>Avro;Apache;Serialization;Binary;Json;Schema</PackageTags>
+    <RepositoryUrl Condition="'$(RepositoryUrl)' == ''">https://github.com/apache/avro.git</RepositoryUrl>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Include="$(MSBuildThisFileDirectory)\LICENSE" Pack="true" Visible="false" PackagePath=""/>
+  </ItemGroup>
+
+  <Target Name="PrintVersionInfo">
+    <Message Importance="high" Text="VersionPrefix: $(VersionPrefix)" />
+    <Message Importance="high" Text="VersionSuffix: $(VersionSuffix)" />
+    <Message Importance="high" Text="AssemblyVersion: $(AssemblyVersion)" />
+    <Message Importance="high" Text="FileVersion: $(FileVersion)" />
+  </Target>
+</Project>
diff --git a/lang/csharp/src/apache/main/Avro.main.csproj b/lang/csharp/src/apache/main/Avro.main.csproj
index 91c551d..f58070b 100644
--- a/lang/csharp/src/apache/main/Avro.main.csproj
+++ b/lang/csharp/src/apache/main/Avro.main.csproj
@@ -16,13 +16,30 @@
 -->
 <Project Sdk="Microsoft.NET.Sdk">
 
+  <Import Project="../../../common.props" />
+
   <PropertyGroup>
     <TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
     <AssemblyName>Avro</AssemblyName>
     <RootNamespace>Avro</RootNamespace>
-    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <SignAssembly>true</SignAssembly>
     <AssemblyOriginatorKeyFile>..\..\..\Avro.snk</AssemblyOriginatorKeyFile>
+    <GenerateDocumentationFile>true</GenerateDocumentationFile>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <!-- NuGet Package Settings -->
+    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
+    <PackageId>Apache.Avro</PackageId>
+    <Description>
+      Avro provides:
+
+      Rich data structures.
+      A compact, fast, binary data format.
+      A container file, to store persistent data.
+      Remote procedure call (RPC).
+      Simple integration with dynamic languages. Code generation is not required to read or write data files nor to use or implement RPC protocols. Code generation as an optional optimization, only worth implementing for statically typed languages.
+    </Description>
   </PropertyGroup>
 
   <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
diff --git a/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs b/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1ef0b2e..0000000
--- a/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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.
- */
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Avro")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache")]
-[assembly: AssemblyProduct("Avro")]
-[assembly: AssemblyCopyright("Copyright © Apache 2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: ComVisible(false)]
-[assembly: Guid("152D7B83-9A97-45F3-B4B3-A367AFC090C4")]
-[assembly: AssemblyVersion("0.9.0.0")]
-[assembly: AssemblyFileVersion("0.9.0.0")]
\ No newline at end of file