ionide / ionide-vscode-fake

VS Code plugin for FAKE
http://ionide.io
MIT License
17 stars 13 forks source link

Can't build on Windows with build.ps1 #23

Open panesofglass opened 7 years ago

panesofglass commented 7 years ago

Whenever I try to run FAKE Build with a local .ionide file using build.ps1, I see the following banner: image

I also see this in the Developer Tools Console window:

[Extension Host] last output: [object Map]
extensionHost.ts:282 [Extension Host] mono
extensionHost.ts:282 [Extension Host] c:\Tachyus\thermion/build.ps1
extensionHost.ts:282 [Extension Host] c:\Tachyus\thermion/build.fsx
messageService.ts:126 spawn UNKNOWNe.doShow @ messageService.ts:126e.show @ messageService.ts:105t.onError @ commandsHandler.ts:105(anonymous function) @ commandsHandler.ts:118done @ winjs.base.raw.js:1378v @ winjs.base.raw.js:1224enter @ winjs.base.raw.js:901_run @ winjs.base.raw.js:1068_error @ winjs.base.raw.js:1041n @ winjs.base.raw.js:743v @ winjs.base.raw.js:1209enter @ winjs.base.raw.js:901_run @ winjs.base.raw.js:1068_error @ winjs.base.raw.js:1041e.resolveErr @ ipcRemoteCom.ts:110f @ ipcRemoteCom.ts:203_combinedTickCallback @ internal/process/next_tick.js:67_tickCallback @ internal/process/next_tick.js:98
shell.ts:426 spawn UNKNOWN: Error: spawn UNKNOWN
    at exports._errnoException (util.js:1026:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at Object.exports.spawn (child_process.js:392:9)
    at Process__spawn$ (C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:514:29)
    at Process__spawnWithNotification$ (C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:530:9)
    at FakeService__startBuild$ (C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:311:18)
    at C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:181:14
    at Object.m [as _notify] (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:6:6584)
    at Object.enter (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:6:10162)
    at _run (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:6:11990)e.onUnexpectedError @ shell.ts:426(anonymous function) @ shell.ts:383e.onUnexpectedError @ errors.ts:68o @ errors.ts:88(anonymous function) @ winjs.base.js:43(anonymous function) @ winjs.base.js:38
winjs.base.js:45 WARNING: Promise with no error callback:112
winjs.base.js:46 Object {exception: null, error: Error: spawn UNKNOWN
    at exports._errnoException (util.js:1026:11)
    at ChildProcess.spawn (int…, promise: n.C…s.d…e._oncancel, handler: undefined, id: 112…}error: Error: spawn UNKNOWN
    at exports._errnoException (util.js:1026:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at Object.exports.spawn (child_process.js:392:9)
    at Process__spawn$ (C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:514:29)
    at Process__spawnWithNotification$ (C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:530:9)
    at FakeService__startBuild$ (C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:311:18)
    at C:\Users\ryan\.vscode\extensions\Ionide.Ionide-FAKE-1.2.3\fake.js:181:14
    at Object.m [as _notify] (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:6:6584)
    at Object.enter (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:6:10162)
    at _run (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:6:11990)exception: nullhandler: undefinedid: 112parent: undefinedpromise: n.Class.derive._oncancel__proto__: Object

Environment:

Please let me know how I can help if this is an actual bug.

Krzysztof-Cieslak commented 7 years ago

Soo.... anyone is using .ps1 files for FAKE ? I guess it was never tested. ;)

I don't even know if node can spawn .ps1 files

Krzysztof-Cieslak commented 7 years ago

Quick googling suggests that .ps1 files will need some additional handling - http://stackoverflow.com/questions/10179114/execute-powershell-script-from-node-js

panesofglass commented 7 years ago

@Krzysztof-Cieslak can you point to where I need to hook this up? I am happy to work on it.

panesofglass commented 7 years ago

Quick and dirty solution might be to parse the extension and, if it's ps1 change https://github.com/panesofglass/ionide-vscode-fake/blob/master/src/fake.fs#L36 to use

let cmd =
    match System.IO.File.GetExtension(target) with
    | "ps1" -> sprintf "powershell.exe %s" (fixSpaces target)
    | _ -> fixSpaces target
let proc = Process.spawnWithNotification command linuxPrefix cmd outputChannel

Also, assuming target is the location, I'm confused why https://github.com/ionide/ionide-atom-helpers/blob/master/src/ProcessHelpers.fs#L118 seems to have the target and command parameters flipped. Am I reading that wrong? Should the above actually be:

let cmd =
    if System.IO.File.GetExtension(command) = "ps1"
    then "powershell.exe " + command
    else command
let proc = Process.spawnWithNotification cmd linuxPrefix (fixSpaces target) outputChannel
panesofglass commented 7 years ago

As an alternative, the normal way one invokes powershell from a cmd.exe is with @powershell ... That might be better than hoping powershell.exe is on the path.