fsprojects / FAKE

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

Resolve symlinks while searching for dotnet #2662

Closed Smaug123 closed 2 years ago

Smaug123 commented 2 years ago

Description

Resolve the path to dotnet fully (traversing symlinks) when trying to find the .NET reference assemblies.

This is necessary when, for example, you've installed dotnet using Nix. On my machine, for example:

➜ which dotnet
/etc/profiles/per-user/patrick/bin/dotnet
➜ readlink $(which dotnet)
/nix/store/2rhkamzmpmri3f91fcdvdgy8bbqacwyx-home-manager-path/bin/dotnet
➜ readlink $(readlink $(which dotnet))
/nix/store/q3w1pk4li282x1fml7rs8p93in5gq3ig-dotnet-sdk-6.0.100/bin/dotnet 

Only this final dotnet has a packs directory above it.

yazeedobaid commented 2 years ago

@Smaug123 Thanks for the PR 🚀

I suppose there is no easy way to add tests for this?

Thanks

Smaug123 commented 2 years ago

Well, quite :P I couldn't find one, but I'm not at all familiar with the FAKE codebase.

yazeedobaid commented 2 years ago

@Smaug123 The integration tests for SdkAssemblyResolver are in FAKE/src/test/Fake.Core.IntegrationTests/Fake.DotNet.sdkAssemblyResolver.fs

Please let me know if you need more information

Thanks

Smaug123 commented 2 years ago

I don't suppose you'd be interested if I refactored so that this could be unit tested instead?

I'm shaving yaks here; FAKE doesn't work on my Nix+Apple Silicon setup, which means I can't dotnet fake build, so it's extremely frictionful to write tests of any kind. This PR is intended to fix one of the reasons why my setup doesn't work, but the unrelated https://github.com/fsprojects/FAKE/issues/2626 is showstopping and I'm not willing to switch to x64 emulation or a non-Nix installation, so my development workflow here and in Fantomas tends to boil down to "stop using FAKE/Paket, add package references to all .fsproj files in the transitive footprint of the file I'm working on, and build using dotnet instead".

yazeedobaid commented 2 years ago

boy scout rule: "leave the code behind in a better state than you found it" (fix warnings, obsolete members or code-style in the places you worked in)

This point is one of the hints/requirements for sending a PR to FAKE. So, yes absolutely, if you can find room for improvement please go ahead. Every help/improvement counts.

We are currently working on the next major version of FAKE, v6. We are concerned mainly in two points:

  1. Improving modules and checking their state -> this is in progress.
  2. Improving FAKE runner. This mainly includes experimenting with how we can utilitze dotnet fsi out of the box feature(s) to resolve dependencies instead of using Paket and trying to resolve reference assemblies for a Dotnet SDK installation in the FAKE runner.

You are welcome to help in that regard also. We are using release/v6 branch for this work.

Thanks

Smaug123 commented 2 years ago

@yazeedobaid I'm not at all happy with this test - the whole thing seems to be hanging together by a thread - but there's a chance you'd consider this good enough to go in?

yazeedobaid commented 2 years ago

@Smaug123 Yes thanks a lot and sorry for the late response