Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Add-ExampleVersion.ps1
Original file line number Diff line number Diff line change
@@ -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 "<TargetFramework>.*?</TargetFramework>", "<TargetFramework>net$($targetVersion)</TargetFramework>" `
| Set-Content $_.FullName
}


# Add to .sln
if (Test-Path $newCsproj) {
dotnet sln $solutionFile add $newCsproj | Out-Null
Write-Host "Added to solution: $newName"
}
}
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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 `<ItemGroup>` sections;
1. Run tests locally to verify everything works as expected.
Loading