GithubHelp home page GithubHelp logo

fsbolero / template Goto Github PK

View Code? Open in Web Editor NEW
66.0 9.0 15.0 297 KB

dotnet cli template to create Bolero applications

F# 73.94% HTML 17.93% Batchfile 0.17% Shell 0.20% CSS 1.19% JavaScript 6.57%

template's Introduction

Bolero Simple Template

Build Nuget

This template can be used as a base to create a Bolero application.

To learn more, you can check the documentation.

Requirements

To get started, you need the following installed:

  • .NET SDK 5.0. Download it here.

Creating a project based on this template

To create a project based on this template, first install the template to your local dotnet:

dotnet new -i Bolero.Templates

Then, you can create a project like so:

dotnet new bolero-app -o YourAppName

This will create a project in a new folder named YourAppName.

Template options

You can use the following options to customize the project being created:

  • Project content options:

    • --minimal, -m:

      If true, the created project is a minimal application skeleton with empty content.

      If false (the default), the created project includes Bolero features such as routed pages, HTML templates and remoting.

    • --server, -s:

      If true (the default), the solution includes a Server project, which is an ASP.NET Core server that hosts the application.

      If false, the solution only contains the Client project that is compiled to WebAssembly.

    • --hostpage, -hp:

      Determines how the server-side HTML page content is written. Can be one of:

      • bolero: using Bolero.Html functions.

      • razor: using a dynamically-compiled Razor page.

      • html: using a plain .html file.

      This is ignored if server=false.

    • --render, -r:

      Determines the render mode. Can be one of:

      This is ignored if server=false. Moreover, the Interactive* render modes are only compatible with hostpage=bolero.

    • --html, -ht:

      If true (the default), use HTML templates.

      If false, use F# functions for HTML content.

      This is ignored if minimal=true, because the minimal project doesn't contain any HTML content.

    • --hotreload, -hr:

      Enable hot reloading for HTML templates.

      The default is true.

      This is ignored if server=false, because hot reloading requires a server side.

    • --pwa, -pwa:

      Create the client side as a progressive web app.

  • Package management options:

    • --paket, -p:

      Use Paket for package management.

    • --nightly, -ni:

      Reference the "nightly" prerelease of Bolero.

      Starting with version 0.18, prereleases are published through GitHub Packages, and therefore require authentication. Make sure that you have set it up before creating your project:

      • Create a GitHub Personal Access Token on this page with permission "read:packages".

      • If you use the default NuGet for package management, add the source with the following command:

        dotnet nuget add source https://nuget.pkg.github.com/fsbolero/index.json -n "Bolero nightly" -u GITHUB_USERNAME -p GITHUB_TOKEN
      • If you use Paket, use the following command instead:

        dotnet paket config add-credentials https://nuget.pkg.github.com/fsbolero/index.json --username GITHUB_USERNAME --password GITHUB_TOKEN

Using this template

Visual Studio Code or Visual Studio is recommended to edit this project.

To compile the project, you can run:

dotnet build

To run it:

dotnet run -p src/YourAppName.Server

# Or if you created the project with --server=false:
dotnet run -p src/YourAppName.Client

Project structure

  • src/YourAppName.Client is the project that gets compiled to WebAssembly, and contains your client-side code.

    • Startup.fs sets up Blazor to get the application started.

    • Main.fs contains the main body of the page.

  • src/YourAppName.Server is the host ASP.NET Core application, and contains your server-side code.

Learn more about Bolero

To learn more about Bolero, you can check the documentation.

template's People

Contributors

adix7 avatar captncodr avatar ctaggart avatar granicz avatar kojo12228 avatar laenas avatar liminiens avatar offline24 avatar pver avatar tarmil avatar xperiandri avatar zakaluka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

template's Issues

Template bolero-app has insecure login / logout features

While I realize a template is not guaranteed to do everything right, the initial results are insecure:

  • With HostModel.defaultIsServer = false, logging out returns to the login form with the username and password filled out correctly.
    image

  • With HostModel.defaultIsServer = true, the SignalR Hub often interferes with typing, and loggin in and/or out fails frequently.
    image

What are recommended approaches for resolving these issues?

OS: Windows 10
Browser: Microsoft Edge (New, based on Chromium)

Bolero.Build.BoleroTask task could not be loaded

Running the following leaves me with this error

