fsprojects / FAKE

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

Calling DotNet.exec from a script in AzureDevOps starts older version of dotnet command #2651

Open ds185357 opened 2 years ago

ds185357 commented 2 years ago

Description

After update to Fake.DotNet.CLI 5.21 and 5.21.1, DotNet.exec command runs from default location instead of the location where dotnet is executed from for fake run.

Repro steps

Having two scripts build.fsx and fantomas.fsx where the former calls the later as shown below:

build.fsx excerpt

Target.create "CheckCodeFormat" (fun _ -> let r = DotNet.exec id "fake" "run fantomas.fsx -t CheckCodeFormat" if not r.OK then failwith "fantomas CheckCodeFormat build script failed" )

fantomas.fsx

Target.create "CheckCodeFormat" (fun _ -> let checkCodeResult = filesToCheckCodeOn |> Seq.map (sprintf "\"%s\"") |> String.concat " " |> sprintf "%s --check" |> DotNet.exec id "fantomas"

if checkCodeResult.ExitCode = 0 then
    Trace.log "No files need formatting"
elif checkCodeResult.ExitCode = 99 then
    failwith "Some files need formatting, check output for more info"
else
    Trace.logf "Errors while formatting: %A" checkCodeResult.Errors)

Expected behavior

Fantomas should be started by the command below (dotnet located in hostedtoolcache, dotnet 6.0)

D:\a\1\s> "C:\hostedtoolcache\windows/dotnet\dotnet.EXE" fake run fantomas.fsx -t CheckCodeFormat (In: false, Out: false, Err: false)

Actual behavior

Fantomas is started by the command below (dotnet located in Program Files, dotnet 5.0)

D:\a\1\s> "C:\Program Files\dotnet\dotnet.exe" fake run fantomas.fsx -t CheckCodeFormat (In: false, Out: false, Err: false)

Known workarounds

Use Fake.DotNet.CLI < 5.21

Related information

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!