Search code examples
.netmsbuildnugetteamcity.net-6.0

How to specify runtimeIdentifier and targetFramework values when using Nuget Restore in TeamCity


I have TeamCity setup to restore a project using MSBuild, specifying the runtimeIdentifier and targetFramework values required, and everything restores smoothly.

However when I try to configure the same restore using the NuGet installer within team city, I get the following message after trying to publish:

....obj\project.assets.json' doesn't have a target for 'net6.0/win-x64'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

How and were do I specify these parameters in the NuGet Installer section of TeamCity, so that the project is restored with the correct targeting?

NuGet is restoring with MSBuild, so I'm presuming there is some way of doing this. Passing the params via the 'Command line parameters' section does not work.

enter image description here


Solution

  • You can switch to dotnet restore and pass --runtime parameter to it:

    dotnet restore -r win-x64
    

    Could not find specific docs for it but it seems that using .NET Core plugin with corresponding command should do the trick.