dotnet new -i Bolero.Templates
dotnet new bolero-app -o RemoteTest
cd RemoteTest
dotnet build

C:\Users\Dave.nuget\packages\bolero.build\0.2.110\build\Bolero.Build.targets(13,5): error MSB4062: The "Bolero.Build.BoleroTask" task could not be loaded from the assembly C:\Users\Dave.nuget\packages\bolero.build\0.2.110\build..\tools\Bolero.Build.dll. Assembly with same name is already loaded Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:\Users\Dave\Projects\RemoteTest\src\RemoteTest.Client\RemoteTest.Client.fsproj]

I previously had an older version installed, and am running on Windows 10

The project does actually seem to build & run fine however (with the above error being produced at the end of each dotnet build)

bolero-app template using Bolero.dll (0.15.18) throws could not load Elmish 3.1.0.0 dll exception

Cross posting from fsbolero/Bolero#180, as I think this issue belongs in this repo:

Creating a Bolero app from the template with defaults, results in the following error:

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM2Q8PGCGTVF", Request id "0HM2Q8PGCGTVF:00000001": An unhandled exception was thrown by the application.
System.IO.FileLoadException: Could not load file or assembly 'Elmish, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Elmish, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'
...

Get started easily instructions from home page throw on Windows+NetSdk5.0.103

Windows 10 Pro 64-bit
VSCode with msys2 terminal

$ dotnet --version
5.0.103

dotnet new -i Bolero.Templates
dotnet new bolero-app -o MyApp
(cd MyApp; dotnet run -p src/MyApp.Server)

