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

Auto-generated program for F# breaks compilation #1924

Closed
rojepp opened this issue Feb 13, 2019 · 3 comments
Closed

Auto-generated program for F# breaks compilation #1924

rojepp opened this issue Feb 13, 2019 · 3 comments
Assignees
Labels

Comments

@rojepp
Copy link

rojepp commented Feb 13, 2019

Description

In #1664, @saul added automatic generation of a main method. This breaks compilation for <OutputType>Exe</OutputType>, as it is generated even if there is already a main method. Compiling then gives the error

error FS0433: A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence.

I ran into this using MiniScaffold template. There, the Test app has a Main.fs, not a Program.fs .
Checking for a hard-coded filename seems like a too weak of a check, and I'd rather have no generation at all (and not have to find out about an obscure switch to turn this magic off.

Because of this magic, this took a really long time to find. Users can be expected to know that there should be a main method in exe programs.

@saul
Copy link
Contributor

saul commented Feb 14, 2019

@rojepp what are you proposing as the solution?

The MiniScaffold template be setting the property to not autogenerate a program, as other templates did when this change was rolled out.

@rojepp
Copy link
Author

rojepp commented Feb 14, 2019

Reading the background issue more thoroughly, I don't have a better option. For reference, the property to set is GenerateProgramFile.

@rojepp rojepp closed this as completed Feb 14, 2019
@saul
Copy link
Contributor

saul commented Feb 14, 2019

@rojepp at a minimum I think the compiler error should be improved (although that will be an issue for Microsoft/visualfsharp). The compiler error should log the file that is the last compile item - that would at least show you where to look.

It may also help if the auto-generated Program.fs had a comment explaining how to disable its generation.

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

No branches or pull requests

4 participants