Fable: Can't use * in fsproj when building fable libraries

Created on 17 Nov 2019  路  8Comments  路  Source: fable-compiler/Fable

Description

If you do something like <Compile Include="SomeSubDirectory\*.fs" /> when building a library, when a project references that library during compile it will complain that the file SomeSubDirectory\*.fs does not exist. To resolve this I had to explicitly add all files in that directory.

Repro code

Build a fable project that gets packaged into a nupkg that includes a item group property using wildcards. Then try to build a new project with a reference to that library.

For example in my library gave the error, doing this resolved it.

You can see very little changed between tags.

You can try it yourself with the 0.17.1 and 0.17.2 nuget packages.

Expected and actual results

Expected that it resolves the wild card and compiles all of the matching files.
Actual is that it complains that a single file does not exist.

enhancement up-for-grabs

Most helpful comment

@Shmew Maybe you can automatically update the *.fsproj file as part of the generation pipeline, adding all the files that were created one by one?

All 8 comments

Then try to build a new project with a reference to that library.

In this case, Fable doesn't use MSBuild to get the list of files, but parses the project file manually. Other MSBuild features like Conditions won't work as well. The project cracker would need to be extended to support this.

May I suggest to split the package to a pure bindings package without source code and a helper package with an F# friendly API on top of the former one?

That's not really applicable here, unfortunately. the issue is that the bindings are generated, so I don't actually know the exact files that are available until the generator application is run. Which means I need to go remove and re-add them every time I make a change to the generator code. The generator code isn't packaged/included at all.

@Shmew Maybe you can automatically update the *.fsproj file as part of the generation pipeline, adding all the files that were created one by one?

I may do that, but I'm not sure it's worth the time. Is this not an easy feature to implement? It detects the globbing pattern as a single file. If it has a wildcard couldn't you just turn it into a globbing pattern and get everything that matches and collect the new list?

@Shmew How do you control the order of those files, are they independent of each other?

Yes they're all independent of each other.

@Shmew Yes, should be easy enough to extend the ProjectCracker.fs to support wildcards, as @inosik pointed above. Please feel free to contribute a PR, any new contributors are quite welcome. Or in the mean time, @Zaid-Ajaj's solution sounds simple enough too.

Yes, we never thought of adding support for the globbing pattern as it's usually not useful in F#, but it may be in this particular case. It'd be great if you could add the functionality to the ProjectCracker.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MangelMaxime picture MangelMaxime  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

nozzlegear picture nozzlegear  路  3Comments

stkb picture stkb  路  3Comments

forki picture forki  路  3Comments