diff --git a/Add-ExampleVersion.ps1 b/Add-ExampleVersion.ps1 new file mode 100644 index 0000000..f46086f --- /dev/null +++ b/Add-ExampleVersion.ps1 @@ -0,0 +1,54 @@ +param ( + [string]$sourceVersion = "6.0", + [string]$targetVersion = "9.0", + [string]$solutionFile = "AspNetCore.JwtAuthentication.sln" +) + +$examplesPath = "Examples" +$prefix = "Example.Net" +$sourceProjects = Get-ChildItem -Directory "$examplesPath\$($prefix)$sourceVersion.*" + +Write-Host "source version: $sourceVersion" +Write-Host "target version: $targetVersion" + +foreach ($src in $sourceProjects) { + $name = $src.Name + $newName = $name -replace "Net$sourceVersion", "Net$targetVersion" + $destPath = Join-Path $examplesPath $newName + + if (Test-Path $destPath) { + Write-Host "Skipping existing: $newName" + continue + } + + $srcPath = Join-Path $examplesPath $name + + # Copying (with no bin/obj/.vs) + robocopy $srcPath $destPath /E /XD bin obj .vs | Out-Null + Write-Host "Copied: $name → $newName" + + # Rename .csproj file + $oldCsproj = Join-Path $destPath "$name.csproj" + $newCsproj = Join-Path $destPath "$newName.csproj" + if (Test-Path $oldCsproj) { + Rename-Item -Path $oldCsproj -NewName "$newName.csproj" + } + + # Renew .cs & .csproj files + Get-ChildItem -Recurse -Path $destPath -Include *.cs,*.csproj | ForEach-Object { + (Get-Content $_.FullName -Raw) ` + -replace "Net$($sourceVersion.Split('.')[0])", "Net$($targetVersion.Split('.')[0])" ` + -replace "$([Regex]::Escape($sourceVersion))", $targetVersion ` + -replace "net$($sourceVersion.Split('.')[0])", "net$($targetVersion.Split('.')[0])" ` + -replace "net$($sourceVersion.Replace('.', ''))", "net$($targetVersion.Replace('.', ''))" ` + -replace ".*?", "net$($targetVersion)" ` + | Set-Content $_.FullName + } + + + # Add to .sln + if (Test-Path $newCsproj) { + dotnet sln $solutionFile add $newCsproj | Out-Null + Write-Host "Added to solution: $newName" + } +} diff --git a/README.md b/README.md index ef03e45..7b7e70a 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,24 @@ The libraries can be used for all projects based on .NET Core 3.0 - .NET 9.0. Basic JWT-based authentication implementation. ## [JwtAuthentication.Identity](https://github.com/TourmalineCore/TourmalineCore.AspNetCore.JwtAuthentication/tree/master/JwtAuthentication.Identity) -JWT-based authentication implemented with usage of EF Core and Identity to store users data. Features Refresh tokens, Registration and Logout functionality. \ No newline at end of file +JWT-based authentication implemented with usage of EF Core and Identity to store user's data. Features Refresh tokens, Registration and Logout functionality. + +## How to Add Support for a New .NET Version +In the root folder of the project, there is a PowerShell script named `Add-ExampleVersion.ps1`. It is designed to automate the creation of new example and test projects for a specific .NET version by copying existing ones. + + +The script requires two parameters: `sourceVersion` and `targetVersion`. +- `sourceVersion` — the version to copy projects from +- `targetVersion` — the new version to create projects for + +Example of calling the script: +```powershell +.\Add-ExampleVersion.ps1 -sourceVersion 7.0 -targetVersion 10.0 +``` + +### Steps to update: +1. Run the script as shown above; +1. In each `.csproj` (`Core` and `Identity`) file, update the `TargetFrameworks` element to include the new version; +1. Update the `Version` field if needed; +1. Review and update NuGet package dependencies in `` sections; +1. Run tests locally to verify everything works as expected. \ No newline at end of file