Application startup exception: System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Components.Server.Circuits.CircuitRegistry' while attempting to activate 'Microsoft.AspNetCore.Components.Server.CircuitDisconnectMiddleware'.
   at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_0.<UseMiddleware>b__0(RequestDelegate next)
   at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
   at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints, String path, Action`1 configureOptions)
   at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints, String path)
   at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints)
   at <StartupCode$MyApp-Server>[email protected](IEndpointRouteBuilder endpoints) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 44
   at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
   at MyApp.Server.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 34
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.WebHost[6]
      Application startup exception
      System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Components.Server.Circuits.CircuitRegistry' while attempting to activate 'Microsoft.AspNetCore.Components.Server.CircuitDisconnectMiddleware'.
         at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
         at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
         at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_0.<UseMiddleware>b__0(RequestDelegate next)
         at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
         at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints, String path, Action`1 configureOptions)
         at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints, String path)
         at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints)
         at <StartupCode$MyApp-Server>[email protected](IEndpointRouteBuilder endpoints) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 44
         at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
         at MyApp.Server.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 34
         at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
         at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
         at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
         at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
         at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)       
         at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
         at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Components.Server.Circuits.CircuitRegistry' while attempting to activate 'Microsoft.AspNetCore.Components.Server.CircuitDisconnectMiddleware'.
   at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_0.<UseMiddleware>b__0(RequestDelegate next)
   at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
   at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints, String path, Action`1 configureOptions)
   at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints, String path)
   at Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub(IEndpointRouteBuilder endpoints)
   at <StartupCode$MyApp-Server>[email protected](IEndpointRouteBuilder endpoints) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 44
   at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
   at MyApp.Server.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 34
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at MyApp.Server.Program.main(String[] args) in C:\Users\samuel\Documents\bitbucket\tryouts\fsharp\bolero_hello\MyApp\src\MyApp.Server\Startup.fs:line 52

Unhandled exception

My system

  • KUbuntu 18.04 with dotnet 2.2 installed via the official repository.

My actions

  • dotnet new -i Bolero.Templates
  • dotnet new bolero-app -o Bolero
  • cd Bolero
  • dotnet run -p src/Bolero.Server

The result

Application startup exception: System.ArgumentException: An item with the same key has already been added. Key: .wasm
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.CreateContentTypeProvider(Boolean enableDebugging)
   at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.UseBlazor(IApplicationBuilder app, BlazorOptions options)
   at Bolero.Server.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in /home/user/code/fsharp/Bolero/src/Bolero.Server/Startup.fs:line 25
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
      Application startup exception
System.ArgumentException: An item with the same key has already been added. Key: .wasm
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.CreateContentTypeProvider(Boolean enableDebugging)
   at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.UseBlazor(IApplicationBuilder app, BlazorOptions options)
   at Bolero.Server.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in /home/user/code/fsharp/Bolero/src/Bolero.Server/Startup.fs:line 25
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Unhandled Exception: System.ArgumentException: An item with the same key has already been added. Key: .wasm
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.CreateContentTypeProvider(Boolean enableDebugging)
   at Microsoft.AspNetCore.Builder.BlazorApplicationBuilderExtensions.UseBlazor(IApplicationBuilder app, BlazorOptions options)
   at Bolero.Server.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in /home/user/code/fsharp/Bolero/src/Bolero.Server/Startup.fs:line 25
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at Bolero.Server.Program.main(String[] args) in /home/user/code/fsharp/Bolero/src/Bolero.Server/Startup.fs:line 41

I also tried dotnet new bolero-app -o ADifferentName just in case there were conflicts, but it still doesn't work

Server in debug mode won't start client unless server starts with specific current directory

This is just a tip for what I believe would be an improvement.

The template solution with server has these lines in Startup.fs :

#if DEBUG
            .AddHotReload(templateDir = "../TdWebServer.Client")
#endif

When I try to start the server outside of VS, it's quite natural for me to CD into the server's bin\Debug\netcoreapp3.0 and start the executable there. That won't work because the templateDir is a relative path of the current directory. When run inside VS, the current directory is that of the server project's directory.

IMHO an application must not rely on the current directory for any purpose other than letting a user of a desktop application or command line application navigate disks and directories, and open files the user want to work with. Files and directories that are relative to an application's executable must be located by other means than the current directory. A server should never use the current directory.

I am not that familiar with web programming, and don't know whether it is common practice to use current directory in any way in various web server platforms.

There's also another line that I don't know enough about, but it works :

    let books =
        Path.Combine(env.ContentRootPath, "data/books.json")
        |> File.ReadAllText

I have fixed the problem in my project by setting templateDir as follows. It will then be relative to the executable rather than the current directory. I can then start the server regardless of where my current directory is. The books are also still displayed, so I assume env.ContentRootPath is not relative to the current directory.

#if DEBUG
            .AddHotReload(templateDir = IO.Path.Combine(AppContext.BaseDirectory, "../../../../TdWebServer.Client"))
#endif

mismatch between project path created and used in solution file

I just created a folder with dashes in it on linux named some-name. Then ran dotnet new bolero-app. The solution file created contained the following:

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{87F6C079-CBD7-4866-BDEB-CBDEA9E51D2A}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "some_name.Server", "src\some_name.Server\some_name.Server.fsproj", "{4E2AA925-4694-4593-ADBC-F349D269587A}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "some_name.Client", "src\some_name.Client\some_name.Client.fsproj", "{1481BBD6-A6DA-4912-A03A-134880D14701}"
EndProject

on disk this file structure was created:

some-name.Client.sln
src/some-name.Client/some-name.Client.fsproj
src/some-name.Server/some-name.Server.fsproj

Note the backslash instead of forward slash and the underscore instead of hyphen inside the solution file.

Bolero 0.5 default template application won't do logon

I am using VS 2019 v 16.1.2. I have installed .NET Core 3.0 SDK v 3.0.100-preview5. I have installed the Bolero 0.5 template and created an application as described on the Getting started page.

The application seems to work just fine until I try to logon in the "Download data" page with a username and the password "password". There is no response when I click on the "Sign in" button.

This is from the output pane in VS 2019. I have included irrelevant repeating group of lines before and after the interesting part.

BoleroSpike2.Client>       Request starting HTTP/1.1 GET http://localhost:7982/favicon.ico  
BoleroSpike2.Client> info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[6]
BoleroSpike2.Client>       The file /index.html was not modified
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 6.125ms 304 text/html
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
BoleroSpike2.Client>       Request starting HTTP/1.1 GET http://localhost:7982/bolero-reload  
BoleroSpike2.Client> info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
BoleroSpike2.Client>       Sending file. Request path: '/index.html'. Physical path: 'C:\devbox\BoleroSpike2\src\BoleroSpike2.Client\wwwroot\index.html'
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 5.397600000000001ms 200 text/html
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
BoleroSpike2.Client>       Request starting HTTP/1.1 GET http://localhost:7982/favicon.ico  
BoleroSpike2.Client> info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[6]
BoleroSpike2.Client>       The file /index.html was not modified
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 4.3846ms 304 text/html
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
BoleroSpike2.Client>       Request starting HTTP/1.1 GET http://localhost:7982/bolero-reload  
BoleroSpike2.Client> info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
BoleroSpike2.Client>       Sending file. Request path: '/index.html'. Physical path: 'C:\devbox\BoleroSpike2\src\BoleroSpike2.Client\wwwroot\index.html'
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 6.0196000000000005ms 200 text/html
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
BoleroSpike2.Client>       Request starting HTTP/1.1 POST http://localhost:7982/books/signIn application/json; charset=utf-8 18
BoleroSpike2.Client> fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
BoleroSpike2.Client>       An unhandled exception has occurred while executing the request.
BoleroSpike2.Client> System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request.
BoleroSpike2.Client> 
BoleroSpike2.Client>    at Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware.<>c__DisplayClass0_0.<Attach>b__1(HttpContext context, Func`1 next)
BoleroSpike2.Client>    at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
BoleroSpike2.Client>    at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
BoleroSpike2.Client>    at Microsoft.AspNetCore.Builder.AutoRebuildExtensions.<>c__DisplayClass4_0.<<UseDevServerAutoRebuild>b__1>d.MoveNext()
BoleroSpike2.Client> --- End of stack trace from previous location where exception was thrown ---
BoleroSpike2.Client>    at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
BoleroSpike2.Client>    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 5.4442ms 500 text/plain
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
BoleroSpike2.Client>       Request starting HTTP/1.1 GET http://localhost:7982/bolero-reload  
BoleroSpike2.Client> info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
BoleroSpike2.Client>       Sending file. Request path: '/index.html'. Physical path: 'C:\devbox\BoleroSpike2\src\BoleroSpike2.Client\wwwroot\index.html'
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 5.0561ms 200 text/html
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
BoleroSpike2.Client>       Request starting HTTP/1.1 GET http://localhost:7982/bolero-reload  
BoleroSpike2.Client> info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
BoleroSpike2.Client>       Sending file. Request path: '/index.html'. Physical path: 'C:\devbox\BoleroSpike2\src\BoleroSpike2.Client\wwwroot\index.html'
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
BoleroSpike2.Client>       Request finished in 6.0516000000000005ms 200 text/html
BoleroSpike2.Client> info: Microsoft.AspNetCore.Hosting.Diagnostics[1]

