-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Write framework references for self-contained apps #3541
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
Comments
Proposed fix in https://github.com/vitek-karas/sdk/tree/IncludedFrameworks - can't really implement it fully as it needs to target |
It's not a runtime breaking change, but it's a breaking change to the SDK. IE if you update the SDK, and rebuild your app, it is a breaking change if the app stops working. It sounds like this may only apply to .NET Core 3.1 and higher. In that case we could only use the new format for .NET Core 3.1 and higher, which would not be breaking, as existing projects don't target .NET Core 3.1. |
Sorry I wasn't clear about that in the description - the proposed change already works that way - as in it will write the new property only for 3.1 and above. |
Fixed by #3697 for 3.1 (and will be migrated to master as well). |
…0191111.7 (dotnet#3541) - Microsoft.NETCore.App.Ref - 3.1.0-preview3.19561.7 - Microsoft.NETCore.App.Runtime.win-x64 - 3.1.0-preview3.19561.7 Dependency coherency updates - System.CodeDom - 4.7.0-preview3.19561.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) - System.Security.Cryptography.ProtectedData - 4.7.0-preview3.19561.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) - System.Text.Encoding.CodePages - 4.7.0-preview3.19561.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) - System.Resources.Extensions - 4.7.0-preview3.19561.8 (parent: Microsoft.NETCore.App.Runtime.win-x64)
SelfContained builds to not contain the `frameworks` node in the `runtimeconfig.json` file. They do however contain a `includedFrameworks` node. Details can be found here: dotnet/sdk#3541 Running tests against a built assembly with the `SelfContained` option does result in the following often discussed error message > Unable to instrument module
Problem
This is continuation of issue originally described in dotnet/core-setup#7610 and the SDK counterpart to dotnet/core-setup#7732.
When the native host loads a .NET Core component into already running .NET Core app, it tries to validate that the component's framework references can be satisfied by the app. In order to do this it needs to know which frameworks the app is using. For framework dependent apps this is trivial as the host knows which frameworks it resolved for the app. For self-contained apps though, there's no information about frameworks.
Currently framework dependent console app has
.runtimeconfig.json
like this:A self-contained app on the other hand has
.runtimeconfig.json
like this:{ "runtimeOptions": {} }
Proposal
Write the same information even for self-contained apps. The caveat is that framework references should not be written the exact same way otherwise host will think it's a framework dependent application (self-contained apps are recognized through the fact that they have no framework references).
Write the
tfm
propertyThis would make self-contained apps behave consistently with framework dependent apps. The TFM is not used widely by the host, but it does come into play in specific cases around additional probe paths and
DOTNET_SHARED_STORE
functionality.Compatibility note: It's not really a breaking change if we start writing the
tfm
property. It does change the behavior of the app slightly, but in order for it to take effect the app has to be rebuilt, so there's an explicit action by the developer.Write a new
includedFrameworks
propertyFramework references in self-contained apps would be written to a new property
includedFrameworks
which would use the same syntax. It's an array of objects, where each object represents a framework reference. The framework reference must specify itsname
andversion
. Other properties likerollForward
which are allowed on normal framework references will not be allowed here.Compatibility note: Combined with the changes in the host to consume this property, it will change behavior of apps when trying to load dynamic components. But the change requires a rebuild of the app in question, so it's not a breaking change.
The final
.runtimeconfig.json
would look like this:Naming is always an interesting question, so
includedFrameworks
is just one option. It could be calledembeddedFrameworks
,containedFrameworks
, ... other suggestions are very welcome. The name should be somewhat clear about the fact that the framework is part of the app.Impact
The proposed change makes the
.runtimeconfig.json
bigger for self-contained apps, but the change is tiny (100s of bytes).Performance wise there is some cost to write it in the SDK, but that it very small compared to the rest of the work SDK does. The host has to parse the new information as well, so there's some cost to that, but it doesn't have to process it (just remember) during startup, so the perf impact on startup should be very small.
The text was updated successfully, but these errors were encountered: