New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable VSCode integration to fake-dotnetcore? #1744

Closed
teo-tsirpanis opened this Issue Dec 6, 2017 · 16 comments

Comments

Projects
None yet
4 participants
@teo-tsirpanis
Contributor

teo-tsirpanis commented Dec 6, 2017

I just installed Fake 5 to a new project of mine. I loaded an example build script, but got this:

image

I know that the build script does not compile. But Ionide does not recognize the Fake namespace.

Is there a way to make Ionide understand the build script despite the inline Paket dependencies file?

@matthid

This comment has been minimized.

Collaborator

matthid commented Dec 6, 2017

Ok the principle idea is to have "include" scripts for the IDE in order to provide proper intellisense (via #if because FAKE itself doesn't need them). However this is currently blocked because of ionide/ionide-vscode-fsharp#558

So the current way (as scripting is not supported in netcore) is to manually use a paket load script and load FakeLib.dll (the "old" FAKE) via #if !FAKE this way the IDE can pretend like it is a non-netcore script.

This is quite cumbersome at the moment. Take a look at build.fsx in this repository to get an idea on how to make the IDE kind of work.

@matthid

This comment has been minimized.

Collaborator

matthid commented Dec 6, 2017

By the way any help/idea/hack is appreciated in this space... I'd like to get this to work as well...

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Dec 8, 2017

I just ported one of my project to Fake5 and wasn't that easy at first. My way to get intellisense support by doing:

To get intellisense, i wrote:

paket.dependencies:

group netcorebuild
    source https://www.nuget.org/api/v2
    nuget NETStandard.Library.NETFramework
    nuget Fake.DotNet.Cli
    nuget Fake.DotNet.Paket
    nuget Fake.Core.Target
    nuget Fake.Core.Process
    nuget Fake.Core.String
    nuget Fake.Core.Globbing
    nuget Fake.Core.ReleaseNotes
    nuget Fake.IO.FileSystem
    nuget FSharpx.Async

build.fsx

(* -- Fake Dependencies paket.dependencies
file ./paket.dependencies
group netcorebuild
-- Fake Dependencies -- *)

#if !DOTNETCORE
#I "./packages/netcorebuild"
#r "NETStandard.Library.NETFramework/build/net461/lib/netstandard.dll"
#r "Fake.DotNet.Paket/lib/netstandard2.0/Fake.DotNet.Paket.dll"
#r "Fake.IO.FileSystem/lib/netstandard2.0/Fake.IO.FileSystem.dll"
#r "Fake.Core.Globbing/lib/netstandard2.0/Fake.Core.Globbing.dll"
#r "Fake.Core.String/lib/netstandard2.0/Fake.Core.String.dll"
#r "Fake.Core.Target/lib/netstandard2.0/Fake.Core.Target.dll"
#r "Fake.DotNet.Cli/lib/netstandard2.0/Fake.DotNet.Cli.dll"
#r "Fake.Core.ReleaseNotes/lib/netstandard2.0/Fake.Core.ReleaseNotes.dll"
#r "Fake.Core.Process/lib/netstandard2.0/Fake.Core.Process.dll"
#r "Fake.Core.Environment/lib/netstandard2.0/Fake.Core.Environment.dll"
#endif

open System
open System.IO
open System.Text.RegularExpressions
open Fake.Core.Globbing.Operators
open Fake.Core
open Fake.Core.Process
open Fake.Core.TargetOperators
open Fake.DotNet.Cli
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.DotNet
open Fake.Core.String
@matthid

This comment has been minimized.

Collaborator

matthid commented Dec 8, 2017

Oh very interesting, thanks for this. maybe this could be a way to get it working...

@baronfel

This comment has been minimized.

Contributor

baronfel commented Dec 8, 2017

As an easy step, you could have paket generate the include scripts for the framework you'll be executing in and load that?

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Dec 9, 2017

After, I don't know we will solve some of the semantic for example, I only open Fake.IO to have this code:

open Fake.IO

Target.Create "Docs.Setup" (fun _ ->
    // Make sure directories exist
    Directory.ensure "./docs/scss/extra/highlight.js/"

    // Copy files from node_modules allow us to manage them via yarn
    Shell.CopyDir "./docs/public/fonts" "./node_modules/font-awesome/fonts" (fun _ -> true)
    Shell.CopyFile "./docs/scss/extra/highlight.js/atom-one-light.css" "./node_modules/highlight.js/styles/atom-one-light.css"
)

If I would open Fake.IO.Directory or Fake.IO.Shell API start be less easy readable IMO. Especially for the ensure function.

I see two solution, change the ensure functio name or perhaps make use of RequireQualifiedAccess to make sure, the API is readable for the end user.

draptik added a commit to draptik/fsharp-playground that referenced this issue Dec 13, 2017

@matthid

This comment has been minimized.

Collaborator

matthid commented Dec 15, 2017

@MangelMaxime Yes opening only Fake.IO is exactly what you should be doing. (this is one of the design goals of FAKE 5). I don't understand what issue you are trying to point out. Please open a new issue as I guess this one is about VSCode IDE support

@matthid

This comment has been minimized.

Collaborator

matthid commented Jan 27, 2018

Ok an initial fix will be part of beta011, we generate intellisense-scripts with the initial run of the script. So the following workflow should work soon:

  • Generate an empty script
  • Add your dependencies
  • run the empty script
  • open the script with VSCode

@matthid matthid closed this Jan 27, 2018

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Feb 21, 2018

@matthid Do you get intellisense when using Ionide and adding #load ".fake/build.fsx/intellisense.fsx" into your build.fsx ?

On my side, i only errors: The namespace or module 'X' is not defined

@matthid

This comment has been minimized.

Collaborator

matthid commented Feb 21, 2018

@MangelMaxime yes it works for me. The only known issue is: You need to use ‘storage:none’ in order for the paths to be correct (this is default for ‘#r “paket: ...”’)

Can you post your example?

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Feb 21, 2018

I am not at work and so can't check the paket.dependencies but I think I didn't set the storage:none option for the Fake group. I will keep you inform tomorrow thanks for the info

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Feb 22, 2018

@matthid Even by using storage:none option it's not working.

Reproduction project

My project can be find here

  1. dotnet restore dotnet-fake.csproj
  2. dotnet fake run build.fsx -t MochaTest
  3. Open build.fsx in Ionide and see if you get intellisense or no.

Machine infos

  • Operating system: Linux
  • Arch: x64
  • VSCode: 1.20.1
  • Runtime: netcore
  • Dotnet version: 2.1.4
intellisense.fsx (click to expand)

// This file is automatically generated by FAKE
// This file is needed for IDE support only
printfn "loading dependencies ..."
#if !FAKE
#r "../../../../../../../../../../.nuget/packages/fake.core.semver/5.0.0-beta018/lib/net46/Fake.Core.SemVer.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.context/5.0.0-beta018/lib/net46/Fake.Core.Context.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.environment/5.0.0-beta018/lib/net46/Fake.Core.Environment.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.globbing/5.0.0-beta018/lib/net46/Fake.Core.Globbing.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.string/5.0.0-beta018/lib/net46/Fake.Core.String.dll" 
#r "../../../../../../../../../../.nuget/packages/system.net.http/4.3.3/lib/net46/System.Net.Http.dll" 
#r "../../../../../../../../../../.nuget/packages/newtonsoft.json/11.0.1/lib/net45/Newtonsoft.Json.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.x509certificates/4.3.2/lib/net461/System.Security.Cryptography.X509Certificates.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.cng/4.4.0/lib/net47/System.Security.Cryptography.Cng.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.csp/4.3.0/lib/net46/System.Security.Cryptography.Csp.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.openssl/4.4.0/lib/netstandard2.0/System.Security.Cryptography.OpenSsl.dll" 
#r "../../../../../../../../../../.nuget/packages/system.componentmodel.typeconverter/4.3.0/lib/net462/System.ComponentModel.TypeConverter.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.algorithms/4.3.1/lib/net463/System.Security.Cryptography.Algorithms.dll" 
#r "../../../../../../../../../../.nuget/packages/system.xml.xmldocument/4.3.0/lib/net46/System.Xml.XmlDocument.dll" 
#r "../../../../../../../../../../.nuget/packages/system.collections.specialized/4.3.0/lib/net46/System.Collections.Specialized.dll" 
#r "../../../../../../../../../../.nuget/packages/system.linq.expressions/4.3.0/lib/net463/System.Linq.Expressions.dll" 
#r "../../../../../../../../../../.nuget/packages/system.runtime.serialization.formatters/4.3.0/lib/net46/System.Runtime.Serialization.Formatters.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.encoding/4.3.0/lib/net46/System.Security.Cryptography.Encoding.dll" 
#r "../../../../../../../../../../.nuget/packages/system.xml.readerwriter/4.3.1/lib/net46/System.Xml.ReaderWriter.dll" 
#r "../../../../../../../../../../.nuget/packages/system.collections.nongeneric/4.3.0/lib/net46/System.Collections.NonGeneric.dll" 
#r "../../../../../../../../../../.nuget/packages/system.componentmodel.primitives/4.3.0/lib/net45/System.ComponentModel.Primitives.dll" 
#r "../../../../../../../../../../.nuget/packages/system.diagnostics.fileversioninfo/4.3.0/lib/net46/System.Diagnostics.FileVersionInfo.dll" 
#r "../../../../../../../../../../.nuget/packages/system.diagnostics.process/4.3.0/lib/net461/System.Diagnostics.Process.dll" 
#r "../../../../../../../../../../.nuget/packages/system.globalization.extensions/4.3.0/lib/net46/System.Globalization.Extensions.dll" 
#r "../../../../../../../../../../.nuget/packages/system.linq/4.3.0/lib/net463/System.Linq.dll" 
#r "../../../../../../../../../../.nuget/packages/system.reflection.typeextensions/4.4.0/lib/net461/System.Reflection.TypeExtensions.dll" 
#r "../../../../../../../../../../.nuget/packages/system.runtime.serialization.primitives/4.3.0/lib/net46/System.Runtime.Serialization.Primitives.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.cryptography.primitives/4.3.0/lib/net46/System.Security.Cryptography.Primitives.dll" 
#r "../../../../../../../../../../.nuget/packages/system.text.regularexpressions/4.3.0/lib/net463/System.Text.RegularExpressions.dll" 
#r "../../../../../../../../../../.nuget/packages/system.diagnostics.diagnosticsource/4.4.1/lib/net46/System.Diagnostics.DiagnosticSource.dll" 
#r "../../../../../../../../../../.nuget/packages/system.runtime.interopservices/4.3.0/lib/net463/System.Runtime.InteropServices.dll" 
#r "../../../../../../../../../../.nuget/packages/system.console/4.3.0/lib/net46/System.Console.dll" 
#r "../../../../../../../../../../.nuget/packages/system.io.filesystem/4.3.0/lib/net46/System.IO.FileSystem.dll" 
#r "../../../../../../../../../../.nuget/packages/system.reflection/4.3.0/lib/net462/System.Reflection.dll" 
#r "../../../../../../../../../../.nuget/packages/microsoft.win32.registry/4.4.0/lib/net461/Microsoft.Win32.Registry.dll" 
#r "../../../../../../../../../../.nuget/packages/system.globalization.calendars/4.3.0/lib/net46/System.Globalization.Calendars.dll" 
#r "../../../../../../../../../../.nuget/packages/system.io/4.3.0/lib/net462/System.IO.dll" 
#r "../../../../../../../../../../.nuget/packages/system.threading.tasks.extensions/4.4.0/lib/netstandard2.0/System.Threading.Tasks.Extensions.dll" 
#r "../../../../../../../../../../.nuget/packages/system.threading.threadpool/4.3.0/lib/net46/System.Threading.ThreadPool.dll" 
#r "../../../../../../../../../../.nuget/packages/microsoft.win32.primitives/4.3.0/lib/net46/Microsoft.Win32.Primitives.dll" 
#r "../../../../../../../../../../.nuget/packages/system.collections.immutable/1.4.0/lib/netstandard2.0/System.Collections.Immutable.dll" 
#r "../../../../../../../../../../.nuget/packages/system.diagnostics.tracing/4.3.0/lib/net462/System.Diagnostics.Tracing.dll" 
#r "../../../../../../../../../../.nuget/packages/system.io.filesystem.primitives/4.3.0/lib/net46/System.IO.FileSystem.Primitives.dll" 
#r "../../../../../../../../../../.nuget/packages/system.runtime.extensions/4.3.0/lib/net462/System.Runtime.Extensions.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.accesscontrol/4.4.1/lib/net461/System.Security.AccessControl.dll" 
#r "../../../../../../../../../../.nuget/packages/system.threading.thread/4.3.0/lib/net46/System.Threading.Thread.dll" 
#r "../../../../../../../../../../.nuget/packages/system.runtime/4.3.0/lib/net462/System.Runtime.dll" 
#r "../../../../../../../../../../.nuget/packages/system.security.principal.windows/4.4.1/lib/net461/System.Security.Principal.Windows.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.releasenotes/5.0.0-beta018/lib/net46/Fake.Core.ReleaseNotes.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.buildserver/5.0.0-beta018/lib/net46/Fake.Core.BuildServer.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.io.filesystem/5.0.0-beta018/lib/net46/Fake.IO.FileSystem.dll" 
#r "../../../../../../../../../../.nuget/packages/system.reflection.metadata/1.5.0/lib/netstandard2.0/System.Reflection.Metadata.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.trace/5.0.0-beta018/lib/net46/Fake.Core.Trace.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.process/5.0.0-beta018/lib/net46/Fake.Core.Process.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.core.target/5.0.0-beta018/lib/net46/Fake.Core.Target.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.dotnet.cli/5.0.0-beta018/lib/net46/Fake.DotNet.Cli.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.dotnet.paket/5.0.0-beta018/lib/net46/Fake.DotNet.Paket.dll" 
#r "../../../../../../../../../../.nuget/packages/fake.tools.git/5.0.0-beta018/lib/net46/Fake.Tools.Git.dll" 
#r "System" 
#r "System.ComponentModel.Composition" 
#r "System.Core" 
#r "System.Runtime.Serialization" 
#r "System.Numerics" 
#r "System.Xml" 
#r "Microsoft.CSharp" 
#r "System.Net.Http" 
#r "System.Configuration" 
#endif

When you spoke about the need to use storage:none I was expecting the path in intellisense.fsx to be absolute path. Because, here they are relative just like when I was not using storage:none.

@matthid

This comment has been minimized.

Collaborator

matthid commented Feb 22, 2018

Are the realtive paths correct? Does it work if you replace with absolute paths and re-open the Editor?

I think something is broken here...

@matthid matthid reopened this Feb 22, 2018

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Feb 22, 2018

Indeed the path is incorrect.

Correct path: ../../../../.nuget/packages/fake.core.semver/5.0.0-beta018/lib/net46/Fake.Core.SemVer.dll

Generatec path: ../../../../../../../../../../.nuget/packages/fake.core.semver/5.0.0-beta018/lib/net46/Fake.Core.SemVer.dll

Both the correct relative path and asbolute path are working.

matthid added a commit to fsprojects/Paket that referenced this issue Feb 25, 2018

fix fsharp/FAKE#1744
1. use absolute paths when storage:none is specified
2. make sure the RootPath is properly evaluated.

matthid added a commit to fsprojects/Paket that referenced this issue Feb 26, 2018

fix fsharp/FAKE#1744
1. use absolute paths when storage:none is specified
2. make sure the RootPath is properly evaluated.

@matthid matthid referenced this issue Feb 26, 2018

Merged

Beta 20 #1801

matthid added a commit that referenced this issue Feb 26, 2018

@matthid

This comment has been minimized.

Collaborator

matthid commented Feb 26, 2018

Basically this should work now in beta020, I don't think FAKE is impacted directly by fsprojects/Paket#3080, just to be safe I'll release beta021 soonish. @MangelMaxime thanks for the feedback and please continue to let me know if things don't work or could be done better :)

@MangelMaxime

This comment has been minimized.

Contributor

MangelMaxime commented Feb 27, 2018

Awesome it's working ❤️

Sure, I will keep using FAKE 5 on some of my project and give feedback if needed and send some PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment