TargetFramework + PackageReference Wildcard Woes
18:11 10 Sep 2026

So I get it... NuGet packages are only as good as they are. And while most packages increase their version and keep older TargetFrameworks available in the release, some do not. So while I can generally have a template *.csproj like this:



  
    Exe
    net10.0
    TargetFrameworkOverride
    Company.ConsoleApplication1
    $(ProjectLanguageVersion)
    enable
    enable
    true
    
    true
    true
    
    sourceName Worker Service
    1.0.0
    1.0.0.0
    1.0.0.0
  

  
    
     
  

Sometimes adding additional necessary packages to a template will end up pulling a version that is incompatible with the TargetFramework supplied by the instantiator.

For instance if the user did a dotnet new mytemplate --Framework net8.0 and one of the packages 100% has a net8.0 compatible release, but the latest release does not include that target, the restore will fail.

My question is, is there a good way to mitigate this and future proof the template? Or is the only way to rectify this, to constantly update the template with more and more conditional $(Framework) lines related to the offending packages?

templates .net-core nuget-package-restore