Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,6 @@ MetricResults/

_configs/
.fake/
.paket/
.paket/
.idea/
.ionide/
6 changes: 2 additions & 4 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
".paket/paket.bootstrapper.exe"
".paket/paket.exe" "restore"

"./packages/FAKE/tools/FAKE.exe" %* "--fsiargs" "build.fsx"
dotnet tool restore
dotnet fake %*
132 changes: 75 additions & 57 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
#r @"packages/FAKE/tools/FakeLib.dll"
open System
open Fake
open Fake.Testing.XUnit2

let testDir = ".test"

let targetName = getBuildParam "target"
trace (sprintf "Target name: %s" targetName)
let targets = ["Ex1Start";"Ex1Done";"Ex2Start";"Ex2Done";"Ex3Start";"Ex3Done";"Ex4Start";"Ex4Start"] |> List.map (fun s -> s.ToLower())

if targets |> List.contains (targetName.ToLower()) |> not then
let targetNames = String.Join("|", targets)
let msg = sprintf "Missing target, use: ./build.sh <%s>" targetNames
targets |> String.concat "|" |> sprintf "Missing target, use: ./build.sh <%s>" |> traceError
exit -1
let (proj,version) = (targetName.Substring(0,3), targetName.Substring(3))
let basePath = sprintf "./%s/%s" proj version

// Add targets so they are found by the Ionide FAKE plugin
Target "Ex1Start" ignore
Target "Ex1Done" ignore
Target "Ex2Start" ignore
Target "Ex2Done" ignore
Target "Ex3Start" ignore
Target "Ex3Done" ignore
Target "Ex4Start" ignore
Target "Ex4Done" ignore

Target "Default" (fun _ ->
trace "Hello default"
)
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.Target //"
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators

Target "RestorePackages" (fun _ ->
let packagesFolder = basePath </> "packages"
!!(basePath </> "**/packages.config")
|> Seq.iter
(RestorePackage (fun parameters ->
{ parameters with
OutputPath = packagesFolder}))
)
Target.initEnvironment ()

