dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.83k stars 4.62k forks source link

The logic for skipping the download of a local SDK (`/.dotnet`) can lead to build breaks #103776

Open SingleAccretion opened 2 months ago

SingleAccretion commented 2 months ago

Here the download of a local SDK is skipped if the version specified in global.json already exists in the global installation:

https://github.com/dotnet/runtime/blob/b0f3c193a995298ce8f23c0e18171c8bb75d6704/eng/common/tools.ps1#L185-L202

However, this logic does not take into account the possibility that a user may have two preview SDKs installed at the same time, wherein the older one matches for this check, while the newer one is actually used for building, which can cause mysterious build breaks.

@dicej ran into one of those. See this Discord discussion: https://discord.com/channels/143867839282020352/1141126727028985877/1253392081238626315.

He had both P3 from global.json and P4 installed on his machine, which skipped downloading the local SDK, but then actually using the P4 SDK didn't work.

Now, runtime's global.json permits unrestricted roll-forward, so perhaps this is by design. But it definitely took us some time to get to the root cause of this. And it doesn't look intended that having an older SDK installed makes the build use a newer one.

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @dotnet/runtime-infrastructure See info in area-owners.md if you want to be subscribed.

am11 commented 2 months ago

Usually we update the SDK version in global.json at the same time preview was publicly released, but if someone has daily build installed system-wide, or they are building older branch with newer preview installed on the system, rollforward can break things.

BTW, for the manual installation, I personally install daily/preview builds at different location and create version-suffixed alias to dotnet binary, in order to avoid cluttering the system-wide installation until the GA release.