Paket bootstrap fails when switching OSes

I edit my repo from Windows and also from Ubuntu. When I try to build after switching OS, paket.bootstrapper.proj tries to install paket but dotnet tells it already exists. I modified paket.bootstrapper.proj so no it's working. You can add to the repo if you will.

<Project ToolsVersion="15.0">

    <Import Project="$(MSBuildThisFileDirectory)paket.bootstrapper.props" Condition="Exists('$(MSBuildThisFileDirectory)paket.bootstrapper.props')" />

    <PropertyGroup>
        <RepoRoot>$(MSBuildThisFileDirectory.TrimEnd('\\').TrimEnd('/'))</RepoRoot>

        <PaketBootstrapperExeWin>$(RepoRoot)\paket.bootstrapper.exe</PaketBootstrapperExeWin>
        <PaketBootstrapperExeNonWin>$(RepoRoot)/paket.bootstrapper</PaketBootstrapperExeNonWin>
        <PaketBootstrapperExe>$(PaketBootstrapperExeWin)</PaketBootstrapperExe>
        <PaketBootstrapperExe Condition=" '$(OS)' != 'Windows_NT' ">$(PaketBootstrapperExeNonWin)</PaketBootstrapperExe>

        <PaketExeWin>$(RepoRoot)\paket.exe</PaketExeWin>
        <PaketExeNonWin>$(RepoRoot)/paket</PaketExeNonWin>
        <PaketExe>$(PaketExeWin)</PaketExe>
        <PaketExe Condition=" '$(OS)' != 'Windows_NT' ">$(PaketExeNonWin)</PaketExe>
    </PropertyGroup>

    <Target Name="RemoveWinPaket" Condition=" '$(OS)' != 'Windows_NT' ">
        <Message Text='Removing Windows version of paket' Importance="High"/>
        <RemoveDir Directories="$(RepoRoot)/.store" />
        <Delete Files='$(PaketBootstrapperExeWin)' />
        <Delete Files='$(PaketExeWin)' />
    </Target>

    <Target Name="RemoveNonWinPaket" Condition=" '$(OS)' == 'Windows_NT' ">
        <Message Text='Removing non Windows version of paket' Importance="High"/>
        <RemoveDir Directories="$(RepoRoot)/.store" />
        <Delete Files='$(PaketBootstrapperExeNonWin)' />
        <Delete Files='$(PaketExeNonWin)' />
    </Target>

    <Target Name="RemoveOtherOSsPaket" DependsOnTargets="RemoveWinPaket;RemoveNonWinPaket">
    </Target>

    <Target Name="InstallPaketBootstrapper" DependsOnTargets="RemoveOtherOSsPaket" Condition="Exists('$(PaketBootstrapperExe)') == false">
        <Message Text='Installing paket.bootstrapper' Importance="High"/>
        <PropertyGroup>
            <InstallBootstrapperCommand>dotnet tool install paket.bootstrapper --tool-path "$(RepoRoot)"</InstallBootstrapperCommand>
            <InstallBootstrapperCommand Condition=" '$(PaketBootstrapperVersion)' != '' ">$(InstallBootstrapperCommand) --version "[$(PaketBootstrapperVersion)]"</InstallBootstrapperCommand>
            <InstallBootstrapperCommand Condition=" '$(PaketBootstrapperFeed)' != '' ">$(InstallBootstrapperCommand) --add-source "$(PaketBootstrapperFeed)"</InstallBootstrapperCommand>
            <InstallBootstrapperCommand Condition=" '$(InstallBootstrapperOtherArgs)' != '' ">$(InstallBootstrapperCommand) $(InstallBootstrapperOtherArgs)"</InstallBootstrapperCommand>
        </PropertyGroup>
        <Exec Command="$(InstallBootstrapperCommand)" WorkingDirectory="$(RepoRoot)" />
    </Target>

    <Target Name="InstallPaket" DependsOnTargets="InstallPaketBootstrapper" Condition="Exists('$(PaketExe)') == false">
        <Message Text='Running paket.bootstrapper to install paket' Importance="High"/>
        <PropertyGroup>
            <RunBootstrapperCommand>$(PaketBootstrapperExe) --as-tool --output-dir=$(RepoRoot)</RunBootstrapperCommand>
            <RunBootstrapperCommand Condition=" Exists('$(RepoRoot)\paket.bootstrapper.exe.config') ">$(RunBootstrapperCommand) --config-file=$(RepoRoot)/paket.bootstrapper.exe.config</RunBootstrapperCommand>
            <RunBootstrapperCommand Condition=" '$(RunBootstrapperOtherArgs)' != '' ">$(RunBootstrapperCommand) $(RunBootstrapperOtherArgs)</RunBootstrapperCommand>
        </PropertyGroup>
        <Exec Command='$(RunBootstrapperCommand)' WorkingDirectory="$(RepoRoot)" />
    </Target>

    <Target Name="Restore" DependsOnTargets="InstallPaket">
        <Message Text='Paket ready, checking version:' Importance="High"/>
        <Exec Command='$(PaketExe) --version' WorkingDirectory="$(RepoRoot)" />
    </Target>

    <Import Project="$(MSBuildThisFileDirectory)paket.bootstrapper.targets" Condition="Exists('$(MSBuildThisFileDirectory)paket.bootstrapper.targets')" />

