Skip to content

Commit

Permalink
#33 target multiple dotnet versions (#38)
Browse files Browse the repository at this point in the history
* Added net60, net40 as a target framework for build

* Deploy -beta versions to bintray

* Fix: reading of assembly location throws notimplemented exception in result could not locate binaries of Pg distribution
  • Loading branch information
zabrowarnyrafal authored Feb 23, 2018
1 parent a9bbc09 commit cb9bf6d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
26 changes: 26 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ environment:
DOTNET_CLI_TELEMETRY_OPTOUT: true
VERSION_INFO_SEMVER: null
VERSION_INFO: null
VERSION_INFO_NUGET: null
nuget:
project_feed: true
disable_publish_on_pr: true
Expand All @@ -27,6 +28,8 @@ before_build:
$env:VERSION_INFO = $version_info;
$env:VERSION_INFO_SEMVER = $version_info.SemVer;
$env:VERSION_INFO_NUGET = $version_info.NuGetVersion
Update-AppveyorBuild -Version "$env:VERSION_INFO_SEMVER-$env:APPVEYOR_BUILD_NUMBER";
Expand Down Expand Up @@ -61,3 +64,26 @@ deploy:
artifact: NuGet
on:
branch: master
- provider: BinTray
username: zabrowarnyrafal
api_key:
secure: XjrCjUTd9QwNy4cUUMuFkzKj9yjWIqBc7ry9Qbqosi7y8OY4NogNFGaog6dIj98D
subject: skyrise
repo: Postgres2Go
package: Postgres2Go
version: ${VERSION_INFO_NUGET}
artifact: NuGet
on:
branch: /hotfix\/*/
- provider: BinTray
username: zabrowarnyrafal
api_key:
secure: XjrCjUTd9QwNy4cUUMuFkzKj9yjWIqBc7ry9Qbqosi7y8OY4NogNFGaog6dIj98D
subject: skyrise
repo: Postgres2Go
package: Postgres2Go
version: ${VERSION_INFO_NUGET}
artifact: NuGet
publish: true
on:
branch: /release\/*/
9 changes: 5 additions & 4 deletions src/Postgres2Go/Common/RecognizedOSPlatform.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Runtime.InteropServices;

namespace Postgres2Go.Common
{
Expand All @@ -17,6 +14,7 @@ internal static class RecognizedOSPlatform
{
internal static RecognizedOSPlatformEnum Determine()
{
#if NETSTANDARD2_0
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return RecognizedOSPlatformEnum.Windows;
Expand All @@ -31,6 +29,9 @@ internal static RecognizedOSPlatformEnum Determine()
}

return RecognizedOSPlatformEnum.Unknown;
#else
return RecognizedOSPlatformEnum.Windows;
#endif
}
}
}
20 changes: 16 additions & 4 deletions src/Postgres2Go/Helper/FileSystem/FolderSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;

namespace Postgres2Go.Helper.FileSystem
{
Expand All @@ -14,8 +12,22 @@ internal static class FolderSearch

internal static string CurrentExecutingDirectory()
{
string filePath = new Uri(typeof(FolderSearch).GetTypeInfo().Assembly.CodeBase).LocalPath;
return Path.GetDirectoryName(filePath);
Assembly pg2goAssembly = typeof(FolderSearch).GetTypeInfo().Assembly;;
string pathToPostgres2GoAssembly = null;

//
// first try read location (abs path) of Postgres2Go assembly
// if framework doesn't implemented it then use code base value to get uri of Postgres2Go assembly
try
{
pathToPostgres2GoAssembly = pg2goAssembly.Location;
}
catch (NotImplementedException)
{
pathToPostgres2GoAssembly = new Uri(pg2goAssembly.EscapedCodeBase).AbsolutePath;
}

return Path.GetDirectoryName(pathToPostgres2GoAssembly);
}

internal static string FindFolder(this string startPath, string searchPattern)
Expand Down
10 changes: 7 additions & 3 deletions src/Postgres2Go/Helper/Postgres/PostgresBinaryLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ public PostgresBinaryLocator(string searchPatternOverride)
_searchPattern = DefaultLinuxSearchPattern;
break;
case RecognizedOSPlatformEnum.OSX:
throw new UnsupportedPlatformException($"Cannot locate Postgres binaries when running on OSX platform. OSX platform is not supported.");
break;
throw new UnsupportedPlatformException("Cannot locate Postgres binaries when running on OSX platform. OSX platform is not supported.");
case RecognizedOSPlatformEnum.Windows:
_searchPattern = DefaultWindowsSearchPattern;
break;
default:
#if NETSTANDARD2_0
throw new PostgresBinariesNotFoundException($"Unknow OS:{RuntimeInformation.OSDescription}");
#endif
throw new PostgresBinariesNotFoundException("Unknow OS. This library is only compatible with Microsoft Windows");

}
}
Expand All @@ -50,8 +52,10 @@ internal string Directory

private string ResolveBinariesDirectory()
{
string searchPatternWithPackagesRootFolder = _nugetPrefix + _searchPattern;

var binariesFolder =
FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(Path.Combine(_nugetPrefix, _searchPattern))
FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(searchPatternWithPackagesRootFolder)
??
FolderSearch.CurrentExecutingDirectory().FindFolderUpwards(_searchPattern);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static void Exec(string binariesDirectory, string dataDirectory, string
.CreateProcess(pgControllerExecutablePath, arguments);

Process.ProcessOutput output = Process.ProcessController
.StartAndWaitForExit(serverInitializatorProcess, $"Postgres cluster initializing");
.StartAndWaitForExit(serverInitializatorProcess, "Postgres cluster initializing");

if(output.ExitCode != 0)
throw new PostgresProcessFinishedWithErrorsException("Cannot initialize Postgres cluster." + output.ToString());
Expand Down
4 changes: 2 additions & 2 deletions src/Postgres2Go/Postgres2Go.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net46;net47</TargetFrameworks>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
Expand Down

0 comments on commit cb9bf6d

Please sign in to comment.