diff --git a/Build/build-scripts.ps1 b/Build/build-scripts.ps1 index 959b2f38..b374dcb1 100644 --- a/Build/build-scripts.ps1 +++ b/Build/build-scripts.ps1 @@ -104,7 +104,8 @@ function Test-Unit($targetFramework) { $sourceDir = Join-Path $sourceDir $targetFramework $testList = Get-ChildItem -Path $sourceDir -Recurse -Filter *.Test.dll ` - | ForEach-Object {$_.FullName} + | Where-Object FullName -NotMatch \\ref\\ ` + | ForEach-Object {$_.FullName} if (-not $testList.Count) { throw ($Framework + " test list is empty.") diff --git a/Build/build-tasks.ps1 b/Build/build-tasks.ps1 index 18cf701d..81f7f08c 100644 --- a/Build/build-tasks.ps1 +++ b/Build/build-tasks.ps1 @@ -6,7 +6,8 @@ Task UnitTest -Depends InitializeTests ` , UnitTest452 ` , UnitTest472 ` , UnitTestcore22 ` - , UnitTestcore31 + , UnitTestcore31 ` + , UnitTest50 Task Test -Depends InitializeTests ` , TestPublishModule ` , TestPowerShellDesktop ` @@ -22,10 +23,13 @@ Task Test -Depends InitializeTests ` , TestPowerShellCore702 ` , TestPowerShellCore703 ` , TestPowerShellCore710 ` + , TestPowerShellCore720 ` , TestGlobalTool22 ` , TestGlobalTool31 ` + , TestGlobalTool50 ` , TestNetCore22 ` - , TestNetCore31 + , TestNetCore31 ` + , TestNet50 Task Initialize { $script:nugetexe = Join-Path $PSScriptRoot "nuget.exe" @@ -147,6 +151,10 @@ Task PackManualDownload { $destination = Join-Path $out "SqlDatabase.$packageVersion-netcore31.zip" $source = Join-Path $binDir "SqlDatabase\netcoreapp3.1\publish\*" Compress-Archive -Path $source, $lic -DestinationPath $destination + + $destination = Join-Path $out "SqlDatabase.$packageVersion-net50.zip" + $source = Join-Path $binDir "SqlDatabase\net5.0\publish\*" + Compress-Archive -Path $source, $lic -DestinationPath $destination } Task InitializeTests { @@ -179,6 +187,10 @@ Task UnitTestcore31 { Test-Unit "netcoreapp3.1" } +Task UnitTest50 { + Test-Unit "net5.0" +} + Task TestPowerShellCore611 { Test-PowerShellCore "mcr.microsoft.com/powershell:6.1.1-alpine-3.8" } @@ -224,7 +236,11 @@ Task TestPowerShellCore703 { } Task TestPowerShellCore710 { - Test-PowerShellCore "mcr.microsoft.com/powershell:7.1.0-rc.1-ubuntu-18.04-20200928" + Test-PowerShellCore "mcr.microsoft.com/powershell:7.1.0-ubuntu-18.04" +} + +Task TestPowerShellCore720 { + Test-PowerShellCore "mcr.microsoft.com/powershell:7.2.0-preview.1-ubuntu-20.04" } Task TestPublishModule { @@ -253,6 +269,10 @@ Task TestGlobalTool31 { Test-GlobalTool "mcr.microsoft.com/dotnet/core/sdk:3.1" } +Task TestGlobalTool50 { + Test-GlobalTool "mcr.microsoft.com/dotnet/sdk:5.0" +} + Task TestNetCore22 { Test-NetCore "netcoreapp2.2" "microsoft/dotnet:2.2-runtime" } @@ -260,3 +280,7 @@ Task TestNetCore22 { Task TestNetCore31 { Test-NetCore "netcoreapp3.1" "mcr.microsoft.com/dotnet/core/runtime:3.1" } + +Task TestNet50 { + Test-NetCore "net5.0" "mcr.microsoft.com/dotnet/runtime:5.0" +} diff --git a/Examples/CSharpMirationStep/readme.md b/Examples/CSharpMirationStep/readme.md index c6e648d7..60421269 100644 --- a/Examples/CSharpMirationStep/readme.md +++ b/Examples/CSharpMirationStep/readme.md @@ -2,13 +2,13 @@ ========================================== Any assembly script is -- .exe or .dll .NET assembly -- target framework is 4.5.2 or .net core 2.2 +- .exe or .dll for target framework is 4.5.2+ +- .dll for .net core 2.2/3.1 or .net5.0 - has exactly one class with script implementation This project is an example of script implementation. The build output is 2.1_2.2.dll with target framework 4.5.2. -Due to the current dependencies, 2.1_2.2.dll works well on .net core 2.2. +Due to the current dependencies, 2.1_2.2.dll works well on .net core 2.2/3.1 and .net 5.0. ## Script source Method [SqlDatabaseScript.Execute](SqlDatabaseScript.cs) implements a logic of script diff --git a/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj b/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj index e8b52dc5..98272266 100644 --- a/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj +++ b/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj @@ -10,7 +10,7 @@ - + diff --git a/README.md b/README.md index d55010cb..f2440df7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ SqlDatabase [![PowerShell Gallery](https://img.shields.io/powershellgallery/v/SqlDatabase.svg?style=flat-square)](https://www.powershellgallery.com/packages/SqlDatabase) [![GitHub release](https://img.shields.io/github/release/max-ieremenko/SqlDatabase.svg?style=flat-square&label=manual%20download)](https://github.com/max-ieremenko/SqlDatabase/releases) -Command-line tool and PowerShell module for SQL Server to execute scripts, export data and database migrations. +Command-line tool and PowerShell module for SQL Server allows to execute scripts, database migrations and export data. Table of Contents ----------------- @@ -30,11 +30,11 @@ Table of Contents Installation ------------ -PowerShell module is compatible with PowerShell Desktop 5.1 and Powershell Core 6.1.0+. +PowerShell module is compatible with Powershell Core 6.1+ and PowerShell Desktop 5.1. -Dotnet tool requires .Net Core SDK 2.2/3.1. +Dotnet tool requires SDK .Net 5.0 or .Net Core 2.2/3.1. -Command-line tool is compatible with .Net Framework 4.5.2+ and .Net Core runtime 2.2/3.1. +Command-line tool is compatible with .Net runtime 5.0, .Net Core runtime 2.2/3.1 and .Net Framework 4.5.2+. ### PowerShell, from gallery diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index a44e9e3b..de37e3b9 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -11,7 +11,7 @@ - + diff --git a/Sources/GlobalAssemblyInfo.cs b/Sources/GlobalAssemblyInfo.cs index e97a7326..85b63946 100644 --- a/Sources/GlobalAssemblyInfo.cs +++ b/Sources/GlobalAssemblyInfo.cs @@ -9,5 +9,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("2.1.1.0")] -[assembly: AssemblyFileVersion("2.1.1.0")] +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] diff --git a/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec b/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec index 0c8ff52c..3449e5f8 100644 --- a/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec +++ b/Sources/SqlDatabase.Package/choco/sqldatabase.nuspec @@ -15,7 +15,8 @@ https://github.com/max-ieremenko/SqlDatabase/raw/master/icon-32.png false Command-line tool and PowerShell module for SQL Server. - SqlDatabase is a tool for SQL Server, allows executing scripts, database migrations and data export. + SqlDatabase is a tool for SQL Server, allows to execute scripts, database migrations and export data. +Requires Powershell Core 6.1+ or PowerShell Desktop 5.1. https://github.com/max-ieremenko/SqlDatabase/releases (C) 2018-2020 Max Ieremenko. sqlserver sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data diff --git a/Sources/SqlDatabase.Package/nuget/package.nuspec b/Sources/SqlDatabase.Package/nuget/package.nuspec index 66672f1d..88af059f 100644 --- a/Sources/SqlDatabase.Package/nuget/package.nuspec +++ b/Sources/SqlDatabase.Package/nuget/package.nuspec @@ -12,7 +12,7 @@ icon-32.png false Command-line tool and PowerShell module for SQL Server. - SqlDatabase is a tool for SQL Server, allows executing scripts, database migrations and data export. + SqlDatabase is a tool for SQL Server, allows to execute scripts, database migrations and export data. https://github.com/max-ieremenko/SqlDatabase/releases (C) 2018-2020 Max Ieremenko. sqlserver sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data diff --git a/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj b/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj index f72a6515..004a8b67 100644 --- a/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj +++ b/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj @@ -7,11 +7,11 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 b/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 index f8521cbd..530ee3a0 100644 Binary files a/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 and b/Sources/SqlDatabase.PowerShell/SqlDatabase.psd1 differ diff --git a/Sources/SqlDatabase.Test/Export/DataExporterTest.cs b/Sources/SqlDatabase.Test/Export/DataExporterTest.cs index 50556fa4..edc4b17b 100644 --- a/Sources/SqlDatabase.Test/Export/DataExporterTest.cs +++ b/Sources/SqlDatabase.Test/Export/DataExporterTest.cs @@ -255,6 +255,10 @@ private static IEnumerable GetExportCases() yield return new TestCaseData("DATETIME2", date, date) { TestName = "DATETIME2" }; yield return new TestCaseData("SMALLDATETIME", date.AddSeconds(-30), date.AddSeconds(30)) { TestName = "SMALLDATETIME" }; yield return new TestCaseData("TIME", date.TimeOfDay, date.TimeOfDay) { TestName = "TIME" }; + + var dateTimeOffset = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2)); + yield return new TestCaseData("DATETIMEOFFSET", dateTimeOffset, dateTimeOffset) { TestName = "DATETIMEOFFSET" }; + ////yield return new TestCaseData() { TestName = "" }; } } diff --git a/Sources/SqlDatabase.Test/Export/SqlWriterTest.cs b/Sources/SqlDatabase.Test/Export/SqlWriterTest.cs index dc13423d..54f38bdc 100644 --- a/Sources/SqlDatabase.Test/Export/SqlWriterTest.cs +++ b/Sources/SqlDatabase.Test/Export/SqlWriterTest.cs @@ -20,6 +20,12 @@ public void BeforeEachTest() _sut = new SqlWriter(new StringWriter(_output)); } + [TearDown] + public void AfterEachTest() + { + Console.WriteLine(_output); + } + [Test] public void Null() { @@ -100,5 +106,18 @@ public void ValueEmptyByteArray() Query.ExecuteScalar(_output.ToString()).ShouldBe(value); } + + [Test] + public void ValueDateTimeOffset() + { + var value = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2)); + + _sut + .Text("SELECT CAST(") + .Value(value) + .Text(" AS DATETIMEOFFSET)"); + + Query.ExecuteScalar(_output.ToString()).ShouldBe(value); + } } } diff --git a/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj b/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj index 94fb60ea..34a28ade 100644 --- a/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj +++ b/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj @@ -1,7 +1,7 @@  - net452;netcoreapp2.2;netcoreapp3.1 + net452;netcoreapp2.2;netcoreapp3.1;net5.0 SqlDatabase NU1702 ..\..\bin\Tests @@ -30,6 +30,7 @@ + @@ -52,11 +53,11 @@ - - + + - + diff --git a/Sources/SqlDatabase/Export/SqlWriter.cs b/Sources/SqlDatabase/Export/SqlWriter.cs index 8636e541..5fc593b2 100644 --- a/Sources/SqlDatabase/Export/SqlWriter.cs +++ b/Sources/SqlDatabase/Export/SqlWriter.cs @@ -195,9 +195,15 @@ private bool TryWriteValue(object value) return true; } - if (value is TimeSpan time) + if (value is TimeSpan timeSpan) { - ValueTimeSpan(time); + ValueTimeSpan(timeSpan); + return true; + } + + if (value is DateTimeOffset dateTimeOffset) + { + ValueDateTimeOffset(dateTimeOffset); return true; } @@ -259,5 +265,12 @@ private void ValueTimeSpan(TimeSpan value) Output.Write(value.ToString("g", CultureInfo.InvariantCulture)); Output.Write(Q); } + + private void ValueDateTimeOffset(DateTimeOffset value) + { + Output.Write(Q); + Output.Write(value.ToString("yyyy-MM-ddTHH:mm:ss.fffK", CultureInfo.InvariantCulture)); + Output.Write(Q); + } } } diff --git a/Sources/SqlDatabase/SqlDatabase.csproj b/Sources/SqlDatabase/SqlDatabase.csproj index 333b2327..3bfe4840 100644 --- a/Sources/SqlDatabase/SqlDatabase.csproj +++ b/Sources/SqlDatabase/SqlDatabase.csproj @@ -1,11 +1,11 @@  - net452;netcoreapp2.2;netcoreapp3.1;netstandard2.0 + net452;netcoreapp2.2;netcoreapp3.1;net5.0;netstandard2.0 - netcoreapp2.2;netcoreapp3.1 + netcoreapp2.2;netcoreapp3.1;net5.0