-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's new in .NET 8 Preview 3 #8135
Comments
SDK: Simplified Output Path format for builds
.NET applications can be built in many different ways, and as a result users of the platform have gotten familiar with a very deep and complex set of output paths for different build artifacts. Folders like To address both of these challenges and make the build outputs easier to use and more consistent, the .NET SDK team has introduced an option that creates a more unified, simplified output path structure. The new output path focuses on
To opt into the new output path layout, you need to set the <UseArtifactsOutput>true</UseArtifactsOutput> From this point on, build output for all projects will be placed into the
We think that this unified output structure addresses concerns that we've heard from our users and gives us a foundation we can build on for the future. The |
SDK: Add
|
SDK: Misc. Breaking ChangesThe .NET SDK tries to make changes without causing behavioral breaks, but sometimes that's either not possible or the breaking change is just obviously correct. The first breaking change we'll talk about for the SDK in preview 3 is the latter category. The .NET SDK has a few ways to change the locale of the |
Introducing
|
Introducing the configuration binding source generatorApplication configuration in ASP.NET Core is performed using one or more configuration providers. Configuration providers read data (as key-value pairs) from a variety of sources such as settings files (e.g. appsettings.json), environment variables, Azure Key Vault etc. At the core of this mechanism is In .NET 8, as a replacement to reflection, we wish to ship a source generator that generates reflection free and AOT friendly binding implementations. The generator probes for Configure, Bind, and Get calls that we can retrieve type info from. Here's example of code that users write to invoke the binder: using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
IConfigurationSection section = builder.Configuration.GetSection("MyOptions");
// !! Configure call - to be replaced with source-gen'd implementation
builder.Services.Configure<MyOptions>(section);
// !! Get call - to be replaced with source-gen'd implementation
MyOptions options0 = section.Get<MyOptions>();
// !! Bind call - to be replaced with source-gen'd implementation
MyOptions options1 = new MyOptions();
section.Bind(myOptions1);
WebApplication app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();
public class MyOptions
{
public int A { get; set; }
public string S { get; set; }
public byte[] Data { get; set; }
public Dictionary<string, string> Values { get; set; }
public List<MyClass> Values2 { get; set; }
}
public class MyClass
{
public int SomethingElse { get; set; }
} When the generator is enabled in a project, the generated methods are implicitly picked, by the compiler, over the pre-existing reflection-based framework implementations. To enable the source generator, download the latest preview version of the the Microsoft.Extensions.Configuration.Binder NuGet package. The generator is off by default. To use it, add the following property to your project file: <PropertyGroup>
<EnableMicrosoftExtensionsConfigurationBinderSourceGenerator>true</EnableMicrosoftExtensionsConfigurationBinderSourceGenerator>
</PropertyGroup> In preview 4, we will add the enabling mechanism to the .NET SDK so that the NuGet package reference is not required to use the source generator. Please try the feature and report any issues at https://github.com/dotnet/runtime/issues. Stretch info
|
Building multi-platform container imagesIt is now common to use both Arm64 and x64 machines on a regular basis. x64 machines have been around for decades, however, Arm64 dev machines (like Apple Macs) and Arm64 cloud nodes are relatively new. Docker supports using and building multi-platform images that work across multiple environments. We've developed a new pattern that enables you to mix and match architectures with the .NET images you build. Imagine you are on an Apple Mac and want to target an x64 cloud service in Azure. You can build the image by using the docker build --pull -t app --platform linux/amd64 . Using the new pattern, you'd update just one line in your Dockerfile (the build stage): FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-preview-alpine AS build That line enables the SDK to run on the local machine architecture, which will make it run faster and compatibly (since .NET doesn't support QEMU). This line didn't require a change in .NET but is a useful Docker feature. We also updated the SDK (in Preview 3) to support RUN dotnet restore -a $TARGETARCH
# copy everything else and build app
COPY aspnetapp/. .
RUN dotnet publish -a $TARGETARCH --self-contained false --no-restore -o /app This approach enables producing more optimized apps in a way that integrates well with the Docker This sample demonstrates the pattern. You can also try it if you clone that repo. Improving multi-platform container support goes into much more detail on this topic. |
Environment Variable for non-root user UID valueWe've added an environment variable for the UID for the non-root user that we added in Preview 1. We realized that the Kubernetes You can see that used in this Dockerfile: USER $APP_UID That's the pattern we recommend for .NET 8. When you build a container image when $ docker inspect app | jq .[-1].Config.User
"64198" You can see how this environment variable is defined. $ docker run --rm -it mcr.microsoft.com/dotnet/runtime bash -c "export | grep APP"
declare -x APP_UID="64198"
$ docker run --rm -it mcr.microsoft.com/dotnet/runtime cat /etc/passwd | tail -n 1
app:x:64198:64198::/home/app:/bin/sh |
CodeGenCommunity PRs (Many thanks to JIT community contributors!)
Arm64
PGO
General Optimizations
|
Breaking change: Multi-platform .NET 8 tags no longer support Windows containersMulti-platform container images make it easy to use the same tags in multiple environments, leaving This change was made because Windows multi-platform tags don't work well with respect to selecting the best version. It is better to specify the Windows version you want. This change is discussed in much more detail in Switch multi-platform tags to Linux only. Pulling a .NET 8 multi-platform tag will result in the following behavior, when "Windows Containers" mode is enabled. >docker pull mcr.microsoft.com/dotnet/nightly/runtime:8.0-preview
8.0-preview: Pulling from dotnet/nightly/runtime
no matching manifest for windows/amd64 10.0.22621 in the manifest list entries Going forward, you will need to use one of the following tags, for Windows
More information: dotnet/dotnet-docker#4549 |
What's new in .NET 8 Preview 3
This issue is for teams to highlight work for the community that will release in .NET 8 Preview 3
To add content, use a new conversation entry. The entry should include the team name and feature title as the first line shown in the template below.
Required
Optional
Below are three additional items to consider. These will help the .NET 8 blog team and the community throughout the release.
Index of .NET 8 releases
Preview 1: #8133
Preview 2: #8134
Preview 3: #8135
Preview 4: #8234
Preview 5: https://github.com/dotnet/core/issues
Preview 6: https://github.com/dotnet/core/issues
Preview 7: https://github.com/dotnet/core/issues
RC 1: https://github.com/dotnet/core/issues
RC 2: https://github.com/dotnet/core/issues
The text was updated successfully, but these errors were encountered: