Commit e16c6995 authored by Nick Craver's avatar Nick Craver

Dapper build fixes, versioning, and SQL CE drop

- Moves to NerdBank git-based versioning
- Cleans up build.ps1 to current (will tweak for older moves later)
- Updates xUnit to latest
- Moves to dotnet test, since they killed dotnet xunit
- Testing SQL Server CE has become unreasonable. It's gone (minimal cleanup in this commit disabling it).
parent 1cd3efd8
...@@ -22,9 +22,5 @@ ...@@ -22,9 +22,5 @@
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" /> <PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
<PackageReference Include="xunit" Version="$(xUnitVersion)" /> <PackageReference Include="xunit" Version="$(xUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)" /> <PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)" />
<DotNetCliToolReference Include="dotnet-xunit" Version="$(xUnitVersion)" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net452' "> <PropertyGroup Condition=" '$(TargetFramework)' == 'net452' ">
<DefineConstants>$(DefineConstants);ENTITY_FRAMEWORK;LINQ2SQL;SQL_CE;OLEDB</DefineConstants> <DefineConstants>$(DefineConstants);ENTITY_FRAMEWORK;LINQ2SQL;OLEDB</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Test.DB.sdf" /> <None Remove="Test.DB.sdf" />
...@@ -27,13 +27,11 @@ ...@@ -27,13 +27,11 @@
<PackageReference Include="System.ValueTuple" Version="4.4.0" /> <PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="xunit" Version="$(xUnitVersion)" /> <PackageReference Include="xunit" Version="$(xUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)" /> <PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)" />
<DotNetCliToolReference Include="dotnet-xunit" Version="$(xUnitVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net452'"> <ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" /> <ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.1" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.1" />
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.314.76" /> <PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.314.76" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
...@@ -52,10 +50,6 @@ ...@@ -52,10 +50,6 @@
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.0.0" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<PostBuildEvent> <PostBuildEvent>
if not exist "$(TargetDir)x86" md "$(TargetDir)x86" if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
......
...@@ -29,7 +29,7 @@ public SkippableFactDiscoverer(IMessageSink diagnosticMessageSink) ...@@ -29,7 +29,7 @@ public SkippableFactDiscoverer(IMessageSink diagnosticMessageSink)
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{ {
yield return new SkippableFactTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); yield return new SkippableFactTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod);
} }
} }
...@@ -40,8 +40,8 @@ public SkippableFactTestCase() ...@@ -40,8 +40,8 @@ public SkippableFactTestCase()
{ {
} }
public SkippableFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null) public SkippableFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null)
: base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
{ {
} }
......
#if SQL_CE
using System.Data.SqlServerCe;
using System.IO;
using System.Linq;
using Xunit;
namespace Dapper.Tests
{
public class SQLCETests : TestBase
{
[Fact]
public void MultiRSSqlCE()
{
if (File.Exists("Test.DB.sdf"))
File.Delete("Test.DB.sdf");
const string cnnStr = "Data Source = Test.DB.sdf;";
var engine = new SqlCeEngine(cnnStr);
engine.CreateDatabase();
using (var cnn = new SqlCeConnection(cnnStr))
{
cnn.Open();
cnn.Execute("create table Posts (ID int, Title nvarchar(50), Body nvarchar(50), AuthorID int)");
cnn.Execute("create table Authors (ID int, Name nvarchar(50))");
cnn.Execute("insert Posts values (1,'title','body',1)");
cnn.Execute("insert Posts values(2,'title2','body2',null)");
cnn.Execute("insert Authors values(1,'sam')");
var data = cnn.Query<PostCE, AuthorCE, PostCE>("select * from Posts p left join Authors a on a.ID = p.AuthorID", (post, author) => { post.Author = author; return post; }).ToList();
var firstPost = data[0];
Assert.Equal("title", firstPost.Title);
Assert.Equal("sam", firstPost.Author.Name);
Assert.Null(data[1].Author);
}
}
public class PostCE
{
public int ID { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public AuthorCE Author { get; set; }
}
public class AuthorCE
{
public int ID { get; set; }
public string Name { get; set; }
}
}
}
#endif
...@@ -8,11 +8,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ...@@ -8,11 +8,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig .editorconfig = .editorconfig
appveyor.yml = appveyor.yml appveyor.yml = appveyor.yml
build.ps1 = build.ps1 build.ps1 = build.ps1
build.sh = build.sh Directory.build.props = Directory.build.props
License.txt = License.txt License.txt = License.txt
nuget.config = nuget.config nuget.config = nuget.config
Readme.md = Readme.md Readme.md = Readme.md
semver.txt = semver.txt semver.txt = semver.txt
version.json = version.json
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dapper", "Dapper\Dapper.csproj", "{FAC24C3F-68F9-4247-A4B9-21D487E99275}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dapper", "Dapper\Dapper.csproj", "{FAC24C3F-68F9-4247-A4B9-21D487E99275}"
......
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<VersionPrefix>1.50.2</VersionPrefix>
<Copyright>2017 Stack Exchange, Inc.</Copyright> <Copyright>2017 Stack Exchange, Inc.</Copyright>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
...@@ -19,16 +17,17 @@ ...@@ -19,16 +17,17 @@
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<IncludeSymbols>false</IncludeSymbols> <IncludeSymbols>false</IncludeSymbols>
<xUnitVersion>2.3.0-beta5-build3769</xUnitVersion> <xUnitVersion>2.4.1-pre.build.4059</xUnitVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net40' OR '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net451'"> <ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<Reference Include="System.Core" Pack="false" /> <Reference Include="System.Core" Pack="false" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.2" PrivateAssets="All" /> <PackageReference Include="Nerdbank.GitVersioning" Version="2.2.13" PrivateAssets="all" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.2" /> <PackageReference Include="SourceLink.Create.GitHub" Version="2.8.3" PrivateAssets="All" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.2" /> <DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.3" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
[CmdletBinding(PositionalBinding=$false)] [CmdletBinding(PositionalBinding=$false)]
param( param(
[string] $Version,
[string] $BuildNumber,
[bool] $CreatePackages, [bool] $CreatePackages,
[bool] $RunTests = $true, [bool] $RunTests = $true,
[string] $PullRequestNumber [string] $PullRequestNumber
) )
function CalculateVersion() {
if ($version) {
return $version
}
$semVersion = '';
$path = $pwd;
while (!$semVersion) {
if (Test-Path (Join-Path $path "semver.txt")) {
$semVersion = Get-Content (Join-Path $path "semver.txt")
break
}
if ($PSScriptRoot -eq $path) {
break
}
$path = Split-Path $path -Parent
}
if (!$semVersion) {
Write-Error "semver.txt was not found in $pwd or any parent directory"
Exit 1
}
if ($semVersion -match "-") {
return "$semVersion-$BuildNumber" #prerelease
} else {
return "$semVersion" #release
}
}
if ($BuildNumber -and $BuildNumber.Length -lt 5) {
$BuildNumber = $BuildNumber.PadLeft(5, "0")
}
Write-Host "Run Parameters:" -ForegroundColor Cyan Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host "Version: $Version" Write-Host " CreatePackages: $CreatePackages"
Write-Host "BuildNumber: $BuildNumber" Write-Host " RunTests: $RunTests"
Write-Host "CreatePackages: $CreatePackages" Write-Host " dotnet --version:" (dotnet --version)
Write-Host "RunTests: $RunTests"
Write-Host "Base Version: $(CalculateVersion)"
$packageOutputFolder = "$PSScriptRoot\.nupkgs" $packageOutputFolder = "$PSScriptRoot\.nupkgs"
$projectsToBuild = $projectsToBuild =
...@@ -63,25 +24,27 @@ $testsToRun = ...@@ -63,25 +24,27 @@ $testsToRun =
'Dapper.Tests', 'Dapper.Tests',
'Dapper.Tests.Contrib' 'Dapper.Tests.Contrib'
if (!$Version -and !$BuildNumber) {
Write-Host "ERROR: You must supply either a -Version or -BuildNumber argument. `
Use -Version `"4.0.0`" for explicit version specification, or `
Use -BuildNumber `"12345`" for generation using <semver.txt>-<buildnumber>" -ForegroundColor Yellow
Exit 1
}
if ($PullRequestNumber) { if ($PullRequestNumber) {
Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow
$CreatePackages = $false $CreatePackages = $false
} }
Write-Host "Building projects..." -ForegroundColor "Magenta"
foreach ($project in $projectsToBuild + $testsToRun) {
Write-Host "Building $project (dotnet restore/build)..." -ForegroundColor "Magenta"
dotnet restore ".\$project\$project.csproj" /p:CI=true
dotnet build ".\$project\$project.csproj" -c Release /p:CI=true
Write-Host ""
}
Write-Host "Done building." -ForegroundColor "Green"
if ($RunTests) { if ($RunTests) {
dotnet restore /ConsoleLoggerParameters:Verbosity=Quiet dotnet restore /ConsoleLoggerParameters:Verbosity=Quiet
foreach ($project in $testsToRun) { foreach ($project in $testsToRun) {
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta" Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
Push-Location ".\$project" Push-Location ".\$project"
dotnet xunit dotnet test -c Release
if ($LastExitCode -ne 0) { if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red" Write-Host "Error with tests, aborting build." -Foreground "Red"
Pop-Location Pop-Location
...@@ -100,31 +63,11 @@ if ($CreatePackages) { ...@@ -100,31 +63,11 @@ if ($CreatePackages) {
Write-Host "done." -ForegroundColor "Green" Write-Host "done." -ForegroundColor "Green"
Write-Host "Building all packages" -ForegroundColor "Green" Write-Host "Building all packages" -ForegroundColor "Green"
}
foreach ($project in $projectsToBuild) {
Write-Host "Working on $project`:" -ForegroundColor "Magenta"
Push-Location ".\$project"
$semVer = CalculateVersion foreach ($project in $projectsToBuild) {
$targets = "Restore" Write-Host "Packing $project (dotnet pack)..." -ForegroundColor "Magenta"
dotnet pack ".\$project\$project.csproj" --no-build -c Release /p:PackageOutputPath=$packageOutputFolder /p:NoPackageAnalysis=true /p:CI=true
Write-Host " Restoring " -NoNewline -ForegroundColor "Magenta"
if ($CreatePackages) {
$targets += ";Pack"
Write-Host "and packing " -NoNewline -ForegroundColor "Magenta"
}
Write-Host "$project... (Version:" -NoNewline -ForegroundColor "Magenta"
Write-Host $semVer -NoNewline -ForegroundColor "Cyan"
Write-Host ")" -ForegroundColor "Magenta"
dotnet msbuild "/t:$targets" "/p:Configuration=Release" "/p:Version=$semVer" "/p:PackageOutputPath=$packageOutputFolder" "/p:CI=true"
Pop-Location
Write-Host "Done." -ForegroundColor "Green"
Write-Host "" Write-Host ""
}
} }
Write-Host "Build Complete." -ForegroundColor "Green" Write-Host "Build Complete." -ForegroundColor "Green"
{
"version": "1.50.7-alpha.{height}",
"assemblyVersion": "1.50.0.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+"
],
"nugetPackageVersion": {
"semVer": 2
},
"cloudBuild": {
"buildNumber": {
"enabled": true,
"setVersionVariables": true
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment