toenuff / flancy

A micro web framework for Windows PowerShell
MIT License
189 stars 21 forks source link

Flancy Broken: Instantly didn't work following the directions on a new install of Windows and VSCode #45

Open ghost opened 2 years ago

ghost commented 2 years ago

I was told this following code would be EASY!

import-module flancy $url = "http://localhost:8001"

new-flancy -url $url -webschema @( Get '/' { "Welcome to Flancy!" } Get '/processes' { $processes = Get-Process $processes |select name, id |convertto-json } )

Sure it looks easy but the dependencies the code requires are not available by default in Windows and I just spent 4 hours unsuccessfully trying to get them.

new-flancy -url $url -webschema @(

Get '/' { "Welcome to Flancy!" }
Get '/processes' {
    $processes = Get-Process
    $processes |select name, id |convertto-json
}

) Add-Type: (2,14): error CS0234: The type or namespace name 'Management' does not exist in the namespace 'System' (are you missing an assembly reference?) using System.Management.Automation; ^

Add-Type: (9,27): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. public class Module : NancyModule ^

Add-Type: (56,39): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. public class CustomBootstrapper : DefaultNancyBootstrapper ^

Add-Type: (58,28): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. protected override IRootPathProvider RootPathProvider ^

Add-Type: (11,16): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. public PowerShell shell = PowerShell.Create(); ^

Add-Type: (11,16): error CS0246: The type or namespace name 'PowerShell' could not be found (are you missing a using directive or an assembly reference?) public PowerShell shell = PowerShell.Create(); ^

Add-Type: (48,48): error CS0012: The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. } public class CustomRootPathProvider : IRootPathProvider ^

Add-Type: (62,54): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. protected override void ConfigureConventions(NancyConventions conventions) ^

Add-Type: (60,29): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. get {return new CustomRootPathProvider();} ^

Add-Type: (11,35): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. public PowerShell shell = PowerShell.Create(); ^

Add-Type: (11,35): error CS0103: The name 'PowerShell' does not exist in the current context public PowerShell shell = PowerShell.Create();

^

Add-Type: (64,18): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. base.ConfigureConventions(conventions); ^

Add-Type: (90,43): error CS0234: The type or namespace name 'WindowsIdentity' does not exist in the namespace 'System.Security.Principal' (are you missing an assembly reference?) config.UrlReservations.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name; ^

Add-Type: (93,29): error CS0012: The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. this.host = new NancyHost(config, uri); ^

Add-Type: (104,23): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. this.host.Start(); ^

Add-Type: (107,23): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. this.host.Stop(); ^

Add-Type: (14,13): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. StaticConfiguration.DisableErrorTraces = false; ^

Add-Type: (16,13): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. Get["/"] = _ => {try { ^

Add-Type: (30,13): error CS0012: The type 'Func<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Get["/processes"] = _ => {try { ^

Add-Type: (30,13): error CS0012: The type 'Func<,,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Get["/processes"] = _ => {try { ^ $psversiontable
rameter 'Exception' because it is null.

                                                  alued expression.
robinmalik commented 2 years ago

Before I spend any amount of time trying to get a project to work, I tend to check the date of the last commit to try and guess whether it's still supported; this codebase was last updated 6 years ago. Whilst it really was very simple then (and for some years after) sadly it seems something has changed! I can't speak for the maintainer as to whether it'll be updated to address these issues but I can recommend Pode which is under active development (and also simple): https://github.com/Badgerati/Pode/