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

fly launch does not recognize an F# project #4021

Open
AngelMunoz opened this issue Oct 22, 2024 · 0 comments
Open

fly launch does not recognize an F# project #4021

AngelMunoz opened this issue Oct 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@AngelMunoz
Copy link

AngelMunoz commented Oct 22, 2024

Please only report specific issues with flyctl behavior. Anything like a support request for your application should go to https://community.fly.io. More people watch that space and can help you faster!

Describe the bug

F# web applications are not recognized as a .NET project even though they use the same tooling and build system as a C# application.

I followed the instructions given here https://fly.io/docs/languages-and-frameworks/dotnet/ but with the exception of using an F# project (.fsproj) rather than a C# project (.csproj)

  • Operating system: Windows 11 26100.2033
  • fly version: fly.exe v0.3.25 windows/amd64 Commit: 8fb314c BuildDate: 2024-10-21T16:49:16Z

** Command output: **

PS X:\> dotnet new web -lang F# -o Sample
The template "ASP.NET Core Empty" was created successfully.

Processing post-creation actions...
Restoring X:\Sample\Sample.fsproj:
  Determining projects to restore...
  Restored X:\Sample\Sample.fsproj (in 1.23 sec).
Restore succeeded.
PS X:\> cd Sample
PS X:\sample> dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5214
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: X:\sample
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
PS X:\sample> fly launch
Scanning source code
Could not find a Dockerfile, nor detect a runtime or framework from source code. Continuing with a blank app.
Warning: This organization has no payment method, turning off high availability
Creating app in X:\sample
We're about to launch your app on Fly.io. Here's what you're getting:

Organization: **************          (fly launch defaults to the personal org)
Name:         *************           (generated)
Region:       Stockholm, Sweden       (this is the fastest region for you)
App Machines: shared-cpu-1x, 1GB RAM  (most apps need about 1GB of RAM)
Postgres:     <none>                  (not requested)
Redis:        <none>                  (not requested)
Tigris:       <none>                  (not requested)
? Do you want to tweak these settings before proceeding? No
Warning: This organization has no payment method, turning off high availability
Created app '************' in organization 'personal'
Admin URL: ********
Hostname: *******
Wrote config file fly.toml
PS X:\sample>

Running the same with a C# project works as expected

PS X:\> dotnet new web -o Sample2
The template "ASP.NET Core Empty" was created successfully.

Processing post-creation actions...
Restoring X:\Sample2\Sample2.csproj:
  Determining projects to restore...
  Restored X:\Sample2\Sample2.csproj (in 144 ms).
Restore succeeded.


PS X:\> cd Sample2
PS X:\Sample2> dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5137
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: X:\Sample2
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
PS X:\Sample2> fly launch
Scanning source code
Detected a .NET app
Warning: This organization has no payment method, turning off high availability
Creating app in X:\Sample2
We're about to launch your .NET app on Fly.io. Here's what you're getting:

Organization: *********         (fly launch defaults to the personal org)
Name:         ********* (generated)
Region:       Stockholm, Sweden      (this is the fastest region for you)
App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM)
Postgres:     <none>                 (not requested)
Redis:        <none>                 (not requested)
Tigris:       <none>                 (not requested)

? Do you want to tweak these settings before proceeding? No
Warning: This organization has no payment method, turning off high availability
Created app '*********' in organization 'personal'
Admin URL: ***********
Hostname: ***********
Wrote config file fly.toml
Validating X:\Sample2\fly.toml
✓ Configuration is valid
==> Building image

The culprit likely is in this file here:

flyctl/scanner/dotnet.go

Lines 12 to 14 in 8fb314c

if !checksPass(sourceDir, dirContains("*.csproj", "Microsoft.NET.Sdk.Web")) {
return nil, nil
}

and

flyctl/scanner/dotnet.go

Lines 60 to 64 in 8fb314c

if !info.IsDir() && filepath.Ext(path) == ".csproj" {
csprojName = strings.TrimSuffix(info.Name(), ".csproj")
csprojPath = path
return filepath.SkipDir // Stop walking the directory
}

where it is checking explicitly for *.csproj, both C# and F# (and even VB.NET) share the same file format and contents in the project files to truly support .NET apps (and not just C#) the glob/regex expresion should check for any of the *.fsproj, *.csproj (and even *.vbproj should work tbh same tooling) file formats instead as copying the files generated for the C# project in the F# project and then running fly deploy works as expected

@AngelMunoz AngelMunoz added the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant