Skip to content

Build SQLServerSpatialTools with dotnet core on macos #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
67 changes: 67 additions & 0 deletions Readme.txt → Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
# SQLServerSpatialTools for dotnet core

A very quick fork that modifies the `.csproj` project file to compile under dotnet core 9 on macos, removes the `pfx` code signing bits (which presumably are unsupported - anyone with more time, please feel free to investigate!), and removes the `LRS` code that breaks the build.

## Compilation

```shell
git checkout https://github.com/tbbuck/SQLServerSpatialTools-DotnetCore
cd SQLServerSpatialTools-DotnetCore/src
dotnet build
```

The resulting `.dll` will be found at `SQLServerSpatialTools-DotnetCore/output/lib/net481/SQLSpatialTools.dll`

## Installation

### System
```shell
# copy the file to your MSSQL server however you fancy, and put in an MSSQL-accessible directory, for example:
scp SQLServerSpatialTools-DotnetCore/output/lib/net481/SQLSpatialTools.dll MyFancySqlServer:/tmp
sudo mkdir /opt/mssql-clr/SQLServerSpatialTools-DotnetCore
sudo mv /tmp/SQLServerSpatialTools.dll /opt/mssql-clr/SQLServerSpatialTools-DotnetCore
sudo chown mssql:mssql -R /opt/mssql-clr/SQLServerSpatialTools-DotnetCore
```

### SQL Server

