33

I created a "Console App (.NET Core)" project in Visual Studio. Now I need to add a dependency that only works on .NET Framework 4.6+, not .NET Core.

Is there a way to convert my project to a full .NET Framework project?


Here's what I've tried:

I went to the project properties and attempted to change the project framework, but I don't see the option I need in the dropdown:

Only .NETCoreApp displays in the target framework list.

If I click "Install other frameworks..." I'm taken to a page that says .NET Framework versions are included in Visual Studio 2017 -- which is exactly what I'm using to edit this project. This is where I got stuck.

Steve Trout
  • 9,261
  • 2
  • 19
  • 30

1 Answers1

41

If you're happy with it still using the new tooling, the easiest approach is probably just to edit the project file (csproj). Right-click on the project in Solution Explorer and you should have a context menu option of "Edit <yourproject>.csproj". Click on that, and just change

<TargetFramework>netcoreapp1.1</TargetFramework>

to

<TargetFramework>net46</TargetFramework>

... and I suspect you'll be good to go. (It may confuse VS for a little while as it restores appropriate packages etc.)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Thanks! I ran into this when adding my first dependency, so luckily VS had nothing to get confused about. – Steve Trout May 04 '17 at 16:41
  • Worked here trying to connect to a ws-trust wcf service throws PlatformNotSupported exception, so back to .NET Framework platform works fine.. After configuring I had to add many and many NuGet packages tho – rfcdejong Feb 26 '18 at 16:12
  • 2
    Is there any way to do this from netcoreapp2.2 to net48? I changed the project file but get an error that package Microsoft.AspNetCore.All 2.2.6 is not compatible with net48. – mslissap Jul 29 '19 at 15:28
  • 2
    @mslissap: I believe you'll need to stop using that metapackage, and use the specific packages instead. See https://learn.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio which gives some instructions that might help you. – Jon Skeet Jul 29 '19 at 15:44
  • How can I do this but be able to use ClickOnce? –  Dec 16 '19 at 11:33
  • 1
    @Shemiroth: I don't know if ClickOnce supports .NET Core at all. https://stackoverflow.com/questions/56390876/will-clickonce-be-ported-to-net-core-3-as-well-as-winforms suggests probably not. – Jon Skeet Dec 16 '19 at 11:36
  • That's correct, which is why I am trying to convert to .net framework. When I change the target framework. It does not give me ClickOnce though. Please see here: https://stackoverflow.com/questions/59354872/using-clickonce-after-converting-from-net-core-to-net-framework –  Dec 16 '19 at 11:38
  • @Shemiroth: Ah, sorry, misread. It's possible that ClickOnce isn't supported in the SDK-style project files. – Jon Skeet Dec 16 '19 at 11:53