.NET 6.0.x
How to install NES for .NET 6.0.x
Follow these easy steps to install NES for .NET:
- Download the package
- Install the package
- Verify your installation
Detailed Instructions
Download the package
Download the appropriate package for your needs:
Credentials for Downloads
The download links require your NES access token. When your browser asks you to sign in, enter your contact email as the username and your access token as the password. See Downloading with an Access Token for curl, PowerShell, NuGet, and Docker.
Windows Hosting Bundle
The Windows Hosting Bundle installs the .NET Runtime, the ASP.NET Core Runtime, and the ASP.NET Core Module (ANCM) for IIS. One installer covers both x64 and x86. ANCM is installed only when IIS is already present on the machine, so install or enable IIS first, then run the bundle.
Install the package
- Open the downloaded
.exefile(s)
- Follow the installation prompts
Verify your installation
Open a new Command Prompt and run:
dotnet --info
You should see the following based on what you installed:
Microsoft.NETCore.App 6.0.47Congratulations! You have successfully installed the NES for .NET.
Authenticate
Pulling requires a HeroDevs access token. Use your contact email as the username:
docker login registry.nes.herodevs.com -u <your-contact-email>
If you do not have an access token, contact support@herodevs.com. See Access Tokens for more information.
Verify the image
docker run --rm registry.nes.herodevs.com/nes/dotnet-runtime-container:6.0.47-bullseye-slim \
dotnet --list-runtimes
Microsoft.NETCore.App 6.0.47 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Self-contained deployments
The installers above cover apps that run on the shared runtime. An app published with --self-contained doesn't use the shared runtime. It carries its own copy, which the .NET SDK downloads as NuGet runtime packs when you publish. By default those packs come from nuget.org at 6.0.36, Microsoft's last .NET 6 release, so the app ships without NES fixes even on a server where NES is installed.
NES publishes the .NET 6 runtime packs on the NES NuGet feed with each release:
| Package | RIDs |
|---|---|
Microsoft.NETCore.App.Runtime.<rid> | win-x64, win-x86, linux-x64 |
Microsoft.NETCore.App.Host.<rid> | win-x64, win-x86, linux-x64 |
Microsoft.NETCore.App.Crossgen2.<rid> | win-x64, win-x86, linux-x64 |
Microsoft.AspNetCore.App.Runtime.<rid> | win-x64, win-x86, linux-x64 |
Microsoft.WindowsDesktop.App.Runtime.<rid> | win-x64 |
To publish against them, add the feed, point the SDK at the NES version, and check the result.
Add the NES feed
Create a nuget.config next to your solution file, or add these entries to the one you already have. Replace <NES_ACCESS_TOKEN> with your access token.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nesnet" value="https://registry.nes.herodevs.com/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<nesnet>
<add key="Username" value="artifactory" />
<add key="ClearTextPassword" value="<NES_ACCESS_TOKEN>" />
</nesnet>
</packageSourceCredentials>
<packageSourceMapping>
<packageSource key="nesnet">
<package pattern="Microsoft.NETCore.App.Runtime.*" />
<package pattern="Microsoft.NETCore.App.Host.*" />
<package pattern="Microsoft.NETCore.App.Crossgen2.*" />
<package pattern="Microsoft.AspNetCore.App.Runtime.*" />
<package pattern="Microsoft.WindowsDesktop.App.Runtime.*" />
</packageSource>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
The packageSourceMapping block sends the runtime packs to the NES feed only, so a restore can't quietly fall back to Microsoft's copies on nuget.org.
Existing package sources
Once a nuget.config has any packageSourceMapping, NuGet applies it to every package. If you restore from other feeds besides nuget.org, give each of them its own packageSource entry with the patterns it serves.
Point the SDK at the NES version
Microsoft's .NET 6 SDK only knows about runtime 6.0.36, so it asks for that version unless you tell it otherwise. Create a Directory.Build.targets next to your solution file:
<Project>
<ItemGroup>
<KnownFrameworkReference Update="Microsoft.NETCore.App" LatestRuntimeFrameworkVersion="6.0.47" />
<KnownFrameworkReference Update="Microsoft.AspNetCore.App" LatestRuntimeFrameworkVersion="6.0.47" />
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App" LatestRuntimeFrameworkVersion="6.0.47" />
<KnownAppHostPack Update="Microsoft.NETCore.App" AppHostPackVersion="6.0.47" />
<KnownCrossgen2Pack Update="Microsoft.NETCore.App.Crossgen2" Crossgen2PackVersion="6.0.47" />
</ItemGroup>
</Project>
Set the version to the current NES release, 6.0.47, and update it when you move to a new one.
If you build with the NES SDK 6.0.438, skip this step. It already asks for the NES runtime packs.
Publish and check the runtime version
Publish as you normally would:
dotnet publish -c Release -r win-x64 --self-contained true
Then check which runtime packs went into the output. The .deps.json file in the publish folder lists them:
Select-String -Path .\bin\Release\net6.0\win-x64\publish\*.deps.json -Pattern '"runtimepack\.'
Every line should show the NES version. For an ASP.NET Core app, the matches include:
"runtimepack.Microsoft.NETCore.App.Runtime.win-x64": "6.0.47",
"runtimepack.Microsoft.AspNetCore.App.Runtime.win-x64": "6.0.47"
If it still shows 6.0.36, the SDK isn't picking up Directory.Build.targets. If restore fails with NU1101 or NU1102 for a runtime pack, check the access token in nuget.config.
NuGet packages with NES fixes
Some NES fixes are in libraries that apps get from NuGet rather than from the installed runtime. Installing NES doesn't change them: an app that references one of these packages keeps using whichever version it restored. To get the fix, restore the NES version from the NES feed:
| Package | NES version |
|---|---|
Microsoft.AspNetCore.Identity.UI | 6.0.47 |
Microsoft.AspNetCore.Authentication.Negotiate | 6.0.47 |
Microsoft.AspNetCore.SignalR.Protocols.MessagePack | 6.0.47 |
Microsoft.AspNetCore.SignalR.StackExchangeRedis | 6.0.47 |
Microsoft.AspNetCore.DataProtection.StackExchangeRedis | 6.0.47 |
Microsoft.Extensions.Caching.SqlServer | 6.0.47 |
dotnet-sql-cache (tool) | 6.0.47 |
System.Formats.Cbor | 6.0.0.1 |
System.Security.Cryptography.Xml | 6.0.2.3 |
System.Security.Cryptography.Pkcs | 6.0.5.1 |
System.Security.Cryptography.Xml and System.Security.Cryptography.Pkcs also ship inside the ASP.NET Core and Windows Desktop runtimes, so ASP.NET Core, WinForms and WPF apps get those fixes from the NES runtime even with an older package reference. Other apps that reference them, such as console apps and worker services, need the NES package.
Add the packages to nuget.config
Use the nuget.config from Self-contained deployments, and add these patterns to both the nesnet and the nuget.org entries in packageSourceMapping:
<packageSourceMapping>
<packageSource key="nesnet">
<!-- the runtime pack patterns from above, then: -->
<package pattern="Microsoft.AspNetCore.Identity.UI" />
<package pattern="Microsoft.AspNetCore.Authentication.Negotiate" />
<package pattern="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" />
<package pattern="Microsoft.AspNetCore.SignalR.StackExchangeRedis" />
<package pattern="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" />
<package pattern="Microsoft.Extensions.Caching.SqlServer" />
<package pattern="dotnet-sql-cache" />
<package pattern="System.Formats.Cbor" />
<package pattern="System.Security.Cryptography.Xml" />
<package pattern="System.Security.Cryptography.Pkcs" />
<package pattern="Microsoft.AspNetCore.Connections.Abstractions" />
<package pattern="Microsoft.AspNetCore.Cryptography.Internal" />
<package pattern="Microsoft.AspNetCore.Cryptography.KeyDerivation" />
<package pattern="Microsoft.AspNetCore.DataProtection" />
<package pattern="Microsoft.AspNetCore.DataProtection.Abstractions" />
<package pattern="Microsoft.AspNetCore.SignalR.Common" />
<package pattern="Microsoft.Extensions.Features" />
<package pattern="Microsoft.Extensions.FileProviders.Embedded" />
<package pattern="Microsoft.Extensions.Identity.Core" />
<package pattern="Microsoft.Extensions.Identity.Stores" />
<package pattern="System.Formats.Asn1" />
</packageSource>
<packageSource key="nuget.org">
<package pattern="*" />
<package pattern="Microsoft.AspNetCore.Identity.UI" />
<package pattern="Microsoft.AspNetCore.Authentication.Negotiate" />
<package pattern="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" />
<package pattern="Microsoft.AspNetCore.SignalR.StackExchangeRedis" />
<package pattern="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" />
<package pattern="Microsoft.Extensions.Caching.SqlServer" />
<package pattern="dotnet-sql-cache" />
<package pattern="System.Formats.Cbor" />
<package pattern="System.Security.Cryptography.Xml" />
<package pattern="System.Security.Cryptography.Pkcs" />
<package pattern="Microsoft.AspNetCore.Connections.Abstractions" />
<package pattern="Microsoft.AspNetCore.Cryptography.Internal" />
<package pattern="Microsoft.AspNetCore.Cryptography.KeyDerivation" />
<package pattern="Microsoft.AspNetCore.DataProtection" />
<package pattern="Microsoft.AspNetCore.DataProtection.Abstractions" />
<package pattern="Microsoft.AspNetCore.SignalR.Common" />
<package pattern="Microsoft.Extensions.Features" />
<package pattern="Microsoft.Extensions.FileProviders.Embedded" />
<package pattern="Microsoft.Extensions.Identity.Core" />
<package pattern="Microsoft.Extensions.Identity.Stores" />
<package pattern="System.Formats.Asn1" />
</packageSource>
</packageSourceMapping>
Listing the packages under both sources lets NuGet take the NES version you reference from the NES feed, while other packages that need a newer version of one of them, such as System.Formats.Asn1 8.0, still get it from nuget.org. The second group of patterns, from Microsoft.AspNetCore.Connections.Abstractions on, are NES builds the fixed packages depend on.
Reference the NES version
NuGet restores the lowest version that matches your reference, so it won't move to the NES version on its own. Update each reference to the version in the table:
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.47" />
For the dotnet-sql-cache tool, run this from the folder with your nuget.config:
dotnet tool update --global dotnet-sql-cache --version 6.0.47
Check the restored versions
dotnet list package --include-transitive
Each package in the table should show its NES version. If restore fails with NU1101 or NU1102, check the access token in nuget.config and that the package is listed under nesnet.