5

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.

Matthew Watson
  • 104,400
  • 10
  • 158
  • 276

2 Answers2

11

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

TheGeneral
  • 79,002
  • 9
  • 103
  • 141
  • Unfortunately, I seem to have a customised toolbar without that option. I'm trying to add it to my toolbar - I've tried adding (from the Debug category) "Start Debug Target" and "Start / Continue" but neither of those have the dropdown. Do you happen to know the name of the command I need to add? – Matthew Watson Sep 08 '20 at 09:37
  • @MatthewWatson is should be just in the toolbar called `Standard`, arg trying to find the documentation on this thing is impossible – TheGeneral Sep 08 '20 at 09:42
  • 1
    OK I found "Debug Target" on the Standard toolbar. Now I just need to work out how to add that to the customised toolbar (which was customised nearly two years ago...) – Matthew Watson Sep 08 '20 at 09:45
  • @MatthewWatson yeah that's the part I was struggling with – TheGeneral Sep 08 '20 at 09:48
  • It looks like Microsoft forgot to make it so you can add that item to a custom toolbar. Meh. – Matthew Watson Sep 08 '20 at 09:51
  • 1
    @MatthewWatson i could add a new menu item to the drop on the debug item (strange) but i couldn't add the debug target dropdown. if you get a a solution post an answer, i am sure it would useful for a lot of people – TheGeneral Sep 08 '20 at 09:57
  • Yes, this is beginning to annoy me now. :) – Matthew Watson Sep 08 '20 at 10:07
  • I think you've answered my question - The question of how to add that command to a custom toolbar is a different one, so I'll ask a different question for that. – Matthew Watson Sep 08 '20 at 10:41
1

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

Anton
  • 136
  • 1
  • 7