(basically - follow the instructions in `src/SQL Scripts/Register.sql`:

```sql
-- These first few instructions may not be necessary if you've set up CLRs pbefore
-- Copyright (c) Microsoft Corporation. All rights reserved.
-- Install the SQLSpatialTools assembly and all its functions into the current database

-- Enabling CLR prior to registering assembly and its related functions.
EXEC sp_configure 'show advanced option', '1';
RECONFIGURE;
Go

sp_configure 'clr enabled', 1 ;
GO
RECONFIGURE ;
GO

EXEC sp_configure 'clr strict security', '0'
RECONFIGURE WITH OVERRIDE;
GO

-- This is the big important one
CREATE assembly SQLSpatialTools
FROM '/opt/mssql-clr/SQLServerSpatialTools-DotnetCore/SQLSpatialTools.dll'
GO

--- run the rest of the commands from the Register script, such as:

CREATE FUNCTION IsValidGeographyFromText (
@inputWKT NVARCHAR(MAX)
,@srid INT
)
RETURNS BIT
AS
EXTERNAL NAME SQLSpatialTools.[SQLSpatialTools.Functions.General.Geography].IsValidGeographyFromText
GO


```

***********************************************************
** 0: Contents
***********************************************************
Expand Down
128 changes: 10 additions & 118 deletions src/SQLSpatialTools.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -13,7 +16,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SQLSpatialTools</RootNamespace>
<AssemblyName>SQLSpatialTools</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworks>net481</TargetFrameworks>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
Expand Down Expand Up @@ -45,7 +48,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
Expand All @@ -58,111 +60,17 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\SpatialTools.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.SqlServer.Types.14.0.1016.290\lib\net40\Microsoft.SqlServer.Types.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.1016.290" />
<PackageReference Include="Microsoft.SqlServer.Server" Version="1.0.0" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Functions\General\Geometry.cs" />
<Compile Include="Functions\LRS\Geometry.cs" />
<Compile Include="Functions\Util\Geometry.cs" />
<Compile Include="Sinks\Geometry\ExtractPolygonFromLineGeometrySink.cs" />
<Compile Include="Sinks\Geometry\BuildMultiLineFromLinesSink.cs" />
<Compile Include="Sinks\Geometry\ClipMGeometrySegmentSink.cs" />
<Compile Include="Sinks\Geometry\ReverseLinearGeometrySink.cs" />
<Compile Include="Sinks\Geometry\MultiplyMeasureGeometrySink.cs" />
<Compile Include="Sinks\Geometry\ScaleGeometrySink.cs" />
<Compile Include="Sinks\Geometry\TranslateMeasureGeometrySink.cs" />
<Compile Include="Sinks\Geometry\ReverseAndTranslateGeometrySink.cs" />
<Compile Include="Sinks\Geometry\LineStringMergeGeometrySink.cs" />
<Compile Include="Sinks\Geometry\LocateMAlongGeometrySink.cs" />
<Compile Include="Sinks\Geometry\ResetMGeometrySink.cs" />
<Compile Include="KMLProcessor\Constants.cs" />
<Compile Include="KMLProcessor\Export\ExportContext.cs" />
<Compile Include="KMLProcessor\Export\KeyholeMarkupLanguageBase.cs" />
<Compile Include="KMLProcessor\Export\KeyholeMarkupLanguageGeography.cs" />
<Compile Include="KMLProcessor\Export\KeyholeMarkupLanguageGeometry.cs" />
<Compile Include="KMLProcessor\FilterSetSridGeographySink.cs" />
<Compile Include="KMLProcessor\GeographyContext.cs" />
<Compile Include="KMLProcessor\Import\AltitudeMode.cs" />
<Compile Include="KMLProcessor\Import\Geography.cs" />
<Compile Include="KMLProcessor\Import\GroundOverlay.cs" />
<Compile Include="KMLProcessor\Import\KMLParser.cs" />
<Compile Include="KMLProcessor\Import\KMLProcessor.cs" />
<Compile Include="KMLProcessor\Import\LatLonAltBox.cs" />
<Compile Include="KMLProcessor\Import\LatLonBox.cs" />
<Compile Include="KMLProcessor\Import\LatLonBoxBase.cs" />
<Compile Include="KMLProcessor\Import\LatLonQuad.cs" />
<Compile Include="KMLProcessor\Import\LinearRing.cs" />
<Compile Include="KMLProcessor\Import\LineString.cs" />
<Compile Include="KMLProcessor\Import\Model.cs" />
<Compile Include="KMLProcessor\Import\MultiGeometry.cs" />
<Compile Include="KMLProcessor\Import\Placemark.cs" />
<Compile Include="KMLProcessor\Import\Point.cs" />
<Compile Include="KMLProcessor\Import\Polygon.cs" />
<Compile Include="KMLProcessor\Import\Region.cs" />
<Compile Include="KMLProcessor\KMLException.cs" />
<Compile Include="KMLProcessor\KmlFunctions.cs" />
<Compile Include="KMLProcessor\Utilities.cs" />
<Compile Include="Projections\GnomonicProjection.cs" />
<Compile Include="Sinks\Geography\GeographyFilters.cs" />
<Compile Include="Sinks\Geometry\GeometryFilters.cs" />
<Compile Include="Sinks\Geometry\GeometryToPointGeographySink.cs" />
<Compile Include="Sinks\Geometry\GISTypeCheckGeometrySink.cs" />
<Compile Include="Sinks\Geometry\BuildLRSMultiLineSink.cs" />
<Compile Include="Sinks\Geometry\PopulateGeometryMeasuresSink.cs" />
<Compile Include="Sinks\Geometry\SplitGeometrySegmentSink.cs" />
<Compile Include="Sinks\Geography\VacuousGeographyToGeometrySink.cs" />
<Compile Include="Sinks\Geometry\VacuousGeometryToGeographySink.cs" />
<Compile Include="Types\LRSEnumerator.cs" />
<Compile Include="Types\LRSLine.cs" />
<Compile Include="Types\LRSMultiLine.cs" />
<Compile Include="Types\LRSPoint.cs" />
<Compile Include="Types\Vertex.cs" />
<Compile Include="Utility\EnumsAndConstants.cs" />
<Compile Include="Utility\ErrorMessage.cs" />
<Compile Include="Utility\SpatialExtensions.cs" />
<Compile Include="Types\SQL\AffineTransform.cs" />
<Compile Include="Aggregates\GeometryEnvelopeAggregate.cs" />
<Compile Include="Aggregates\GeographyUnionAggregate.cs" />
<Compile Include="Projections\AlbersEqualAreaProjection.cs" />
<Compile Include="Projections\EquirectangularProjection.cs" />
<Compile Include="Projections\LambertConformalConicProjection.cs" />
<Compile Include="Projections\MathX.cs" />
<Compile Include="Projections\MercatorProjection.cs" />
<Compile Include="Projections\ObliqueMercatorProjection.cs" />
<Compile Include="Projections\Projection.cs" />
<Compile Include="Resource\Resource.Designer.cs" />
<Compile Include="Sinks\Geometry\GeometryTransformer.cs" />
<Compile Include="Types\SQL\SqlProjection.cs" />
<Compile Include="Projections\TransverseMercatorProjection.cs" />
<Compile Include="Sinks\Geography\DensifyGeographySink.cs" />
<Compile Include="Sinks\Geometry\LocateAlongGeometrySink.cs" />
<Compile Include="Functions\General\Geography.cs" />
<Compile Include="Sinks\Geography\LocateAlongGeographySink.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sinks\Geography\Projector.cs" />
<Compile Include="Sinks\Geometry\ShiftGeometrySink.cs" />
<Compile Include="Sinks\Geometry\UnProjector.cs" />
<Compile Include="Sinks\Geometry\ConvertXYZ2XYMGeometrySink.cs" />
<Compile Include="Utility\SQLTypeConversions.cs" />
<Compile Include="Utility\SpatialUtil.cs" />
<Compile Include="Types\Vector3.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="SQL Scripts\aggregate_example.sql">
Expand All @@ -187,9 +95,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resource\Resource.resx" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
Expand Down Expand Up @@ -217,24 +122,11 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. %0AUse NuGet Package Restore to download them. %0AFor more information, see http://go.microsoft.com/fwlink/?LinkID=322105. %0AThe missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.SqlServer.Types.14.0.1016.290\lib\net40\Microsoft.SqlServer.Types.dll')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.SqlServer.Types.14.0.1016.290\lib\net40\Microsoft.SqlServer.Types.dll'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>if exist "$(ProjectDir)obj" rd "$(ProjectDir)obj" /S /Q
powershell.exe -ExecutionPolicy Unrestricted [io.file]::WriteAllText('$(TargetDir)SQL Scripts\Register.sql', ((gc '$(TargetDir)SQL Scripts\Register.sql') -replace 'DLLPath', '$(TargetPath)' -join \"`r`n\"))
powershell.exe -ExecutionPolicy Unrestricted [io.file]::WriteAllText('$(TargetDir)SQL Scripts\RegisterAndValidate.sql', ((gc '$(TargetDir)SQL Scripts\RegisterAndValidate.sql') -replace 'ScriptDirPath', '$(TargetDir)SQL Scripts' -join \"`r`n\"))
exit 0</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
83 changes: 0 additions & 83 deletions src/Sinks/Geometry/BuidLRSMultiLineSink.cs

This file was deleted.