Skip to content
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

Generate the F# file who contains the main (EntryPoint) based on runtime #1171

Closed
enricosada opened this issue Oct 6, 2017 · 5 comments
Closed

Comments

@enricosada
Copy link

enricosada commented Oct 6, 2017

F# bundle the Program.fs (who contains the main, [<EntryPoint>] in f#), because a test project targeting netcoreapp2.0 is built as exe (so need a main)
But if i switch to net461, the test project is a library, by design, and should include it.

Atm template is going to be changed to conditionally include the Program.fs (ref dotnet/templating#1271 ) to workaround this.

But that's annoying, because all test framework templates need to do so. otherwise bug is subtle (ref dotnet/netcorecli-fsc#79 ).

C# autogenerate the Program.cs needed in the CoreGenerateProgramFile target.

F# should do the same.

Minor notes:

  • need to add the file at end (for f# file order matter, and EntryPoint MUST be the last), so just Compile is not enough (=> require support by f# sdk, like adding CompileLast or CompileMain item)
  • need a property to disable this behaviour. For example the expecto test library, used a lot in F#, configure itself in main, so cannot be autogenerated
  • something to generate the main empty file, obj/{projectName}.Program.fs (in F# sdk or msbuild sdk or here)
  • a feature flag (a property?), so project based on previous template (who add a Program.fs explicit) doesnt break with new sdk version

/cc @dsyme @cartermp @KevinRansom

Environment

dotnet sdk >= 2.0

@ErikSchierboom
Copy link

This would be great to have!

@dsyme
Copy link

dsyme commented Nov 13, 2017

@enricosada Yes indeed!

@ErikSchierboom
Copy link

Is there any plan to work on this?

@saul
Copy link
Contributor

saul commented Jun 29, 2018

Opened #1664 which does this - it's not a lot of work at all.

@ErikSchierboom
Copy link

Love it! Thank a ton @saul!

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

No branches or pull requests

5 participants