Compile error when adding Xamarin iOS app to solution with .NET 6 NUnit test project

Bob 6 Reputation points
2022-12-01T20:33:27.143+00:00

This came up as a result of attempting to upgrade our test projects from .NET Core 3.1 to .Net 6 in our solution that includes a Xamarin iOS app. It happens on the macOS-11 build agent in azure dev ops and also on my development mac running Visual Studio for Mac version 17.4(build 2406). Is it possible to upgrade .net core 3.1 NUnit projects to .NET 6when there's a xamarin iOS project in the solution?266361-buildoutput.txt

Repro steps

  • Open visual studio for mac, click new
  • Under Web and Console in the left pane, click Tests
  • Click NUnit Test Project, click continue
  • Select .NET 6.0, click continue
  • Give the test project a project name, click create
  • Clean and Rebuild the solution, build succeeds
  • Add a new project to the solution
  • Under iOS select App, click continue
  • Give the app a name, click continue
  • On the next screen leave the defaults, click create
  • Clean solution, fails

error NETSDK1005: Assets file '/Users/robertc/Projects/TestProject/TestProject/obj/project.assets.json' doesn't have a target for '.NETFramework,Version=v6.0'. Ensure that restore has run and that you have included 'net60' in the TargetFrameworks for your project.

I'll include the sample solution and also the build output.

Developer technologies .NET Xamarin
Developer technologies Visual Studio Testing
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.