Събитие
Създаване на интелигентни приложения
17.03, 23 ч. - 21.03, 23 ч.
Присъединете се към поредицата срещи, за да изградите мащабируеми AI решения, базирани на реални случаи на употреба с колеги разработчици и експерти.
Регистрирайте се сегаТози браузър вече не се поддържа.
Надстройте до Microsoft Edge, за да се възползвате от най-новите функции, актуализации на защитата и техническа поддръжка.
Runtime-specific apps, or .NET apps with a RuntimeIdentifier
, are no longer self-contained by default. Instead, they are framework-dependent by default.
This is a breaking change in the following situations:
SelfContained
property, but also didn't require that the .NET runtime be installed on the machine for it to work. In this case, you may have relied on the previous behavior to produce a self-contained app by default.Previously, if a runtime identifier (RID) was specified (via RuntimeIdentifier), the app was published as self-contained, even if SelfContained
wasn't explicitly specified.
In addition:
PublishSelfContained
wasn't explicitly set to false
, the publish properties PublishSingleFile
and PublishAot
implied a RuntimeIdentifier
and therefore SelfContained
(if it wasn't specified) during operations including dotnet build
, dotnet restore
, and dotnet publish
.PublishTrimmed
property did not imply SelfContained
.PublishReadyToRun
property implied SelfContained
if SelfContained
wasn't specified.Starting in .NET 8, for apps that target .NET 8 or a later version, RuntimeIdentifier
no longer implies SelfContained
by default. Instead, apps that specify a runtime identifier are dependent on the .NET runtime by default (framework-dependent). Apps that target .NET 7 or earlier versions aren't affected.
In addition:
PublishSelfContained
isn't explicitly set to false
, the publish properties PublishSingleFile
and PublishAot
now imply SelfContained
(if it's not specified) during dotnet publish
only (that is, not for dotnet build
or dotnet restore
).PublishTrimmed
property also now implies SelfContained
during dotnet publish
.PublishReadyToRun
property no longer implies SelfContained
if the project targets .NET 8 or later.Бележка
If you publish using msbuild /t:Publish
and you want your app to be self-contained, you must explicitly specify SelfContained
, even if your project has one of the listed publish properties.
.NET 8 Preview 5
This change can affect source compatibility and binary compatibility.
.NET 6 alerted users to this breaking change with the following warning:
warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used.
Now that customers have had time to add SelfContained
explicitly, it's okay to introduce the break.
If you're using .NET 7 or an earlier version and relied on the previous behavior where SelfContained
was inferred, you'll see this warning:
For projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically gives a SelfContained app. To continue creating a .NET framework independent app after upgrading to 8.0, consider setting SelfContained explicitly.
Follow the guidance of the warning and declare your app as self-contained. You can do that either in the project file or as a command-line argument, for example, dotnet publish --self-contained
.
If you're using .NET 8 and want to keep the previous behavior, set SelfContained
to true
in the same way as previously described.
SelfContained
is an MSBuild property that you can insert into your project file, which is a file that has a .csproj, .vbproj, or .fsproj extension. Set the property as follows:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
Обратна връзка за .NET
.NET е проект с отворен код. Изберете връзка, за да предоставите обратна връзка:
Събитие
Създаване на интелигентни приложения
17.03, 23 ч. - 21.03, 23 ч.
Присъединете се към поредицата срещи, за да изградите мащабируеми AI решения, базирани на реални случаи на употреба с колеги разработчици и експерти.
Регистрирайте се сегаОбучение
Модул
Publish an ASP.NET Core app - Training
Learn how to publish an ASP.NET Core app for deployment to a web server or cloud service.
Документация
.NET Runtime Identifier (RID) catalog - .NET
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
ReadyToRun deployment overview - .NET
Learn what ReadyToRun deployments are and why you should consider using it as part of the publishing your app with .NET 5 and .NET Core 3.0 and later.
dotnet publish command - .NET CLI
The dotnet publish command publishes a .NET project or solution to a directory.