-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
RuntimeSpecific Apps (.NET Apps with a RuntimeIdentifier
) Will No Longer Be SelfContained
by default, and instead Framework Dependent By Default.
dotnet/sdk#30038
cc @richlander.
Version
.NET 8 Preview 5
Previous behavior
Previously, if RuntimeIdentifier
(RID) was specified, the app would be SelfContained
(SC) if SelfContained
was not explicitly specified.
New behavior
Now, for apps with TargetFramework
8.0 or higher, RuntimeIdentifier
no longer implies SelfContained
by default. Instead, apps that give a runtime identifier will be dependent on the .NET Framework by default (FDD). Apps for .NET 7 or below will not see this change in behavior.
This is a break for any customer that deployed, distributed, published, etc, their app, and desired their app to not require the .NET Framework to be installed on the machine for it to work, but did not explicitly add SelfContained
to get this behavior. They may have relied on the old behavior to produce a .NET Framework INDEPENDENT app by default.
This is a break for anyone relying on the IL Link tool. Users will have to take the steps described below to use IL Link again.
Note: Some Publish
properties like PublishTrimmed
, and PublishSingleFile
, PublishAot
, currently require SelfContained
to work and using these properties will require SelfContained
to be added now.
This is a break for Blazor WASM apps as they relied on this behavior. We expect the Blazor WASM team to side-step this breaking change in their SDK by adding SelfContained
automatically for all customers, so Blazor customers should be unaffected.
Type of breaking change
- Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
- Behavioral change: Existing binaries may behave differently at run time.
Reason for change
Previously we warned of this breaking change with the following warning in .NET 6:
warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/app/app.csproj]
We have given customers time to add SelfContained
explicitly.
As for why the change is being made:
- This is currently what Visual Studio does by default. So it aligns the dotnet SDK with VS.
- It will save space to have apps be framework dependent by default as there won't be copies of .NET stored in each app.
- Command line options should be ideally orthogonal. In this case the tooling supports both RuntimeIdentifier specific SelfContained Deployment and RID specific Framework Dependent Deployments. So it's really weird that no-RID -> defaults to FDD and RID -> defaults to SCD. It has made even internal people at MSFT think that you cant have a Non SelfContained app (FDD) if a RID is given, which is NOT true.
Recommended action
Customers using .NET 7 and below who relied on the old behavior where SelfContained
was inferred will 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.
They should follow the guidance of the warning if they want to continue to produce SelfContained
apps. If they would like to move to the new default, they can set SelfContained
as false
, in the project file, like
<SelfContained>false</SelfContained
or in the call to dotnet,
like dotnet publish --no-self-contained
.
For .NET 8, nothing needs to be specified unless the old default is desired, in which case the customer must add SelfContained
as true
.
Feature area
SDK
Affected APIs
No response