How do you select which build target to debug?

2.2k Views Asked by At

If I am multitargeting a project to .Net Core 3.1 and .Net Framework 4.8 and I select Debug | Start Debugging, Visual Studio 2019 starts a debugging session with the .Net Framework build target.

How can I get it to launch the .Net Core build target instead?

Here is my test project file:

<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFrameworks>net48;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

And here is the test code:

using System;

namespace Demo
{
    class Program
    {
        public static void Main(string[] args)
        {
            #if NET48
                Console.WriteLine(".Net Framework");
            #else
                Console.WriteLine(".Net Core");
            #endif
        }
    }
}

There are no other files in the project. I'm using Visual Studio 2019 version 16.7.2.

2

There are 2 best solutions below

9
TheGeneral On BEST ANSWER

Just to make it obvious, If you click the dropdown next to your start debug toolbar item, you will see your targeting options

enter image description here

Note : I am trying to find the actual documentation for this... zilch

0
Anton On

There is also a dropdown to update the preview in the editor. You can find it under tabs view. If you will change the selected value, the syntax highlight under #if #else updates

enter image description here