</Project>

Ahead-of-time (AOT) compilation option needed

From .NET 6.0, Ahead-of-time (AOT) compilation is supported.

Blazor WebAssembly supports ahead-of-time (AOT) compilation, where you can compile your .NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size.

https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#ahead-of-time-aot-compilation

Currently, I manually add the below to *.fspoj file, but I think it's very nice of Bolero Template to have the option to select true/false:

<PropertyGroup>
  <RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>

Thanks for your work!

PS. I see .README.md is outdated for .NET SDK 5.0.

Target "_ResolveCssScopes" does not exist (dotnet 8.0.0-rc2)

Error

I created a new project from the template and tried to run the server. It gave me this error:

Bolero.Build.targets(21,41): Error MSB4057 : The target "_ResolveCssScopes" does not exist in the project.

Setup

dotnet new -i Bolero.Templates

Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.100-rc.2.23502.2
...snip...
Success: Bolero.Templates::0.22.7 installed the following templates:
Template Name              Short Name  Language  Tags
-------------------------  ----------  --------  -----------------
Bolero Hosted Application  bolero-app  F#        Web/Blazor/Bolero

Create project

dotnet new bolero-app -o Baffo

Run project

PS C:\Users\...\code\baffo-fs> dotnet run --project ./src/Baffo.Server
C:\Users\...\.nuget\packages\bolero.build\0.22.45\build\Bolero.Build.targets(21,41): error MSB4057: The target "_ResolveCssScopes" does not exist 