Target "Build" (fun _ ->
trace (sprintf "Building %s %s" proj version)
let sln = !! (basePath </> "*.sln")
trace (sprintf "Will build solution: %A" sln)
sln
|> MSBuildDebug "" "Rebuild"
|> ignore
Target.create "Clean" (fun _ ->
!! "./**/bin"
++ "./**/obj"
|> Shell.cleanDirs
)

Target "Test" (fun _ ->
let testDlls = !!(basePath </> "*.Tests/bin/Debug/*.Tests.dll")
testDlls
|> xUnit2 (fun p -> p)
)
let build target =
!! (target + "/*.sln")
|> Seq.iter (DotNet.build id)

let test target =
!! (target + "/*.sln")
|> Seq.iter (DotNet.test id)

let restore target =
!! (target + "/*.sln")
|> Seq.iter (DotNet.restore id)

let buildAndTest (context:TargetParameter) target =
// Trace.log "--- Context ---"
// Trace.log (context.ToString())
// Trace.log "---------------"
let cmd =
if not context.Context.Arguments.IsEmpty then
context.Context.Arguments.Head.ToLower()
else ""
match cmd with
| "test" -> test target
| "restore" -> restore target
| _ -> build target


Target.create "Ex1Start" (fun x -> buildAndTest x "ex1/start")
Target.create "Ex1Done" (fun x -> buildAndTest x "ex1/done")
Target.create "Ex2Start" (fun x -> buildAndTest x "ex2/start")
Target.create "Ex2Done" (fun x -> buildAndTest x "ex2/done")
Target.create "Ex3Start" (fun x -> buildAndTest x "ex3/start")
Target.create "Ex3Done" (fun x -> buildAndTest x "ex3/done")
Target.create "Ex4Start" (fun x -> buildAndTest x "ex4/start")
Target.create "Ex4Done" (fun x -> buildAndTest x "ex4/done")

Target.create "All" ignore

"RestorePackages"
==> "Build"
==> "Test"
==> "Default"
"Clean"
==> "Ex1Start"
"Clean"
==> "Ex1Done"
"Clean"
==> "Ex2Start"
"Clean"
==> "Ex2Done"
"Clean"
==> "Ex3Start"
"Clean"
==> "Ex3Done"
"Clean"
==> "Ex4Start"
"Clean"
==> "Ex4Done"
"Clean"
==> "Ex4Done"==> "Ex4Start"
<=> "Ex3Done" <=> "Ex3Start"
<=> "Ex2Done" <=> "Ex2Start"
<=> "Ex1Done" <=> "Ex1Start"
==> "All"

Run "Default"
Target.runOrDefaultWithArguments "All"
17 changes: 10 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env bash

function run() {
mono "$@"
}
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage:"
echo "build.sh Ex1Start | Ex1Done | Ex2Start | Ex2Done | Ex3Start | Ex3Done | Ex4Start | Ex4Done [test|restore]"
exit 1
fi

run .paket/paket.bootstrapper.exe
run .paket/paket.exe restore
set -eu
set -o pipefail

run ./packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
#run packages/FAKE/tools/FAKE.exe "$@" $FSIARGS build.fsx
dotnet tool restore
dotnet fake build --target "$@"
#dotnet fake "$@"
115 changes: 20 additions & 95 deletions ex1/done/LibAAS.App/LibAAS.App.fsproj
Original file line number Diff line number Diff line change
@@ -1,96 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>9d09871e-2bb3-465f-a040-18c873d2aa13</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>LibAAS.App</RootNamespace>
<AssemblyName>LibAAS.App</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
<Name>LibAAS.App</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Debug\LibAAS.App.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Release\LibAAS.App.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="App.fs" />
<None Include="App.fsx" />
<Compile Include="Program.fs" />
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibAAS.Domain\LibAAS.Domain.fsproj">
<Name>LibAAS.Domain</Name>
<Project>{21160132-ecf3-4e8c-a2e1-7c2c149f9ea8}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\LibAAS.Contracts\LibAAS.Contracts.fsproj">
<Name>LibAAS.Contracts</Name>
<Project>{5c38a911-dcdc-4381-98e9-9f6808788d4a}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\LibAAS.Infrastructure\LibAAS.Infrastructure.fsproj">
<Name>LibAAS.Infrastructure</Name>
<Project>{e0012e26-9a9f-429b-a5f3-e13211c28ca2}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="App.fs" />
<None Include="App.fsx" />
<Compile Include="Program.fs" />
<None Include="App.config" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LibAAS.Contracts\LibAAS.Contracts.fsproj" />
<ProjectReference Include="..\LibAAS.Domain\LibAAS.Domain.fsproj" />
</ItemGroup>

</Project>
90 changes: 15 additions & 75 deletions ex1/done/LibAAS.Contracts/LibAAS.Contracts.fsproj
Original file line number Diff line number Diff line change
@@ -1,75 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>5c38a911-dcdc-4381-98e9-9f6808788d4a</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>LibAAS.Contracts</RootNamespace>
<AssemblyName>LibAAS.Contracts</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Name>LibAAS.Contracts</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\LibAAS.Contracts.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\LibAAS.Contracts.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Types.fs" />
<Compile Include="Commands.fs" />
<Compile Include="Events.fs" />
<None Include="Script.fsx" />
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Types.fs" />
<Compile Include="Commands.fs" />
<Compile Include="Events.fs" />
<None Include="Script.fsx" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion ex1/done/LibAAS.Domain/Inventory.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ let evolveOne (event:EventData) state =
match state with
| _ -> raise (exn "Implement me")

let evolveSeed = {Init = ItemInit; EvolveOne = evolveOne}
let evolveSeed = {Init = ItemInit; EvolveOne = evolveOne}
Loading