From 6cdb4572f8f97b7142d779b5bd05ae37908550d3 Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Sun, 2 Feb 2025 10:07:57 +0100 Subject: [PATCH] Update to NET 8 and use GitHub actions --- .github/workflows/cli-release.yml | 30 +++++ .github/workflows/dotnet.yml | 56 +++++++++ .github/workflows/vsix.yml | 108 ++++++++++++++++++ src/SQLQueryStress/DatabaseSelect.cs | 5 +- src/SQLQueryStress/GlobalSuppressions.cs | 9 ++ src/SQLQueryStress/Program.cs | 3 +- src/SQLQueryStress/Properties/AssemblyInfo.cs | 4 +- src/SQLQueryStress/SQLQueryStress.csproj | 3 +- src/SqlQueryStressCLI/AssemblyInfo.cs | 2 +- src/SqlQueryStressCLI/sqlstresscmd.csproj | 2 +- 10 files changed, 212 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/cli-release.yml create mode 100644 .github/workflows/dotnet.yml create mode 100644 .github/workflows/vsix.yml create mode 100644 src/SQLQueryStress/GlobalSuppressions.cs diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml new file mode 100644 index 0000000..a47cfad --- /dev/null +++ b/.github/workflows/cli-release.yml @@ -0,0 +1,30 @@ +name: CLI Tool Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Build version (xxx)' + required: true + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.100' + + - name: Package CLI 8 + run: dotnet pack src\Core\efcpt.8\efcpt.8.csproj -p:PackageVersion=8.1.${{ github.event.inputs.version }} -p:InformationalVersion=8.1.${{ github.event.inputs.version }} + + - name: Package CLI 9 + run: dotnet pack src\Core\efcpt.9\efcpt.9.csproj -p:PackageVersion=9.1.${{ github.event.inputs.version }} -p:InformationalVersion=9.1.${{ github.event.inputs.version }} + + - name: Publish NuGet + if: startsWith(github.ref, 'refs/heads/master') + run: dotnet nuget push **\*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{ secrets.NUGET }} --skip-duplicate + \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..29aac9b --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,56 @@ +name: .NET + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Update Version + run: | + ((Get-Content -Path .\src\SqlQueryStressCLI\AssemblyInfo.cs -Raw) -Replace "1.0.0.0", "0.9.8.${{ github.run_number }}") | Set-Content -Path .\src\SqlQueryStressCLI\AssemblyInfo.cs + ((Get-Content -Path .\src\SQLQueryStress\Properties\AssemblyInfo.cs -Raw) -Replace "1.0.0.0", "0.9.8.${{ github.run_number }}") | Set-Content -Path .\src\SqlQueryStressCLI\AssemblyInfo.cs + shell: pwsh + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore --configuration Release + + - name: dotnet publish + run: dotnet publish ./src/SQLQueryStress/SqlQueryStress.csproj --configuration Release --output .\src\SQLQueryStress\bin\Publish\net8.0-windows\ --self-contained true + + - name: zip app + run: 7z a SqlQueryStress-0.9.8.${{ env.VERSION }}.zip .\src\SQLQueryStress\bin\Publish\net8.0-windows\*.exe + + - name: Publish artifacts + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: | + *.zip + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + path: | + **\\*.nupkg + + # - name: Publish NuGet + # if: startsWith(github.ref, 'refs/heads/master') && github.repository_owner == 'ErikEJ' + # run: dotnet nuget push **\*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{ secrets.NUGET }} --skip-duplicate + \ No newline at end of file diff --git a/.github/workflows/vsix.yml b/.github/workflows/vsix.yml new file mode 100644 index 0000000..c153121 --- /dev/null +++ b/.github/workflows/vsix.yml @@ -0,0 +1,108 @@ +name: VSIX + +on: + workflow_dispatch: + push: + paths-ignore: + - '**/*' + - '!.github/workflows/vsix.yml' + - '!src/GUI/**/*' + - '!src/Core/**/*' + branches: + - 'master' + pull_request: + branches: + - '*' + +env: + VERSION: 2.6.${{ github.run_number }} + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.100' + + - name: Update Version + run: | + ((Get-Content -Path GUI/EFCorePowerTools/Properties/AssemblyInfo.cs -Raw) -Replace "2.6.0.1", "${{ env.VERSION }}") | Set-Content -Path GUI/EFCorePowerTools/Properties/AssemblyInfo.cs + ((Get-Content -Path GUI/EFCorePowerTools/source.extension.vsixmanifest -Raw) -Replace "2.6.0", "${{ env.VERSION }}") | Set-Content -Path GUI/EFCorePowerTools/source.extension.vsixmanifest + ((Get-Content -Path GUI/PowerToolsExtensionPack/source.extension.vsixmanifest -Raw) -Replace "2.6.0", "${{ env.VERSION }}") | Set-Content -Path GUI/PowerToolsExtensionPack/source.extension.vsixmanifest + working-directory: src + shell: pwsh + + - name: Restore + run: dotnet restore EFCorePowerTools.sln + working-directory: src + + - name: Build reveng tools + if: github.event_name != 'pull_request' + shell: cmd + run: | + cd ${{ github.workspace}}\src\Core\efreveng80 + call ${{ github.workspace}}\src\Core\efreveng80\BuildCmdlineTool.cmd + cd ${{ github.workspace}}\src\Core\efreveng90 + call ${{ github.workspace}}\src\Core\efreveng90\BuildCmdlineTool.cmd + cd ${{ github.workspace}} + + - name: Extract and verify efreveng80.exe.zip file count + if: github.event_name != 'pull_request' + shell: cmd + run: | + mkdir vsix + 7z x src/GUI/lib/efreveng80.exe.zip -oefreveng80 -y + dir /a:-d /s /b "efreveng80" | find /c ":\" > filecount.txt + findstr "168" filecount.txt + + - name: Extract and verify efreveng90.exe.zip file count + if: github.event_name != 'pull_request' + shell: cmd + run: | + mkdir vsix + 7z x src/GUI/lib/efreveng90.exe.zip -oefreveng90 -y + dir /a:-d /s /b "efreveng90" | find /c ":\" > filecount.txt + findstr "167" filecount.txt + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v2 + + - name: Build + run: msbuild EFCorePowerTools.sln /property:Configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m + working-directory: src + + - name: Extract and verify vsix file count + shell: cmd + run: | + mkdir vsix + 7z x src/GUI/EFCorePowerTools/bin/Release/EFCorePowerTools.vsix -ovsix -y + dir /a:-d /s /b "vsix" | find /c ":\" > filecount.txt + findstr "77" filecount.txt + + - name: Move build output + if: github.ref == 'refs/heads/master' && github.repository_owner == 'erikej' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + run: | + mv src/GUI/EFCorePowerTools/bin/Release/EFCorePowerTools.vsix EFCorePowerTools-${{ env.VERSION }}.vsix + mv src/GUI/PowerToolsExtensionPack/bin/Release/PowerToolsExtensionPack.vsix PowerToolsExtensionPack-${{ env.VERSION }}.vsix + + - name: Publish artifacts + if: github.ref == 'refs/heads/master' && github.repository_owner == 'erikej' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: | + *.vsix + + - name: Publish to Open VSIX Gallery + if: github.ref == 'refs/heads/master' && github.repository_owner == 'erikej' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + run: | + $ErrorActionPreference='Stop' + (new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex + Vsix-PublishToGallery + shell: pwsh + continue-on-error: false diff --git a/src/SQLQueryStress/DatabaseSelect.cs b/src/SQLQueryStress/DatabaseSelect.cs index 219a1ab..b318301 100644 --- a/src/SQLQueryStress/DatabaseSelect.cs +++ b/src/SQLQueryStress/DatabaseSelect.cs @@ -410,14 +410,13 @@ private void appintent_check_CheckedChanged(object sender, EventArgs e) { appintent_combo.Enabled = appintent_check.Checked; - appintent_combo.DataSource = Enum.GetValues(typeof(ApplicationIntent)); + appintent_combo.DataSource = Enum.GetValues(); } private void pm_appintent_check_CheckedChanged(object sender, EventArgs e) { pm_appintent_combo.Enabled = pm_appintent_check.Checked; - pm_appintent_combo.DataSource = Enum.GetValues(typeof(ApplicationIntent)); - } + pm_appintent_combo.DataSource = Enum.GetValues(); } } } diff --git a/src/SQLQueryStress/GlobalSuppressions.cs b/src/SQLQueryStress/GlobalSuppressions.cs new file mode 100644 index 0000000..e9f7c65 --- /dev/null +++ b/src/SQLQueryStress/GlobalSuppressions.cs @@ -0,0 +1,9 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only")] +[assembly: SuppressMessage("Maintainability", "CA1515:Consider making public types internal", Justification = "Console app")] diff --git a/src/SQLQueryStress/Program.cs b/src/SQLQueryStress/Program.cs index 17248da..1e20a40 100644 --- a/src/SQLQueryStress/Program.cs +++ b/src/SQLQueryStress/Program.cs @@ -3,7 +3,6 @@ using SQLQueryStress.Properties; using System; using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Windows.Forms; @@ -80,7 +79,7 @@ private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) return null; } var assemblyData = new byte[stream.Length]; - stream.Read(assemblyData, 0, assemblyData.Length); + stream.ReadExactly(assemblyData); return Assembly.Load(assemblyData); } } diff --git a/src/SQLQueryStress/Properties/AssemblyInfo.cs b/src/SQLQueryStress/Properties/AssemblyInfo.cs index c52abab..453f4cb 100644 --- a/src/SQLQueryStress/Properties/AssemblyInfo.cs +++ b/src/SQLQueryStress/Properties/AssemblyInfo.cs @@ -37,5 +37,5 @@ // Revision // -[assembly: AssemblyVersion("0.9.7.0")] -[assembly: AssemblyFileVersion("0.9.7.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/SQLQueryStress/SQLQueryStress.csproj b/src/SQLQueryStress/SQLQueryStress.csproj index fa465e4..7b3f719 100644 --- a/src/SQLQueryStress/SQLQueryStress.csproj +++ b/src/SQLQueryStress/SQLQueryStress.csproj @@ -1,6 +1,7 @@  - net6.0-windows + net8.0-windows + windows WinExe true true diff --git a/src/SqlQueryStressCLI/AssemblyInfo.cs b/src/SqlQueryStressCLI/AssemblyInfo.cs index 8c889ef..8b84fa7 100644 --- a/src/SqlQueryStressCLI/AssemblyInfo.cs +++ b/src/SqlQueryStressCLI/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: ComVisible(false)] [assembly: Guid("e4c26a22-8376-4ff3-aa7f-878ebd9f34b3")] -[assembly: AssemblyVersion("0.9.14.0")] +[assembly: AssemblyVersion("1.0.0.0")] diff --git a/src/SqlQueryStressCLI/sqlstresscmd.csproj b/src/SqlQueryStressCLI/sqlstresscmd.csproj index fc4574e..deb5205 100644 --- a/src/SqlQueryStressCLI/sqlstresscmd.csproj +++ b/src/SqlQueryStressCLI/sqlstresscmd.csproj @@ -7,7 +7,7 @@ readme.md 0.9.20 Update M.D.S. - net6.0 + net8.0 false false false