@echo off
setlocal enabledelayedexpansion
set TEST_NAME=ConvertPrintTest
for /f %%i in ('dotnet --version') do set ver=%%i
set net=0
if %ver:~0,2% EQU 2. set net=netcoreapp2.1
if %ver:~0,2% EQU 3. set net=netcoreapp2.1
if %ver:~0,2% EQU 5. set net=net5.0
if %ver:~0,2% EQU 6. set net=net6.0
if %ver:~0,2% EQU 7. set net=net7.0
if %ver:~0,2% EQU 8. set net=net8.0
if %ver:~0,2% EQU 9. set net=net9.0

set "textfile=%TEST_NAME%.csproj"
set "tempfile=%TEST_NAME%.csproj.txt"
(for /f "delims=" %%i in (%textfile%) do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    set "line=!line:<TargetFramework>netcoreapp2.1</TargetFramework>=<TargetFramework>%net%</TargetFramework>!"
    set "line=!line:<TargetFramework>net5.0</TargetFramework>=<TargetFramework>%net%</TargetFramework>!"
    set "line=!line:<TargetFramework>net6.0</TargetFramework>=<TargetFramework>%net%</TargetFramework>!"
    set "line=!line:<TargetFramework>net7.0</TargetFramework>=<TargetFramework>%net%</TargetFramework>!"
    set "line=!line:<TargetFramework>net8.0</TargetFramework>=<TargetFramework>%net%</TargetFramework>!"
    set "line=!line:<TargetFramework>net9.0</TargetFramework>=<TargetFramework>%net%</TargetFramework>!"
    echo(!line!
))>"%tempfile%"
del %textfile%
rename %tempfile%  %textfile%
call dotnet run
exit /b %errorlevel%
endlocal