Skip to content

Commit

Permalink
Use Build.fsproj instead of build.fsx
Browse files Browse the repository at this point in the history
  • Loading branch information
theimowski committed Dec 11, 2020
1 parent 03ee2c2 commit af5bc09
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 40 deletions.
6 changes: 4 additions & 2 deletions Content/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ dotnet tool restore
To concurrently run the server and the client components in watch mode use the following command:

```bash
dotnet fsi build.fsx -t run
cd build/Build
dotnet run -- run
```

Then open `http://localhost:8080` in your browser.

To run concurrently server and client tests in watch mode (run in a new terminal):

```bash
dotnet fsi build.fsx -t runtests
cd build/Build
dotnet run -- runtests
```

Client tests are available under `http://localhost:8081` in your browser and server tests are running in watch mode in console.
Expand Down
17 changes: 17 additions & 0 deletions Content/default/SAFE.App.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Server.Tests", "tests\Serve
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Client.Tests", "tests\Client\Client.Tests.fsproj", "{CF8C20AC-1FC4-4114-ACB8-6CE6E51F34F9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{B14E2CEE-C6BD-4CAA-ACDD-0793202FD82E}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "build\Build\Build.fsproj", "{4CB536B9-7324-46D4-B1D3-97D5B295C836}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -116,6 +120,18 @@ Global
{CF8C20AC-1FC4-4114-ACB8-6CE6E51F34F9}.Release|x64.Build.0 = Release|Any CPU
{CF8C20AC-1FC4-4114-ACB8-6CE6E51F34F9}.Release|x86.ActiveCfg = Release|Any CPU
{CF8C20AC-1FC4-4114-ACB8-6CE6E51F34F9}.Release|x86.Build.0 = Release|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Debug|x64.ActiveCfg = Debug|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Debug|x64.Build.0 = Debug|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Debug|x86.ActiveCfg = Debug|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Debug|x86.Build.0 = Debug|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Release|Any CPU.Build.0 = Release|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Release|x64.ActiveCfg = Release|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Release|x64.Build.0 = Release|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Release|x86.ActiveCfg = Release|Any CPU
{4CB536B9-7324-46D4-B1D3-97D5B295C836}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B743B9A7-78C6-4FEB-ADDD-19B27F542340} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
Expand All @@ -124,5 +140,6 @@ Global
{87197987-1524-4E8A-A7CB-4440BD22A395} = {3820D9E8-1B4E-486E-9C46-D52E3784D222}
{9ADB89B5-54DA-4F25-B2D0-013A7FCEFABA} = {3820D9E8-1B4E-486E-9C46-D52E3784D222}
{CF8C20AC-1FC4-4114-ACB8-6CE6E51F34F9} = {3820D9E8-1B4E-486E-9C46-D52E3784D222}
{4CB536B9-7324-46D4-B1D3-97D5B295C836} = {B14E2CEE-C6BD-4CAA-ACDD-0793202FD82E}
EndGlobalSection
EndGlobal
69 changes: 31 additions & 38 deletions Content/default/build.fsx → Content/default/build/Build/Build.fs
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
#r "nuget: System.Reactive"
#r "nuget: Fake.Core.Target,5.20.3"
#r "nuget: Fake.DotNet.Cli"
#r "nuget: Fake.IO.FileSystem"
#r "nuget: Farmer"

open Fake.Core
open Fake.DotNet
open Fake.IO
open Farmer
open Farmer.Builders

match fsi.CommandLineArgs |> Array.toList with
| scriptPath :: args -> scriptPath, args
| args -> "", args
|> fun (scriptPath, args) ->
args
|> Context.FakeExecutionContext.Create false (System.IO.Path.GetFileName scriptPath)
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext

let sharedPath = Path.getFullName "./src/Shared"
let serverPath = Path.getFullName "./src/Server"
let deployDir = Path.getFullName "./deploy"
let sharedTestsPath = Path.getFullName "./tests/Shared"
let serverTestsPath = Path.getFullName "./tests/Server"
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)

let sharedPath = Path.getFullName "../../src/Shared"
let serverPath = Path.getFullName "../../src/Server"
let clientPath = Path.getFullName "../../src/Client"
let deployDir = Path.getFullName "../../deploy"
let sharedTestsPath = Path.getFullName "../../tests/Shared"
let serverTestsPath = Path.getFullName "../../tests/Server"

let npm args workingDir =
let npmPath =
Expand Down Expand Up @@ -56,7 +45,7 @@ Target.create "InstallClient" (fun _ -> npm "install" ".")

Target.create "Bundle" (fun _ ->
dotnet (sprintf "publish -c Release -o \"%s\"" deployDir) serverPath
dotnet "fable --run webpack -p" "src/Client"
dotnet "fable --run webpack -p" clientPath
)

Target.create "Azure" (fun _ ->
Expand All @@ -77,7 +66,7 @@ Target.create "Azure" (fun _ ->
Target.create "Run" (fun _ ->
dotnet "build" sharedPath
[ async { dotnet "watch run" serverPath }
async { dotnet "fable watch --run webpack-dev-server" "src/Client" } ]
async { dotnet "fable watch --run webpack-dev-server" clientPath } ]
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
Expand All @@ -94,19 +83,23 @@ Target.create "RunTests" (fun _ ->

open Fake.Core.TargetOperators

"ToolRestore"
==> "Clean"
==> "InstallClient"
==> "Bundle"
==> "Azure"

"Clean"
==> "InstallClient"
==> "Run"

"Clean"
==> "InstallClient"
==> "RunTests"

Target.runOrDefaultWithArguments "Bundle"

let dependencies = [
"ToolRestore"
==> "Clean"
==> "InstallClient"
==> "Bundle"
==> "Azure"

"Clean"
==> "InstallClient"
==> "Run"

"Clean"
==> "InstallClient"
==> "RunTests"
]

let commandLineArgs = System.Environment.GetCommandLineArgs()
match commandLineArgs with
| [| target |] -> Target.runOrDefault target
| _ -> Target.runOrDefault "Bundle"
10 changes: 10 additions & 0 deletions Content/default/build/Build/Build.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Build.fs" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
4 changes: 4 additions & 0 deletions Content/default/build/Build/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fake.Core.Target
Fake.DotNet.Cli
Fake.IO.FileSystem
Farmer
5 changes: 5 additions & 0 deletions Content/default/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ nuget Fable.Mocha
nuget Fable.React
nuget Fable.Remoting.Client
nuget Fulma

nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Farmer
Loading

0 comments on commit af5bc09

Please sign in to comment.