2

I would like to write some console apps using C# 11. I know that it can be only with .NET 7x. If I write

<TargetFramework>netcoreapp7</TargetFramework>

in my .csproj file, I will get NETSDK1045 instead of running. But "file" (type modifier) is useful.

  • 1
    im pretty sure Visual Studio doesnt even support .net 6. If you look [here](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) you can see which version of visual studio supports the language/framework – Roe Nov 15 '22 at 09:07
  • If it does not support it, what IDE could you reccomend? –  Nov 15 '22 at 09:12
  • 1
    Visual Studio 2022 17.4 supports .NET 7, C# 11 and all .NET and C# versions before those. What's wrong with updating? – Orion Nov 15 '22 at 09:24
  • 3
    And also, please use the correct TFM, which is `net7.0`. Here is a list of the monikers: https://learn.microsoft.com/en-us/dotnet/standard/frameworks – Sébastien Sevrin Nov 15 '22 at 09:26
  • 1
    You should choose visual studio 2022. NET 7.0 support under visual studio version 2022 17.4 . – Lei Zhang-MSFT Nov 16 '22 at 08:37
  • As the answer below and related documentation say, what you need is to upgrade to VS 2022 17.4.1. If you find the solution, you should click '✔' to mark it as an answer to change its status to Answered. It will also help others to solve a similar issue. See also [stackoverflow.com/help/why-vote](https://stackoverflow.com/help/why-vote) – Jiale Xue - MSFT Nov 24 '22 at 08:41

2 Answers2

0

There's no inherent downside to upgrading your Visual Studio (as long as your tools are compatible). Within it you can still develop for older versions.

As mentioned by rbdeenk, you have to upgrade Visual Studio as per this link: https://dotnet.microsoft.com/en-us/download/dotnet/7.0

CthenB
  • 800
  • 6
  • 17
0

As written in the .NET 7 release notes for .NET 7 support in Visual Studio you need to install 17.4+ version:

You need Visual Studio 17.4 latest preview to use .NET 7.0 on Windows. On macOS, you need the latest version of Visual Studio for Mac. The C# extension for Visual Studio Code supports .NET 7.0 and C# 11.

You can try using 2019 version but some features even for .NET 6 (see this answer) will not work correctly (note that building and running from command line via dotnet ... still should work correctly if appropriate SDK is installed).

So in short - install the latest VS 2022.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132