Skip to content

Commit

Permalink
Merge pull request #10 from LuccaSA/update.dotnet8
Browse files Browse the repository at this point in the history
update to .net 8
  • Loading branch information
rducom committed Jul 3, 2024
2 parents a8104a2 + 7451b53 commit 79b2825
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 80 deletions.
56 changes: 24 additions & 32 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow

- name: Dump globals
Expand All @@ -26,55 +26,47 @@ jobs:
GLOBAL_STEPS: ${{ toJson(steps) }}

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: '5.5.0'
versionSpec: '5.12.0'

- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.9.7

- uses: actions/setup-java@v3
with:
distribution: 'microsoft' # See 'Supported distributions' for available options
java-version: '11'

- name: Setup SonarScanner
run: dotnet tool install --tool-path tools dotnet-sonarscanner

- name: Setup ReportGenerator
run: dotnet tool install --tool-path tools dotnet-reportgenerator-globaltool

- name: SonarScanner begin
run: tools/dotnet-sonarscanner begin /k:"SqlBackupTools" /o:"lucca" /v:${{ env.GitVersion_FullSemVer }} /d:sonar.login=${{ secrets.SONAR_TOKEN }} /d:sonar.host.url="https://sonarcloud.io/" /d:sonar.coverageReportPaths="./sonarCoverage/SonarQube.xml"
uses: gittools/actions/gitversion/execute@v1.1.1

- name: LocalDB
run: |
Write-Host "Downloading"
Import-Module BitsTransfer
Start-BitsTransfer -Source https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi -Destination SqlLocalDB.msi
Write-Host "Installing"
Start-Process -FilePath "SqlLocalDB.msi" -Wait -ArgumentList "/qn", "/norestart", "/l*v SqlLocalDBInstall.log", "IACCEPTSQLLOCALDBLICENSETERMS=YES";
try {
Start-Process -FilePath "SqlLocalDB.msi" -Wait -ArgumentList "/qn", "/norestart", "/l*v SqlLocalDBInstall.log", "IACCEPTSQLLOCALDBLICENSETERMS=YES"
}
catch {
Write-Host "Installation failed"
Get-Content SqlLocalDBInstall.log
throw
}
Write-Host "Checking"
sqlcmd -l 60 -S "(localdb)\MSSQLLocalDB" -Q "SELECT @@VERSION;"
Write-Host "SqlLocalDB 2019 installed and accessible at (localdb)\MSSQLLocalDB"
try {
sqlcmd -l 60 -S "(localdb)\MSSQLLocalDB" -Q "SELECT @@VERSION;"
Write-Host "SqlLocalDB 2019 installed and accessible at (localdb)\MSSQLLocalDB"
}
catch {
Write-Host "Sqlcmd execution failed"
throw
}
- name: Test
run: dotnet test --configuration Release /p:CollectCoverage=true --collect:"XPlat Code Coverage" --settings coverlet.runsettings --results-directory:./coverage
run: dotnet test --configuration Release
env:
TEST_SQL_INSTANCE: (localdb)\MSSQLLocalDB

- name: Merge coverages
run: tools/reportgenerator -reports:./coverage/*/*.xml -targetdir:./sonarCoverage -reporttypes:SonarQube

- name: SonarScanner end
run: tools/dotnet-sonarscanner end /d:sonar.login=${{ secrets.SONAR_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- name: Pack
if: startsWith(github.ref, 'refs/tags/')
run: dotnet publish src\SqlBackupTools\SqlBackupTools.csproj -c Release -o published -r win10-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix="${{ env.GitVersion_SemVer }}" /p:AssemblyVersion="${{ env.GitVersion_AssemblySemVer }}"
run: dotnet publish src\SqlBackupTools\SqlBackupTools.csproj -c Release -o published -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix="${{ env.GitVersion_SemVer }}" /p:AssemblyVersion="${{ env.GitVersion_AssemblySemVer }}"

- name: Zip
if: startsWith(github.ref, 'refs/tags/')
Expand Down
7 changes: 2 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Authors>rducom</Authors>
<Description>SqlBackupsTools</Description>
<PackageProjectUrl>https://github.com/LuccaSA/SqlBackupTools</PackageProjectUrl>
<Copyright>Copyright Lucca 2021</Copyright>
<Copyright>Copyright Lucca 2024</Copyright>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -24,10 +24,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions SqlBackupTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBackupTools", "src\SqlBa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBackupTools.Tests", "tests\SqlBackupTools.Tests\SqlBackupTools.Tests.csproj", "{30AD9161-DD80-40E7-965D-6923D244D19A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{71E7863F-0717-4A94-94E7-41338BA249E0}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
.github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml
global.json = global.json
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "v8.0.302",
"rollForward": "latestMajor"
}
}
}
22 changes: 15 additions & 7 deletions src/SqlBackupTools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SqlBackupTools.Restore;
using SqlBackupTools.SerilogAsync;
using System.Globalization;
using Serilog.Configuration;

namespace SqlBackupTools
{
Expand Down Expand Up @@ -99,13 +100,20 @@ private static Logger CreateLogger(GeneralCommandInfos commandInfos)
};

var level = commandInfos.Verbose ? LogEventLevel.Debug : LogEventLevel.Information;
var loggerConf = new LoggerConfiguration()
.WriteTo.Async(conf =>
{
var path = commandInfos.LogsPath?.Exists == true ? Path.Combine(commandInfos.LogsPath.FullName, logFileName) : "logs/" + logFileName;
conf.File(path, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 31, formatProvider: CultureInfo.InvariantCulture);
conf.Console(formatProvider: CultureInfo.InvariantCulture);
}).MinimumLevel.Is(level);


var loggerConf = new LoggerConfiguration();

loggerConf.MinimumLevel.Is(level);

var sink = LoggerSinkConfiguration.Wrap(sink => new BackgroundWorkerSink(sink), conf =>
{
var path = commandInfos.LogsPath?.Exists == true ? Path.Combine(commandInfos.LogsPath.FullName, logFileName) : "logs/" + logFileName;
conf.File(path, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 31, formatProvider: CultureInfo.InvariantCulture);
conf.Console(formatProvider: CultureInfo.InvariantCulture);
});

loggerConf.WriteTo.Sink(sink);

return loggerConf.CreateLogger();
}
Expand Down
17 changes: 0 additions & 17 deletions src/SqlBackupTools/SerilogAsync/BackgroundWorkerSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Serilog;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Debugging;
using Serilog.Events;

namespace SqlBackupTools.SerilogAsync
{
public static class LoggerConfigurationAsyncExtensions
{
public static LoggerConfiguration Async(
this LoggerSinkConfiguration loggerSinkConfiguration,
Action<LoggerSinkConfiguration> configure)
{
return LoggerSinkConfiguration.Wrap(
loggerSinkConfiguration,
wrappedSink => new BackgroundWorkerSink(wrappedSink),
configure,
LevelAlias.Minimum,
null);
}
}

internal sealed class BackgroundWorkerSink : ILogEventSink, IDisposable
{
private readonly ILogEventSink _wrappedSink;
Expand Down
18 changes: 9 additions & 9 deletions src/SqlBackupTools/SqlBackupTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="MailKit" Version="3.3.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Dapper" Version="2.1.35" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
19 changes: 11 additions & 8 deletions tests/SqlBackupTools.Tests/SqlBackupTools.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.analyzers" Version="0.10.0" />
<PackageReference Include="xunit.analyzers" Version="1.14.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\SqlBackupTools\SqlBackupTools.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 79b2825

Please sign in to comment.