ASP.Net Core
- Downloads
- Documentation (mostly docs.microsoft.com):
Asp.Net 5/MVC6 (pre-release) | Pre 2016 | The command line tools were k (hence "Kestrel") and then dnx, before becoming "dotnet". |
.Net Core 1.0 | released June 2016 | originally in Visual Studio 2015. Support ended in 2019. |
.Net Core 1.1 | released November 2016 | Support ended in 2019. |
.Net Core 2.0 | released August 2017 | Implemented .NetStandard 2.0 and lots more APIs. Project files changed from project.json/ .xproj to an updated .csproj xml formt. Support has ended (in October 2018) |
.Net Core 2.1 | released May 2018 | Added Span<T> |
.Net Core 3.0/3.1 | released 2019 | Supports more APIs including winforms. Support ends December 2022 |
net 5 | released 2020 | Drops "core" from name; there was no v4. C# 9 (record types, init setters). Supports ends 2022 |
net 6 | released 2021 | C# 10 (global usings, file-scoped namespace), minimal apis. breaking changes |
net 7 | released 2022 | C# 11 (what's new). |
net 8 | released 2023 | C# 12 (what's new). |
Source code
- DotNet Core Repo includes
dotnet tooling/SDK
The 2016/VS2015 tooling was preview; it is only RTM with VS2017.
- View the current runtime version with "dotnet --version"; SDK tooling version can be seen in "dotnet"
- there can be multiple runtimes and sdks installed- see %PROGRAMFILES%\dotnet\
- dotnet --list-runtimes runtimes: %PROGRAMFILES%\dotnet\shared\Microsoft.NETCore.App\
- dotnet --list-sdks tooling: %PROGRAMFILES%\dotnet\sdk
- Downloads - LongTermSupport + "Current" (latest)
- .NET Core Runtime and SDK download archive
- Notes on the obsolete VS2015 project.json format
Project-specific tooling: global.json
- The tooling/sdk version can be specified in the solution file global.json (as from VS2017, the "projects" is obsolete).
- The runtime is specified in the csproj (TargetFramework)
- If you don't set this, the latest installed version of the sdk is used. This may break older projects (eg VS2015 projects after you installed VS2017)
- Since net 3 you can use allowPrerelease (true/false), rollForward: (latestMajor, latestMinor ...) to allow later versions
- docs
- Older version (pre 3) had a projects section, which no longer exists
"sdk": {
"version": "3.1.102",
"rollForward": "latestMinor"
}
}
Project types
Projects have a <TargetFramework> (in full framework we had <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>).
NB: for multi-targeting, it's plural <TargetFrameworks> with a semicolon delimiter.
- Executables (consoles and web, with a static void Main) need a runtime - <TargetFramework>netcoreapp1.0</TargetFramework>
- NB: ASP.net Core web projects have a Program.cs
- Class libraries only need an API - <TargetFramework>netstandard1.4</TargetFramework>
- VS2017 Add new project has ".NET Core"/"Class Library (.NET Core)" (netcoreapp1.0)
AND ".NET Standard"/"Class Library (.NET Standard)" (netstandard1.4) - VS2019/VS2022 Add new project has "class library that targets Net Standard or Net Core"; in the wizard after naming the project, select the target from the dropdown as NetStandard, Core 3.1 or net5/net6
- VS2017 Add new project has ".NET Core"/"Class Library (.NET Core)" (netcoreapp1.0)
Netstandard class libraries can be called by "classic" framework .net as well as Core.
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
</Project>
Core class libraries can only be called from Core projects, not full framework.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>
For Asp.net Core websites the sdk for web is Microsoft.NET.Sdk.Web; otherwise it's Microsoft.NET.Sdk
.net core 2 could run on framework (TargetFramework net461 with RuntimeIdentifier of win7-x86) but since core 3 this is no longer possible.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>
A console app just has an OutputType of "Exe"
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
</Project>
Multi-targeting
Frameworks run .net code, and there can be several in the same project (multi-targeting). Note TargetFrameworks is plural!
<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;net451</TargetFrameworks>
</PropertyGroup>
</Project>
For references/packages add them with msbuild conditionals.
<PackageReference Include="System.Data.Common" Version="4.1.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.0.11" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
The framework moniker (.net 4.6 is "net46") is the same label used in Nuget packages. It's also available (uppercased to NET46) as a conditional compilation symbol when you build.
Framework | Versions | Framework (TFM) | Dependency (MetaPackage) |
---|---|---|---|
Full framework | 4.8 | net48 | N/A (installation) |
NetStandard (API) | 1.6 | netstandard1.6 | NETStandard.Library 1.6.0 |
.Net Core (June 2016) | 1.0 | netcoreapp1.0 | Microsoft.NETCore.App 1.0.0 |
.Net Core (Nov 2016) | 1.1 | netcoreapp1.1 | Microsoft.NETCore.App 1.1.0 |
.Net Core (Aug 2017) | 2.0-3.1 | netcoreapp2.0 netcoreapp3.1 |
No longer required |
.Net Standard
.Net Core (1-2) can run on .Net full framework, or by itself. .Net Standard is a common API (in programming terms, an interface). Netstandard class libraries are binary compatible across the framework, core, Xamarin, UWP etc.
Each netstandard is a superset of the previous. Core 1.0 supports all netstandards from netstandard1.0 (net45) to netstandard1.6 (net461).
With .Net Core 3.0, there is no longer any support for the full framework.
Netstandard 2.1 is the highest (final) version; net5 and net6 are newer versions which are not compatible with .net framework (although netstandard can still be referenced).
.Net Standard | .Net Framework | .Net Core |
---|---|---|
netstandard1.6 | net 4.6.1 (net461) | Core 1.0 (netcoreapp1.0) |
netstandard2.0 | net 4.6.1 (net461) | Core 2.0 (netcoreapp2.0) |
netstandard2.1 | - (Not supported!) | Core 3.0 |