-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Enable projects to use the SDK TargetFramework
#29949
Comments
I noticed that I've raised this previously. |
why don't we do this? I love user-delightful stuff like this. I hit this daily. |
An alternative (and likely better) design is to leave |
I definitely think we should do something. There are several different user experiences we could provide, on a sliding scale of potential work/disruption:
My preference is the second option - the third, while tempting, is very broad and I would worry about giving users clarity about what it means version-to-version, as well as having firm guidance for folks contributing to the SDK to prevent it becoming a 'kitchen sink' property. |
We have a <TargetFramework>net$(NETCoreAppMaximumVersion)</TargetFramework> We should think twice about offering something like this though. Projects which roll forward the |
I agree with you @dsplaisted although it is odd to gate upgrades on both
That's not actually that bad, however, it requires the project to be written that way. I was hoping for a way to augment this value outside of the project. It may not be obvious, but we'd equally need to support the following flows:
The |
IIRC this is defined after Directory.Build.props is imported, which makes it harder to do solution-wide conditional logic on SDK versions. |
That's a good point. It isn't written down yet, but we're moving to model (I think) where:
|
Perhaps we should put a version number at the top: <Project Sdk="Microsoft.NET.Sdk.Web" version="8.0">
<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project> That completes the pivot. The Or better yet: <Project Sdk="Microsoft.NET.Sdk.Web" version="8.0">
</Project> Obviously, there might be an |
So there's already a versioning mechanism for SDKs, it just isn't used widely today. Are you suggesting that specifying the SDK version in this way should default the TFM (and other properties potentially) to "current SDK defaults"? |
Yes. Certainly, whether it is opt-in min or exact is a detail. There are really two suggestions here:
|
Here's a slightly different look at this. To build our own repositories with Arcade and avoid manually updating TFMs, we added floating TFMs properties, i.e. I would find it useful if we would publicly expose those in the SDK. They would get updated when the SDK revs to the next version of .NET. Examples
<Project>
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<PropertyGroup>
</Project>
<Project>
<PropertyGroup>
<TargetFrameworks>$(NetCurrent);$(NetMinimum)</TargetFrameworks>
<PropertyGroup>
</Project> |
I don't have any real concerns with exposing I'd have concerns with
|
I think we should scope this to To address concerns about breaking projects:
|
Any update? Seemed the |
Not implemented yet but it would be great to get this in for .NET 10. It would simplify things a lot. |
The .NET SDK comes with a targeting pack and a runtime (in addition to build tools). If you compile an app for the same version as the SDK, then you can use the targeting pack and runtime that comes with the SDK. Yeahh! If you compile an app for an older version, then you need an older version of the runtime and targeting pack. You can either install those or update the project file. There is no way to that via the commandline. You can change the RID via the commandline but not the TFM.
The .NET SDK offers a variety of controls for controlling compile-time vs runtime framework versions. The model, however, could be better. This is particularly obvious if you are wanting to test existing/old apps on a newer SDK.
FYI: I'm using older .NET versions for my examples, only because they were convenient. This experience hasn't changed recently.
This is the base experience today, when SDK and
TargetFramework
don't match:You cannot updated
TargetFramework
from the commandline, AFAICT.The
RollForward
property works pretty well. It can be added to a project file or injected viaENV
or the CLI (via-p:RollFoward
).RollForward
model has the downside that an old target framework needs to be downloaded, at least in the case that you want to use a new SDK for both compiling and running the app.Instead, it would nice if there was a way to say "roll forward by using the SDK target framework". That would result in using SDK-provided assets and to naturally using the SDK runtime version.
We could offer a way to specify what the minimum target framework is for a project and infer the actual target framework from the SDK (assuming it is same or higher). That way, you wouldn't ever get weird compile-time failures due to missing APIs.
Perhaps via the following property:
or possibly:
The second property could also be
UseSdkDefaults
if we wanted something more general.This approach would have a few benefits:
RollForward
property wouldn't need to be used as part of development, leaving it only for deployed apps.Some apps would break with this model, either due to breaking changes, warning waves or something else. It's less about the apps breaking and more about the care factor of the apps breaking. There are two solutions for that: don't use the feature, or use
global.json
. For people that useglobal.json
, this feature would still have significant value.This model would be more complicated for compound TFMs, like the ones we have for Android and iOS. That would require some more thought. I thought we should start out with the base premise before looking at those TFMs.
This model wouldn't work (at least not naturally) with multi-targeting. That seems fine, both because multi-targeting is uncommon with apps and because multi-targeting is an intentional model that isn't amenable to policy solutions like this.
The text was updated successfully, but these errors were encountered: