fsprojects / FAKE

FAKE - F# Make
https://fake.build
Other
1.28k stars 585 forks source link

Fake 5.22.0 is not respecting `rollForward` property in global.json #2678

Closed InvisibleBacon closed 2 years ago

InvisibleBacon commented 2 years ago

Description

I am having to specify a sdk version in global.json in order to force Fake to use something greater than netstandard2.0 since our fake script uses async (see https://github.com/fsprojects/FAKE/issues/2659#issuecomment-1048985697 for details).

I was hoping to not require all our devs (and build servers) to require a specific patch of the .NET 6 sdk so I added "rollForward": "latestPatch" to the global.json file. However I would get errors like this unless I had the exact SDK version installed:

There was a problem while setting up the environment: -> Could not find referenced assemblies in path: 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.2\ref\net6.0', please check installed SDK and runtime versions

Repro steps

NOTE: I am using the specific version numbers I tested with below, but this appears to be a general problem whenever you don't have the runtime installed that is associated with the SDK patch specified in global.json

  1. On a machine that does not have SDK 6.0.200 and also does not have the 6.0.2 runtime installed, but does have SDK 6.0.202 and runtime 6.0.4, use the specified global.json file:

    {
    "sdk": {
    "version": "6.0.200",
    "rollForward": "latestPatch"
    }
    }
  2. Run fake (I am including verbose output). You will get this output

    resolved runtime version: 6.0.2
    Resolved referenced SDK path: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.2\ref\net6.0
    ...
    There was a problem while setting up the environment, see standard error for details.
    There was a problem while setting up the environment:
    -> Could not find referenced assemblies in path: 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.2\ref\net6.0', please check installed SDK and runtime versions

Expected behavior

It should have honored the rollForward prop and rolled forward to the 6.0.202 SDK and 6.0.4 runtime that I had installed.

I later learned that "rollForward": "latestPatch" is actually the default behavior if none is specified so ideally I shouldn't have had to do anything to get this behavior.

Actual behavior

See repro.

Known workarounds

Only workaround I know of is to require all devs to install a specific SDK version.

Related information

I did look at the source a bit and see that Fake is parsing the global.json file directly to determine the runtime. https://github.com/fsprojects/FAKE/blob/5.22.0/src/app/Fake.DotNet.Cli/DotNet.fs

Is there a way to rely on dotnet to give the appropriate sdk/runtime rather than parsing the file directly?

github-actions[bot] commented 2 years ago

Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!

InvisibleBacon commented 2 years ago

Ah.. well I see I should search through existing issues more carefully before creating a new one. This is a duplicate of https://github.com/fsprojects/FAKE/issues/2641