Skip to content

Commit

Permalink
add support for building nuget packages on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coe committed Nov 28, 2023
1 parent 8500389 commit aa36b19
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 3 deletions.
1 change: 1 addition & 0 deletions csharp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ x64

artifacts/
TestResults/
nugets/
8 changes: 7 additions & 1 deletion csharp/Apache.Arrow.Adbc.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
Expand Down Expand Up @@ -31,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Tests.Drivers.BigQuery", "test\Drivers\BigQuery\Apache.Arrow.Adbc.Tests.Drivers.BigQuery.csproj", "{EA43BB7C-BC00-4701-BDF4-367880C2495C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Arrow.Adbc.Drivers.Interop.Snowflake", "src\Drivers\Snowflake\Apache.Arrow.Adbc.Drivers.Interop.Snowflake.csproj", "{5F707F02-EB23-42B0-9430-0938C1BA1E96}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -73,6 +74,10 @@ Global
{EA43BB7C-BC00-4701-BDF4-367880C2495C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA43BB7C-BC00-4701-BDF4-367880C2495C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA43BB7C-BC00-4701-BDF4-367880C2495C}.Release|Any CPU.Build.0 = Release|Any CPU
{5F707F02-EB23-42B0-9430-0938C1BA1E96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F707F02-EB23-42B0-9430-0938C1BA1E96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F707F02-EB23-42B0-9430-0938C1BA1E96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F707F02-EB23-42B0-9430-0938C1BA1E96}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -87,6 +92,7 @@ Global
{DEE943D1-A2D0-40CD-ABE0-2CB38E7CA156} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{A748041C-EF9A-4E88-B6FB-9F2D6CB79170} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
{EA43BB7C-BC00-4701-BDF4-367880C2495C} = {C7290227-E925-47E7-8B6B-A8B171645D58}
{5F707F02-EB23-42B0-9430-0938C1BA1E96} = {FEB257A0-4FD3-495E-9A47-9E1649755445}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4795CF16-0FDB-4BE0-9768-5CF31564DC03}
Expand Down
2 changes: 1 addition & 1 deletion csharp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<Product>Apache Arrow ADBC library</Product>
<Copyright>Copyright 2022-2023 The Apache Software Foundation</Copyright>
<Company>The Apache Software Foundation</Company>
<Version>0.5.0</Version>
<Version>0.8.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
7 changes: 7 additions & 0 deletions csharp/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"msbuild-sdks": {
"Microsoft.Build.CentralPackageVersions" : "2.1.3",
"Microsoft.Build.Traversal": "3.4.0",
"Microsoft.Build.NoTargets": "3.7.0"
}
}
42 changes: 42 additions & 0 deletions csharp/scripts/Build-All.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.

# This does the following:

# 1.) Builds each managed library as a nuget package using `dotnet pack`
# 2.) Builds each interop library and packages it in to a nuget using `nuget pack`
# 3.) Copies them all to a single folder
# 4.) Need to run tests using the nuget packages (dotnet test ?)

param (
[string]$destination=".\nugets"
)

$location = Get-Location

Write-Host "Building Snowflake Go driver"

cd ..\src\Drivers\Snowflake

powershell -ExecutionPolicy Unrestricted -File .\Build-SnowflakeDriver.ps1

cd $location

cd ..

Write-Host "Running dotnet pack"

dotnet pack -o $destination
13 changes: 12 additions & 1 deletion csharp/src/Apache.Arrow.Adbc/Apache.Arrow.Adbc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Remove="readme.md" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\arrow\csharp\src\Apache.Arrow\Apache.Arrow.csproj" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net5.0'))">
<Compile Remove="C\NativeLibrary.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
25 changes: 25 additions & 0 deletions csharp/src/Apache.Arrow.Adbc/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
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.
-->
# About

This is a C# implementation of the ADBC spec. It is designed so drivers can be written in any C-based language and leveraged from .NET.

Current C#-implemented drivers include BigQuery and FlightSQL.

The Snowflake Go driver can also be used from .NET.
8 changes: 8 additions & 0 deletions csharp/src/Client/Apache.Arrow.Adbc.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'" />
Expand All @@ -11,4 +12,11 @@
<ItemGroup>
<ProjectReference Include="..\..\Apache.Arrow.Adbc\Apache.Arrow.Adbc.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<!--<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="powershell -ExecutionPolicy Unrestricted -File $(ProjectDir)build-SnowflakeDriver.ps1 -netversion $(TargetFramework)" />
</Target>-->

<!-- use Build-SnowflakeDriver.ps1 to build the dll -->

<!-- libadbc_driver_snowflake.dll is listed for each framework because Condition doesn't work here -->

<ItemGroup>
<Content Include="libadbc_driver_snowflake.dll">
<Pack>true</Pack>
<PackagePath>lib\netstandard2.0</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="libadbc_driver_snowflake.dll">
<Pack>true</Pack>
<PackagePath>lib\net6.0</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="readme.md">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions csharp/src/Drivers/Snowflake/Build-SnowflakeDriver.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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 (
# [string]$netversion
#)

#Write-Host "Building for $netversion"

$location = Get-Location

$file = "libadbc_driver_snowflake.dll"

cd ..\..\..\..\go\adbc\pkg
del $file
go build -tags driverlib -o $file -buildmode=c-shared -ldflags "-s -w" ./snowflake
COPY $file $location
27 changes: 27 additions & 0 deletions csharp/src/Drivers/Snowflake/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
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.
-->

# About
This project generates a NuGet package containing the Snowflake ADBC Go Driver for use in other .NET projects.

For details, see:

[Snowflake Driver](https://arrow.apache.org/adbc/main/driver/snowflake.html) for docs

[GitHub](https://github.com/apache/arrow-adbc/tree/main/go/adbc/driver/snowflake) for source code

0 comments on commit aa36b19

Please sign in to comment.