Build targets file

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <PropertyGroup Condition="'$(BoleroTaskAssemblyPath)' == ''">
    <BoleroTaskAssemblyPath>$(MSBuildThisFileDirectory)..\tools\Bolero.Build.dll</BoleroTaskAssemblyPath>
    <ProduceReferenceAssembly>false</ProduceReferenceAssembly><!-- See https://github.com/fsbolero/Bolero/issues/279 -->
  </PropertyGroup>
  <PropertyGroup>
    <_BoleroScopedCssSourceFile>$(BaseIntermediateOutputPath)CssScopes.fs</_BoleroScopedCssSourceFile>
  </PropertyGroup>

  <UsingTask AssemblyFile="$(BoleroTaskAssemblyPath)" TaskName="Bolero.Build.BoleroStripFSharpMetadata"
             Condition="'$(BoleroStripAssemblies)' != 'False'" />
  <UsingTask AssemblyFile="$(BoleroTaskAssemblyPath)" TaskName="Bolero.Build.BoleroApplyCssScopes" />

  <!-- Strip F# metadata embedded files -->
  <Target Name="_BoleroStripFSharpMetadata" AfterTargets="ILLink" Condition="'$(BoleroStripAssemblies)' != 'False'">
    <BoleroStripFSharpMetadata AssembliesDir="$(IntermediateLinkDir)" ReferencePath="@(ManagedAssemblyToLink)" />
  </Target>

  <!-- Generate the CSS Scope identifier for *.bolero.css -->
  <Target Name="_BoleroComputeCssScope" DependsOnTargets="_ResolveCssScopes">
    <ComputeCssScope ScopedCssInput="@(BoleroScopedCss)" Targetname="$(TargetName)">
      <Output TaskParameter="ScopedCss" ItemName="_BoleroScopedCss" />
    </ComputeCssScope>
  </Target>

  <!-- Generate CssScopes.fs and add *.bolero.css to Razor's _ScopedCss -->
  <Target Name="_BoleroApplyCssScopes" DependsOnTargets="_BoleroComputeCssScope" BeforeTargets="_ResolveScopedCssOutputs;CoreCompile"
          Inputs="@(_BoleroScopedCss);$(MSBuildThisFileFullPath)" Outputs="$(_BoleroScopedCssSourceFile)">
    <BoleroApplyCssScopes ScopedCss="@(_BoleroScopedCss)" ScopedCssSourceFile="$(_BoleroScopedCssSourceFile)" />
    <ItemGroup>
      <CompileBefore Include="$(_BoleroScopedCssSourceFile)" />
      <_ScopedCss Include="@(_BoleroScopedCss)" />
    </ItemGroup>
  </Target>
</Project>

The offending line is <Target Name="_BoleroComputeCssScope" DependsOnTargets="_ResolveCssScopes">. I see no other reference to _ResolveCssScopes.

Using --paket when paket is not installed as a global tool results in an error...

that looks like this:

Running command 'dotnet paket convert-from-nuget --force'...
Command failed.
Output from command:
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-paket does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

This can easily be fixed by altering the template to install paket as a local tool inside the solution (i.e. .config/dotnet-tools.json); which is also a better choice than globally installed tools in general. I don't know how dotnet templates work or I'd submit a PR.

Version 0.14.13 does not seem to work

When I create a new project with from version 0.14.13 of Bolero.Templates the project is not working. I get the error below:

image

I reverted the templates back to Version 0.13.6. This is working fine.

use NuGet PackageReferences by default for Bolero.Templates

When getting started at https://fsbolero.io/ dotnet new -i Bolero.Templates creates a project that requires paket. I don't use paket any more and strongly prefer working with the build in NuGet package references. It supports transitive dependencies. It supports locking with the latest version as well. It works better with other dotnet tooling like dotnet publish and friends.

