Skip to content

Commit

Permalink
Issue 363 (#364)
Browse files Browse the repository at this point in the history
* Added scripts for running PostgreSQL integration tests

* Replaced ILMerge with Costura.Fody

* Fixed some path problems
  • Loading branch information
erikbra authored Feb 3, 2019
1 parent a00e81a commit 0047ffb
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 193 deletions.
4 changes: 2 additions & 2 deletions build/Extract-Resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ If (! (Test-Path $OutputFile)) {
}

#Powershell and powershell Core have different ways of doing this, so safeguard.
$IsWin = ($IsWindows -or $env:OS -eq "Windows_NT")
If ($IsWin) {
$IsFullFramework = ($PSVersionTable.PSEdition -eq "Desktop")
If ($IsFullFramework) {
[System.Reflection.Assembly] $assembly = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($f);
} Else {
[System.Reflection.Assembly] $assembly = [System.Reflection.Assembly]::LoadFile($f);
Expand Down
5 changes: 5 additions & 0 deletions build/run-postgres-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env pwsh

$Root="$($PSScriptRoot)/..";

& "$Root/code_drop/merge/rh.exe" --dt postgres --cs "host=localhost; port=5432; database=db; username=postgres; password=monkeybusiness;"
5 changes: 5 additions & 0 deletions build/setup-postgres.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/env pwsh

docker pull postgres
docker run -d --name postgres-rh-test -e 'POSTGRES_PASSWORD=monkeybusiness' -p 5432:5432 postgres

3 changes: 3 additions & 0 deletions build/start-postgres.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /usr/bin/env pwsh

docker start postgres-rh-test
37 changes: 0 additions & 37 deletions ilmerge.bat

This file was deleted.

104 changes: 0 additions & 104 deletions lib/ILMerge/ILMerge License.rtf

This file was deleted.

Binary file removed lib/ILMerge/ILMerge.doc
Binary file not shown.
Binary file removed lib/ILMerge/ILMerge.exe
Binary file not shown.
4 changes: 4 additions & 0 deletions product/roundhouse.console/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
111 changes: 111 additions & 0 deletions product/roundhouse.console/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
2 changes: 2 additions & 0 deletions product/roundhouse.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private static void Main(string[] args)
run_migrator(cf);
}
}


catch (Exception ex)
{
the_logger.Error(ex.Message, ex);
Expand Down
10 changes: 0 additions & 10 deletions product/roundhouse.console/packages.config

This file was deleted.

52 changes: 27 additions & 25 deletions product/roundhouse.console/roundhouse.console.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="'$(TargetFramework)' == ''" >netcoreapp2.1;net461</TargetFrameworks>
<TargetFramework Condition="'$(TargetFramework)' == ''" >net461</TargetFramework>
<TargetFrameworks Condition="'$(TargetFramework)' == ''">netcoreapp2.1;net461</TargetFrameworks>
<TargetFramework Condition="'$(TargetFramework)' == ''">net461</TargetFramework>
<CLSCompliant>true</CLSCompliant>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -45,7 +45,12 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.3.2" />
<PackageReference Include="FluentNHibernate" Version="2.1.2" />
<PackageReference Include="Fody" Version="3.3.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Iesi.Collections" Version="4.0.4" />
<PackageReference Include="Microsoft.Build.Framework" Version="15.9.20" />
<PackageReference Include="MySql.Data" Version="8.0.13" />
Expand Down Expand Up @@ -77,7 +82,7 @@
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="../../generated/MySql.Data/keywords.txt" Link="$(AssemblyName).keywords.txt" >
<EmbeddedResource Include="../../generated/MySql.Data/keywords.txt" Link="$(AssemblyName).keywords.txt">
<LogicalName>$(AssemblyName).keywords.txt</LogicalName>
</EmbeddedResource>
</ItemGroup>
Expand All @@ -87,34 +92,31 @@
<None Include="rh.bat" CopyToOutputDirectory="PreserveNewest" />
<None Include="DotnetToolSettings.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<!-- Merge properties and target -->

<PropertyGroup>
<ILMergeDir>..\..\code_drop\merge\</ILMergeDir>
<LogDir>..\..\code_drop\log\</LogDir>
<ILMergeTarget>$(ILMergeDir)$(AssemblyName).exe</ILMergeTarget>
<DropDir>..\..\code_drop\merge\</DropDir>
<Extension>.dll</Extension>
</PropertyGroup>
<Target Name="ILMerge" AfterTargets="Build" Condition="'$(BuildingInsideVisualStudio)' != 'true' and '$(TargetFramework)' == 'net461'">
<ItemGroup>
<ILMergeAssemblies Include="$(OutputPath)*.dll" />
</ItemGroup>
<PropertyGroup>
<IgnoreFile>..\..\build.custom\ilmerge.internalize.ignore.txt</IgnoreFile>
<ILMerge>..\..\lib\ILMerge\ILMerge.exe</ILMerge>
<ILMergeLog>$(LogDir)roundhouse.console.ILMerge.log</ILMergeLog>
<ILMergeSource>$(OutputPath)$(AssemblyName).exe</ILMergeSource>
<ILMergeCommand>$(ILMerge) /internalize:$(IgnoreFile) /target:exe /out:$(ILMergeTarget) /log:$(ILMergeLog) /ndebug /zeroPeKind /allowDup $(ILMergeSource) @(ILMergeAssemblies, ' ')</ILMergeCommand>
</PropertyGroup>
<Delete Files="$(ILMergeLog);$(ILMergeTarget)" Condition="Exists($(ILMergeDir))" />
<MakeDir Directories="$(ILMergeDir)" />
<Message Importance="high" Text="ILMerge-ing into $(ILMergeTarget)" />
<Exec Command="$(ILMergeCommand)" />

<PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
<Extension>.exe</Extension>
</PropertyGroup>

<PropertyGroup>
<CopySource>$(MSBuildProjectDirectory)/$(OutputPath)/$(TargetFramework)/$(RuntimeIdentifier)/$(AssemblyName)$(Extension)</CopySource>
<CopyDestination>$(DropDir)$(AssemblyName)$(Extension)</CopyDestination>
</PropertyGroup>

<Target Name="CopyOutput" AfterTargets="Build" Condition="'$(BuildingInsideVisualStudio)' != 'true' and '$(TargetFramework)' == 'net461'">
<Message Importance="high" Text="Source: $(CopySource)" />
<Copy SourceFiles="$(CopySource)" DestinationFolder="$(DropDir)" />
</Target>


<!-- Nuspec properties (for generating NuGet package) -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
<NuspecFile>roundhouse.nuspec</NuspecFile>
<NuspecProperties>mergedExe=$(ILMergeTarget);version=$(NugetVersion)</NuspecProperties>
<NuspecProperties>mergedExe=$(CopyDestination);version=$(NugetVersion)</NuspecProperties>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PackageReference Include="FluentNHibernate" Version="2.1.2" />
<PackageReference Include="Iesi.Collections" Version="4.0.4" />
<PackageReference Include="NHibernate" Version="5.1.3" />
<PackageReference Include="Npgsql" Version="3.2.7" />
<PackageReference Include="Npgsql" Version="4.0.4" />
<PackageReference Include="System.Linq" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion product/roundhouse.lib.merged/roundhouse.lib.merged.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="../../generated/MySql.Data/keywords.txt" Link="$(AssemblyName).keywords.txt" >
<EmbeddedResource Include="../../generated/MySql.Data/keywords.txt" Link="$(AssemblyName).keywords.txt">
<LogicalName>$(AssemblyName).keywords.txt</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILMerge" Version="3.0.21" />
</ItemGroup>


<!-- Merge properties and target -->
Expand All @@ -95,6 +98,7 @@
<PropertyGroup>
<IgnoreFile>..\..\build.custom\ilmerge.internalize.ignore.txt</IgnoreFile>
<ILMerge>..\..\lib\ILMerge\ILMerge.exe</ILMerge>
<ILMerge>$(NugetPackageRoot)\ilmerge\3.0.21\tools\net452\ILMerge.exe</ILMerge>
<ILMergeLog>$(LogDir)roundhouse.ILMerge.log</ILMergeLog>
<ILMergeCommand>$(ILMerge) /internalize:$(IgnoreFile) /target:dll /out:$(ILMergeTarget) /log:$(ILMergeLog) /ndebug /zeroPeKind /allowDup @(ILMergeAssemblies, ' ')</ILMergeCommand>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<CLSCompliant>true</CLSCompliant>
Expand Down
2 changes: 1 addition & 1 deletion product/roundhouse.tests/roundhouse.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="MySql.Data" Version="8.0.13" />
<PackageReference Include="Npgsql" Version="3.2.7" />
<PackageReference Include="Npgsql" Version="4.0.4" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
Expand Down
24 changes: 23 additions & 1 deletion product/roundhouse/connections/AdoNetConnection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using System.Data;
using System.Linq;
using System.Reflection;

namespace roundhouse.connections
{
Expand All @@ -15,7 +18,26 @@ public AdoNetConnection(IDbConnection server_connection)

public void open()
{
server_connection.Open();
try
{

server_connection.Open(); }

catch (ReflectionTypeLoadException rtle)
{
throw rtle.LoaderExceptions.First();

}

catch (TypeInitializationException tie)
{
var inner = tie.InnerException;
if (inner is ReflectionTypeLoadException r)
{
throw r.LoaderExceptions.First();
}
}

}

public void clear_pool()
Expand Down
Loading

0 comments on commit 0047ffb

Please sign in to comment.