From 7512cf95e9c53bc995889201548ec15e762f3c30 Mon Sep 17 00:00:00 2001 From: Tohirjon-Odilov Date: Wed, 3 Apr 2024 20:11:41 +0500 Subject: [PATCH 1/7] update files --- src/BookStore.Presentation/MVC/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BookStore.Presentation/MVC/appsettings.json b/src/BookStore.Presentation/MVC/appsettings.json index ad2f083..76e6001 100644 --- a/src/BookStore.Presentation/MVC/appsettings.json +++ b/src/BookStore.Presentation/MVC/appsettings.json @@ -8,6 +8,6 @@ "AllowedHosts": "*", "ConnectionStrings": { "SQLServer": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BookStore.MVC.DB;", - "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=sardor0618!;Database=BookStoree.DB" + "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=coder;Database=BookStoree.DB" } } From adad35c38894c23a93d2f930cce4b76e2c52a634 Mon Sep 17 00:00:00 2001 From: Tohirjon <82634626+Tohirjon-Odilov@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:56:01 +0500 Subject: [PATCH 2/7] Create dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 115 +++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/dotnet-desktop.yml diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml new file mode 100644 index 0000000..e718dd9 --- /dev/null +++ b/.github/workflows/dotnet-desktop.yml @@ -0,0 +1,115 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will build, test, sign and package a WPF or Windows Forms desktop application +# built on .NET Core. +# To learn how to migrate your existing application to .NET Core, +# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework +# +# To configure this workflow: +# +# 1. Configure environment variables +# GitHub sets default environment variables for every workflow run. +# Replace the variables relative to your project in the "env" section below. +# +# 2. Signing +# Generate a signing certificate in the Windows Application +# Packaging Project or add an existing signing certificate to the project. +# Next, use PowerShell to encode the .pfx file using Base64 encoding +# by running the following Powershell script to generate the output string: +# +# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte +# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' +# +# Open the output file, SigningCertificate_Encoded.txt, and copy the +# string inside. Then, add the string to the repo as a GitHub secret +# and name it "Base64_Encoded_Pfx." +# For more information on how to configure your signing certificate for +# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing +# +# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". +# See "Build the Windows Application Packaging project" below to see how the secret is used. +# +# For more information on GitHub Actions, refer to https://github.com/features/actions +# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, +# refer to https://github.com/microsoft/github-actions-for-desktop-apps + +name: .NET Core Desktop + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + + strategy: + matrix: + configuration: [Debug, Release] + + runs-on: windows-latest # For a list of available runner types, refer to + # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on + + env: + Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. + Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. + Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. + Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Install the .NET Core workload + - name: Install .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v2 + + # Execute all unit tests in the solution + - name: Execute unit tests + run: dotnet test + + # Restore the application to populate the obj folder with RuntimeIdentifiers + - name: Restore the application + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + env: + Configuration: ${{ matrix.configuration }} + + # Decode the base 64 encoded pfx and save the Signing_Certificate + - name: Decode the pfx + run: | + $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") + $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx + [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) + + # Create the app package by building and packaging the Windows Application Packaging project + - name: Create the app package + run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} + env: + Appx_Bundle: Always + Appx_Bundle_Platforms: x86|x64 + Appx_Package_Build_Mode: StoreUpload + Configuration: ${{ matrix.configuration }} + + # Remove the pfx + - name: Remove the pfx + run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx + + # Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: MSIX Package + path: ${{ env.Wap_Project_Directory }}\AppPackages From f7f1c0c005a24e07c22b6ae94ae65221e837eaad Mon Sep 17 00:00:00 2001 From: root Date: Sat, 20 Apr 2024 12:53:35 +0000 Subject: [PATCH 3/7] fixed files for deployment --- src/BookStore.Presentation/MVC/Properties/launchSettings.json | 4 ++-- src/BookStore.Presentation/MVC/appsettings.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BookStore.Presentation/MVC/Properties/launchSettings.json b/src/BookStore.Presentation/MVC/Properties/launchSettings.json index dec2026..4c0d290 100644 --- a/src/BookStore.Presentation/MVC/Properties/launchSettings.json +++ b/src/BookStore.Presentation/MVC/Properties/launchSettings.json @@ -12,8 +12,8 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:5197", + "launchBrowser": false, + "applicationUrl": "http://localhost:5189", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/BookStore.Presentation/MVC/appsettings.json b/src/BookStore.Presentation/MVC/appsettings.json index 76e6001..ebf0cfd 100644 --- a/src/BookStore.Presentation/MVC/appsettings.json +++ b/src/BookStore.Presentation/MVC/appsettings.json @@ -8,6 +8,6 @@ "AllowedHosts": "*", "ConnectionStrings": { "SQLServer": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BookStore.MVC.DB;", - "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=coder;Database=BookStoree.DB" + "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=root;Database=BookStoree.DB" } } From 0ec0dffa0c9ae8a5616bede72806aafa04c313cd Mon Sep 17 00:00:00 2001 From: Tohirjon <82634626+Tohirjon-Odilov@users.noreply.github.com> Date: Sat, 20 Apr 2024 18:22:35 +0500 Subject: [PATCH 4/7] Update dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 114 --------------------------- 1 file changed, 114 deletions(-) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index e718dd9..8b13789 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -1,115 +1 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build, test, sign and package a WPF or Windows Forms desktop application -# built on .NET Core. -# To learn how to migrate your existing application to .NET Core, -# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework -# -# To configure this workflow: -# -# 1. Configure environment variables -# GitHub sets default environment variables for every workflow run. -# Replace the variables relative to your project in the "env" section below. -# -# 2. Signing -# Generate a signing certificate in the Windows Application -# Packaging Project or add an existing signing certificate to the project. -# Next, use PowerShell to encode the .pfx file using Base64 encoding -# by running the following Powershell script to generate the output string: -# -# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte -# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' -# -# Open the output file, SigningCertificate_Encoded.txt, and copy the -# string inside. Then, add the string to the repo as a GitHub secret -# and name it "Base64_Encoded_Pfx." -# For more information on how to configure your signing certificate for -# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing -# -# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". -# See "Build the Windows Application Packaging project" below to see how the secret is used. -# -# For more information on GitHub Actions, refer to https://github.com/features/actions -# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, -# refer to https://github.com/microsoft/github-actions-for-desktop-apps - -name: .NET Core Desktop - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - - build: - - strategy: - matrix: - configuration: [Debug, Release] - - runs-on: windows-latest # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - - env: - Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. - Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. - Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. - Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # Install the .NET Core workload - - name: Install .NET Core - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v2 - - # Execute all unit tests in the solution - - name: Execute unit tests - run: dotnet test - - # Restore the application to populate the obj folder with RuntimeIdentifiers - - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration - env: - Configuration: ${{ matrix.configuration }} - - # Decode the base 64 encoded pfx and save the Signing_Certificate - - name: Decode the pfx - run: | - $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") - $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx - [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) - - # Create the app package by building and packaging the Windows Application Packaging project - - name: Create the app package - run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} - env: - Appx_Bundle: Always - Appx_Bundle_Platforms: x86|x64 - Appx_Package_Build_Mode: StoreUpload - Configuration: ${{ matrix.configuration }} - - # Remove the pfx - - name: Remove the pfx - run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx - - # Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact - - name: Upload build artifacts - uses: actions/upload-artifact@v3 - with: - name: MSIX Package - path: ${{ env.Wap_Project_Directory }}\AppPackages From 3ba6ec50f8abc7659948efa6075b58b928261321 Mon Sep 17 00:00:00 2001 From: Tohirjon-Odilov Date: Mon, 29 Apr 2024 12:05:22 +0500 Subject: [PATCH 5/7] CODE RUB: Agar folder bo'lmasa unda folder yaratiladi --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7fdd162..04a3488 100644 --- a/.gitignore +++ b/.gitignore @@ -369,3 +369,4 @@ FodyWeavers.xsd /src/BookStore.Presentation/MVC/wwwroot/BookPhoto /src/BookStore.Presentation/MVC/wwwroot/Books /src/BookStore.Presentation/MVC/wwwroot/UserProfileImage +/ConsoleApp1 From b854b693f6e296880f846beb6b708021c2506639 Mon Sep 17 00:00:00 2001 From: Tohirjon-Odilov Date: Mon, 29 Apr 2024 12:06:15 +0500 Subject: [PATCH 6/7] CODE RUB: created file fixed --- BookStore.sln | 17 +++++++++---- .../Commands/CreateAuthorCommandHandler.cs | 21 ++++++++++++---- .../Commands/CreateBookCommandHandler.cs | 24 +++++++++++++++++++ src/BookStore.Presentation/MVC/MVC.csproj | 6 ----- .../MVC/appsettings.json | 2 +- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/BookStore.sln b/BookStore.sln index 181901e..fcb4ecc 100644 --- a/BookStore.sln +++ b/BookStore.sln @@ -5,17 +5,19 @@ VisualStudioVersion = 17.8.34316.72 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E63592A0-27C4-4444-BD76-903F182458F1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Domain", "src\BookStore.Domain\BookStore.Domain.csproj", "{6E8888F1-9B76-421E-ACEF-A499B3D04927}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore.Domain", "src\BookStore.Domain\BookStore.Domain.csproj", "{6E8888F1-9B76-421E-ACEF-A499B3D04927}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Application", "src\BookStore.Application\BookStore.Application.csproj", "{D22C7023-F7E3-468C-AEA1-37B97C680D15}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore.Application", "src\BookStore.Application\BookStore.Application.csproj", "{D22C7023-F7E3-468C-AEA1-37B97C680D15}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Infrastructure", "src\BookStore.Infrastructure\BookStore.Infrastructure.csproj", "{B6A4EF17-870B-4BF7-AAAE-FDC55E5831ED}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore.Infrastructure", "src\BookStore.Infrastructure\BookStore.Infrastructure.csproj", "{B6A4EF17-870B-4BF7-AAAE-FDC55E5831ED}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BookStore.Presentation", "BookStore.Presentation", "{3F32713F-015A-4919-93CA-E1A5B34B4863}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "src\BookStore.Presentation\API\API.csproj", "{A71B8C92-ACA9-40D5-B277-E4CA6D2E195D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "src\BookStore.Presentation\API\API.csproj", "{A71B8C92-ACA9-40D5-B277-E4CA6D2E195D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVC", "src\BookStore.Presentation\MVC\MVC.csproj", "{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVC", "src\BookStore.Presentation\MVC\MVC.csproj", "{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{216E730C-ACC0-4053-A332-713E53440962}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -43,6 +45,10 @@ Global {34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}.Debug|Any CPU.Build.0 = Debug|Any CPU {34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}.Release|Any CPU.ActiveCfg = Release|Any CPU {34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}.Release|Any CPU.Build.0 = Release|Any CPU + {216E730C-ACC0-4053-A332-713E53440962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {216E730C-ACC0-4053-A332-713E53440962}.Debug|Any CPU.Build.0 = Debug|Any CPU + {216E730C-ACC0-4053-A332-713E53440962}.Release|Any CPU.ActiveCfg = Release|Any CPU + {216E730C-ACC0-4053-A332-713E53440962}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -54,6 +60,7 @@ Global {3F32713F-015A-4919-93CA-E1A5B34B4863} = {E63592A0-27C4-4444-BD76-903F182458F1} {A71B8C92-ACA9-40D5-B277-E4CA6D2E195D} = {3F32713F-015A-4919-93CA-E1A5B34B4863} {34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9} = {3F32713F-015A-4919-93CA-E1A5B34B4863} + {216E730C-ACC0-4053-A332-713E53440962} = {E63592A0-27C4-4444-BD76-903F182458F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8C5D27F3-0D32-4A29-AE50-8C54EE56B386} diff --git a/src/BookStore.Application/useCases/Authors/Commands/CreateAuthorCommandHandler.cs b/src/BookStore.Application/useCases/Authors/Commands/CreateAuthorCommandHandler.cs index 1065a86..91650b3 100644 --- a/src/BookStore.Application/useCases/Authors/Commands/CreateAuthorCommandHandler.cs +++ b/src/BookStore.Application/useCases/Authors/Commands/CreateAuthorCommandHandler.cs @@ -3,6 +3,7 @@ using Mapster; using MediatR; using Microsoft.AspNetCore.Hosting; +using System.IO; namespace BookStore.Application.useCases.Authors.Commands { @@ -24,18 +25,30 @@ public async Task Handle(CreateAuthorCommand command, CancellationToken string fileName = ""; try { + var newFilePath = ""; fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); filePath = Path.Combine(_webHostEnvironment.WebRootPath, "AuthorsProfileImage", fileName); - using (var stream = new FileStream(filePath, FileMode.Create)) + + if (!Directory.Exists(newFilePath)) { - await file.CopyToAsync(stream); + for (int i = 0; i < filePath.Split("\\").Length; i++) + { + if (i + 1 != filePath.Split("\\").Length) + newFilePath += filePath.Split("\\")[i] + "\\"; + } + + Directory.CreateDirectory(newFilePath); } - } - catch (Exception ex) + + using (var stream = new FileStream(filePath, FileMode.Create)) + await file.CopyToAsync(stream); + + } catch (Exception ex) { await Console.Out.WriteLineAsync($"Error: {ex.Message}"); } + var author = command.Adapt(); author.PhotoPath = "/AuthorsProfileImage/" + fileName; var res = await _context.Authors.AddAsync(author); diff --git a/src/BookStore.Application/useCases/Books/Commands/CreateBookCommandHandler.cs b/src/BookStore.Application/useCases/Books/Commands/CreateBookCommandHandler.cs index 47ea84f..740a7ea 100644 --- a/src/BookStore.Application/useCases/Books/Commands/CreateBookCommandHandler.cs +++ b/src/BookStore.Application/useCases/Books/Commands/CreateBookCommandHandler.cs @@ -38,12 +38,36 @@ public async Task Handle(CreateBookCommand request, CancellationToken canc try { + var newFilePath = ""; + fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); filePath = Path.Combine(_webHostEnvironment.WebRootPath, "Books", fileName); PhotofileName = Guid.NewGuid().ToString() + Path.GetExtension(PhotoFile.FileName); PhotofilePath = Path.Combine(_webHostEnvironment.WebRootPath, "BookPhoto", PhotofileName); + if (!Directory.Exists(filePath)) + { + for (int i = 0; i < filePath.Split("\\").Length; i++) + { + if (i + 1 != filePath.Split("\\").Length) + newFilePath += filePath.Split("\\")[i] + "\\"; + } + + Directory.CreateDirectory(newFilePath); + } + + if (!Directory.Exists(PhotofilePath)) + { + newFilePath = ""; + for (int i = 0; i < PhotofilePath.Split("\\").Length; i++) + { + if (i + 1 != PhotofilePath.Split("\\").Length) + newFilePath += PhotofilePath.Split("\\")[i] + "\\"; + } + + Directory.CreateDirectory(newFilePath); + } using (var stream = new FileStream(filePath, FileMode.Create)) { diff --git a/src/BookStore.Presentation/MVC/MVC.csproj b/src/BookStore.Presentation/MVC/MVC.csproj index d1a012c..f1d1999 100644 --- a/src/BookStore.Presentation/MVC/MVC.csproj +++ b/src/BookStore.Presentation/MVC/MVC.csproj @@ -20,10 +20,4 @@ - - - - - - diff --git a/src/BookStore.Presentation/MVC/appsettings.json b/src/BookStore.Presentation/MVC/appsettings.json index c2aa385..0b4cab0 100644 --- a/src/BookStore.Presentation/MVC/appsettings.json +++ b/src/BookStore.Presentation/MVC/appsettings.json @@ -9,7 +9,7 @@ "BotToken": "7040566448:AAGuJLoJsg8xqAAW4yWGPkZDR6PIxBlU0ns", "ConnectionStrings": { "SQLServer": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BookStore.MVC.DB;", - "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=sardor0618!;Database=BookStoree.DB" + "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=coder;Database=BookStore.Db" }, "Serilog": { "Using": [ "Serilog.Sinks.File" ], From 7c3717ddb71ef88760ec9830576f2d40e8db8627 Mon Sep 17 00:00:00 2001 From: Tohirjon-Odilov Date: Mon, 29 Apr 2024 12:17:49 +0500 Subject: [PATCH 7/7] INFRA: Initalize Build Project --- .github/workflows/dotnet.yml | 25 ++++++ BookStore.sln | 9 +- .../BookStore.Infrastructure.Build.csproj | 14 ++++ src/BookStore.Infrastructure.Build/Program.cs | 84 +++++++++++++++++++ 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dotnet.yml create mode 100644 src/BookStore.Infrastructure.Build/BookStore.Infrastructure.Build.csproj create mode 100644 src/BookStore.Infrastructure.Build/Program.cs diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..b4bea3b --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,25 @@ +name: BookStore Build Pipline +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build: + runs-on: windows-2022 + steps: + - name: Check out + uses: actions/checkout@v2 + - name: Setup .Net + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.204 + include-prerelease: true + - name: Restore + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/BookStore.sln b/BookStore.sln index fcb4ecc..50eb531 100644 --- a/BookStore.sln +++ b/BookStore.sln @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "src\BookStore.Presen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVC", "src\BookStore.Presentation\MVC\MVC.csproj", "{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{216E730C-ACC0-4053-A332-713E53440962}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{216E730C-ACC0-4053-A332-713E53440962}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Infrastructure.Build", "src\BookStore.Infrastructure.Build\BookStore.Infrastructure.Build.csproj", "{785D78EE-F055-46F3-A7DD-6F8F488DDF1E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -49,6 +51,10 @@ Global {216E730C-ACC0-4053-A332-713E53440962}.Debug|Any CPU.Build.0 = Debug|Any CPU {216E730C-ACC0-4053-A332-713E53440962}.Release|Any CPU.ActiveCfg = Release|Any CPU {216E730C-ACC0-4053-A332-713E53440962}.Release|Any CPU.Build.0 = Release|Any CPU + {785D78EE-F055-46F3-A7DD-6F8F488DDF1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {785D78EE-F055-46F3-A7DD-6F8F488DDF1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {785D78EE-F055-46F3-A7DD-6F8F488DDF1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {785D78EE-F055-46F3-A7DD-6F8F488DDF1E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -61,6 +67,7 @@ Global {A71B8C92-ACA9-40D5-B277-E4CA6D2E195D} = {3F32713F-015A-4919-93CA-E1A5B34B4863} {34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9} = {3F32713F-015A-4919-93CA-E1A5B34B4863} {216E730C-ACC0-4053-A332-713E53440962} = {E63592A0-27C4-4444-BD76-903F182458F1} + {785D78EE-F055-46F3-A7DD-6F8F488DDF1E} = {E63592A0-27C4-4444-BD76-903F182458F1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8C5D27F3-0D32-4A29-AE50-8C54EE56B386} diff --git a/src/BookStore.Infrastructure.Build/BookStore.Infrastructure.Build.csproj b/src/BookStore.Infrastructure.Build/BookStore.Infrastructure.Build.csproj new file mode 100644 index 0000000..9ef96f3 --- /dev/null +++ b/src/BookStore.Infrastructure.Build/BookStore.Infrastructure.Build.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/src/BookStore.Infrastructure.Build/Program.cs b/src/BookStore.Infrastructure.Build/Program.cs new file mode 100644 index 0000000..1456f1d --- /dev/null +++ b/src/BookStore.Infrastructure.Build/Program.cs @@ -0,0 +1,84 @@ +using ADotNet.Clients; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV1s; + +var githubPipline = new GithubPipeline +{ + Name = "BookStore Build Pipline", + OnEvents = new Events + { + PullRequest = new PullRequestEvent + { + Branches = new string[] { "main" } + }, + + Push = new PushEvent + { + Branches = new string[] { "main" } + }, + + }, + + Jobs = new Dictionary + { + { + "build", + new Job + { + RunsOn = BuildMachines.Windows2022, + + Steps = new List + { + new CheckoutTaskV2 + { + Name = "Check out" + }, + + new SetupDotNetTaskV1 + { + Name = "Setup .Net", + + TargetDotNetVersion = new TargetDotNetVersion + { + DotNetVersion = "8.0.204", + IncludePrerelease = true + } + }, + + new RestoreTask + { + Name = "Restore" + }, + + new DotNetBuildTask + { + Name = "Build" + }, + + new TestTask + { + Name = "Test" + } + } + } + } + } +}; + +var client = new ADotNetClient(); + + +string buildScriptPath = "../../../../../.github/workflows/dotnet.yml"; +string directoryPath = Path.GetDirectoryName(buildScriptPath)!; + +if (!Directory.Exists(directoryPath)) +{ + Directory.CreateDirectory(directoryPath); +} + +client.SerializeAndWriteToFile +( + adoPipeline: githubPipline, + path: buildScriptPath +); \ No newline at end of file