.NET 4.5 is an in place upgrade for .NET 4 so you still use the same MSBuild path to build your project. If you call the msbuild.exe directly, you can leverage any version of NAnt to build your project.
Given the example below, when you want to change to .NET 5 (or any other version of .NET), you simply update the property that points to msbuild.exe and the rest should work (assuming no breaking changes in the msbuild.exe arguments).
<property name="MSBuildPath" value="c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"/>
<target name="build">
<exec program="${MSBuildPath}">
<arg line='"${SolutionFile}"' />
<arg line="/property:Configuration=${SolutionConfiguration}" />
<arg value="/target:Rebuild" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
</exec>
</target>