I'm creating this issue because I'm not the only one that hit this stumbling block: https://fsharp.slack.com/archives/C10DLSHQV/p1557920194474300

Although I'd prefer to see this project use NuGet packages as well, this request is for the templates, not quite the same as fsbolero/Bolero#43 .

Add a test that actually runs the application

The tests for the project template currently checks that all combinations of options build properly. We should add Selenium tests to also check that they (or at least some of the combinations) also run properly.

Why is camelCasing being used for the record fields in the Elmish model?

I have just started playing around with Belero and immediately, I noticed that the Model in the no-server template uses camelCasing for its records. Is there any particular reason for this? Please see the snippet of code below.

/// The Elmish application's model.
type Model =
    {
        page: Page
        counter: int
        books: Book[] option
        error: string option
    }

and Book =
    {
        title: string
        author: string
        publishDate: DateTime
        isbn: string
    }

let initModel =
    {
        page = Home
        counter = 0
        books = None
        error = None
    }

Test by instantiating with dotnet new

The current build -t test-build compiles the solution within the content folder, rather than instantiating with dotnet new and building the resulting project. The problem is that:

  1. It doesn't properly test the different variants (with or without server).
  2. It doesn't properly test whether template.json creates the correct files.

Question: Better way to handle linq expression for Blazor component?

Working with AntDesign Table.... In Blazor a table can be defined as:

<Table @ref="table"
       TItem="Ak"
       DataSource="@forecasts"
>
  <Selection Key="@(context.Id.ToString())" />
  <PropertyColumn Property="c=>c.Id" />
</Table>

In Bolero, the following seems to work but wondering if there is an better way:

open System.Linq.Expressions
open FSharp.Linq.RuntimeHelpers

let (idExpr:Expression<Func<Ak,int>>) = LeafExpressionConverter.QuotationToLambdaExpression <@ Func<Ak,int>(fun (o:Ak) -> o.Id) @>

let alarmGrid (alarms:Ak[]) : Node  =    
    comp<Table<Ak>> { 
        "DataSource" => ResizeArray(alarms) 
        "PageSize" => 25
        
        attr.fragmentWith "ChildContent" <| fun (context: Ak) ->
            concat {
                comp<Selection> {"Key" => "@(context.Id.ToString()"}
                comp<PropertyColumn<Ak,int>> {
                    "Property" => idExpr
                }
            }
    }

Setting the value of 'Property' on 'PropertyColumn' requires an explicit conversion to a Linq Expression. I would have preferred to use a simple lambda, as in:

comp<PropertColumn<Ak,int>> {
   "Property" => (fun (o:Ak) -> o.Id)
}

But the above gives me a cast expression error at runtime.

PWA support

Hello,

This is a continuation of a conversation on the F# slack regarding PWA support for FSBolero.

I created 2 minimal projects with Blazor to understand the difference between templates with the PWA option -p enabled and disabled. Here is the diff output from comparing the two directories:

--- ~/t ยป diff --color --recursive nopwa pwa
diff --color --recursive nopwa/Properties/launchSettings.json pwa/Properties/launchSettings.json
6,7c6,7
<       "applicationUrl": "http://localhost:45259",
<       "sslPort": 44309
---
>       "applicationUrl": "http://localhost:20322",
>       "sslPort": 44320
diff --color --recursive nopwa/pwa.csproj pwa/pwa.csproj
5a6
>     <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
12a14,17
>   </ItemGroup>
> 
>   <ItemGroup>
>     <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
Only in pwa/wwwroot: icon-512.png
diff --color --recursive nopwa/wwwroot/index.html pwa/wwwroot/index.html
10a11,12
>     <link href="manifest.json" rel="manifest" />
>     <link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
21a24
>     <script>navigator.serviceWorker.register('service-worker.js');</script>
Only in pwa/wwwroot: manifest.json
Only in pwa/wwwroot: service-worker.js
Only in pwa/wwwroot: service-worker.published.js

--server=false results in mismatch

If the template switch -s=false or --server=false like:
dotnet new bolero-app -o BoleroNoServer -s=false
is used, the resulting solution still has the project files for the .Server in the folder.

The Server project is not in the .sln file, so it does not show in VS.

The Client Main.fs file also contains:
#if DEBUG
|> Program.withHotReload
#endif

and the Book Service items as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.