En3Tho / PoshRedisViewer

A compact redis browser for powershell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to test the module during dev-time

abhi18av opened this issue · comments

Hi @En3Tho ,

Thanks for the wonderful project!

I came across this repo while searching for cmdlet's written in F# for Powershell and this is a great example!

NOTE: The only change I've made to the source code is to change the TargetFramework to net6.0.

While testing the powershell module locally, I ran across the following error

PoshRedisViewer/PoshRedisViewer  🍣 main 🅒 base 
+  >_ Import-Module /Users/eklavya/projects/code/PoshRedisViewer/PoshRedisViewer/PoshRedisViewerModule/bin/Debug/net6.0/PoshRedisViewerModule.dll
Import-Module: Could not load file or assembly 'FSharp.Core, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Also, out of curiosity I noticed two salient features about the project structure and being new to the dotnet ecosystem I wanted to see if I understood them correctly.

  1. <PackageReference Remove="FSharp.Core" /> has been referenced in the fsproj file as to remove the FSharp.Core from the compiled assembly right? If so, could this be the reason why I'm seeing the Could not load file or assembly ... error above?

  2. I also noticed the "composition" of projects via <ProjectReference Include="..\PoshRedisViewer\PoshRedisViewer.fsproj" /> - I think this might be to create explicit compile time dependency between the projects, however it'd be great if you could please confirm.

  1. <PackageReference Remove="FSharp.Core" /> - this is sorta quirk because usually FSharp.Core is an implicit dependency coming from SDK. Not that you can choose direct version via nuget package manager.

  2. <ProjectReference Include="..\PoshRedisViewer\PoshRedisViewer.fsproj" /> - Yes, this is default way to specify dependencies on other projects in .Net csproj/fsproj etc

I'm not seeing any errors when changing TargetFramework to Net6.
Do you have 6.0 sdk installed? Implicit FSharp.Core should come from there.
Using dotnet --list-sdks can help you check.

You can try building https://github.com/En3Tho/PoshDotnetDumpAnalyzeViewer - this is C# project for powershell based on gui.cs too but it targets .Net6

Thanks @En3Tho for explaining the project/solution level details!

Do you have 6.0 sdk installed? Implicit FSharp.Core should come from there.

Actually yes, to be precise it is 6.0.103 [/usr/local/Cellar/dotnet/6.0.103/libexec/sdk].

In the meantime, I came across another project here https://github.com/Stroniax/PSSharp.PowerShell.FSharpCore and the approach of manually moving the F# core DLL into a separate folder with a DLL has done the trick for me. I've used the same techniques on my project to overcome this issue.

I think that till I gain more experience with the dotnet tooling and encantations - this might work fine.

P.S. https://github.com/En3Tho/PoshDotnetDumpAnalyzeViewer is a cool project ⭐ - I figure I'll need this sooner or later to debug stuff I'm trying to build. Thanks for building these tools man!

You shouldn't move anything manually. It should just build actually. No sure what is wrong.

No worries, I'll add the notes here as soon as I have more visibility on why this was happening. I'm on macOS by the way so there might be some platform dependent stuff going on.