Skip to content

Commit

Permalink
New project layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Byrd committed Apr 3, 2017
1 parent 29b9a0b commit cfd4700
Show file tree
Hide file tree
Showing 15 changed files with 512 additions and 187 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -152,6 +152,7 @@ PublishScripts/

# NuGet Packages
*.nupkg
packages/
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
Expand Down Expand Up @@ -250,3 +251,7 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml

TestResults.xml

dist/
42 changes: 42 additions & 0 deletions .paket/Paket.Restore.targets
@@ -0,0 +1,42 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Mark that this target file has been loaded. -->
<IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
<!-- Paket command -->
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
</PropertyGroup>

<Target Name="PaketRestore" BeforeTargets="_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" >

<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" ' />

<PropertyGroup>
<PaketReferencesFilePath>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references</PaketReferencesFilePath>
</PropertyGroup>

<ReadLinesFromFile File="$(PaketReferencesFilePath)" >
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>

<ItemGroup Condition=" '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<RestoreConfigFile>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
</PropertyGroup>

</Target>
</Project>
Binary file added .paket/paket.bootstrapper.exe
Binary file not shown.
6 changes: 6 additions & 0 deletions .paket/paket.exe.config
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Prerelease" value="True"/>
</appSettings>
</configuration>
62 changes: 62 additions & 0 deletions .paket/paket.targets
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
</PropertyGroup>

<PropertyGroup>
<!-- Paket command -->
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
</PropertyGroup>

<Choose> <!-- MyProject.fsproj.paket.references has the highest precedence -->
<When Condition="Exists('$(MSBuildProjectFullPath).paket.references')">
<PropertyGroup>
<PaketReferences>$(MSBuildProjectFullPath).paket.references</PaketReferences>
</PropertyGroup>
</When> <!-- MyProject.paket.references -->
<When Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references')">
<PropertyGroup>
<PaketReferences>$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketReferences>
</PropertyGroup>
</When> <!-- paket.references -->
<When Condition="Exists('$(MSBuildProjectDirectory)\paket.references')">
<PropertyGroup>
<PaketReferences>$(MSBuildProjectDirectory)\paket.references</PaketReferences>
</PropertyGroup>
</When> <!-- Set to empty if a reference file isn't found matching one of the 3 format options -->
<Otherwise>
<PropertyGroup>
<PaketReferences></PaketReferences>
</PropertyGroup>
</Otherwise>
</Choose>

<PropertyGroup>
<!-- Commands -->
<PaketReferences Condition="!Exists('$(MSBuildProjectFullPath).paket.references')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketReferences>
<PaketReferences Condition="!Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references')">$(MSBuildProjectDirectory)\paket.references</PaketReferences>
<PaketReferences Condition="!Exists('$(PaketReferences)')">$(MSBuildStartupDirectory)\paket.references</PaketReferences>
<PaketReferences Condition="Exists('$(MSBuildProjectFullPath).paket.references')">$(MSBuildProjectFullPath).paket.references</PaketReferences>
<RestoreCommand>$(PaketCommand) restore --references-files "$(PaketReferences)"</RestoreCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
</PropertyGroup>
<Target Name="RestorePackages">
<Exec Command="$(RestoreCommand)"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(PaketRootPath)"
ContinueOnError="true"
Condition=" Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' "
/>
</Target>
</Project>
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
@@ -0,0 +1,2 @@
#### 0.1.0 - 2.04.2017
* Initial release
101 changes: 101 additions & 0 deletions build.fsx
@@ -0,0 +1,101 @@
#r @"packages/build/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.UserInputHelper
open System

#if MONO
let inferFrameworkPathOverride () =
let mscorlib = "mscorlib.dll"
let possibleFrameworkPaths =
[
"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/"
"/usr/local/Cellar/mono/4.6.12/lib/mono/4.5/"
"/usr/lib/mono/4.5/"
]

possibleFrameworkPaths
|> Seq.find (fun p ->IO.File.Exists(p @@ mscorlib))

Environment.SetEnvironmentVariable("FrameworkPathOverride", inferFrameworkPathOverride ())
#endif
let release = LoadReleaseNotes "RELEASE_NOTES.md"
let srcGlob = "src/**/*.fsproj"
let testsGlob = "tests/**/*.fsproj"

Target "Clean" (fun _ ->
["bin"; "temp" ;"dist"]
|> CleanDirs

!! srcGlob
++ testsGlob
|> Seq.collect(fun p ->
["bin";"obj"]
|> Seq.map(fun sp ->
IO.Path.GetDirectoryName p @@ sp)
)
|> CleanDirs

)

Target "DotnetRestore" (fun _ ->
!! srcGlob
++ testsGlob
|> Seq.iter (fun proj ->
DotNetCli.Restore (fun c ->
{ c with
Project = proj
})
))

Target "DotnetBuild" (fun _ ->
!! srcGlob
|> Seq.iter (fun proj ->
DotNetCli.Build (fun c ->
{ c with
Project = proj
})
))

Target "DotnetTest" (fun _ ->
!! testsGlob
|> Seq.iter (fun proj ->
DotNetCli.Test (fun c ->
{ c with
Project = proj
WorkingDir = IO.Path.GetDirectoryName proj
})
))

Target "DotnetPack" (fun _ ->
!! srcGlob
|> Seq.iter (fun proj ->
DotNetCli.Pack (fun c ->
{ c with
Project = proj
Configuration = "Release"
OutputPath = IO.Directory.GetCurrentDirectory() @@ "dist"
AdditionalArgs = [sprintf "/p:PackageVersion=%s" release.NugetVersion]
})
)
)

Target "Publish" (fun _ ->
Paket.Push(fun c ->
{ c with
PublishUrl = "https://www.nuget.org"
WorkingDir = "dist"
}
)
)

"Clean"
==> "DotnetRestore"
==> "DotnetBuild"
==> "DotnetTest"
==> "DotnetPack"
==> "Publish"

RunTargetOrDefault "DotnetPack"
79 changes: 79 additions & 0 deletions build.sh
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

set -eu

cd "$(dirname "$0")"

PAKET_BOOTSTRAPPER_EXE=.paket/paket.bootstrapper.exe
PAKET_EXE=.paket/paket.exe
FAKE_EXE=packages/build/FAKE/tools/FAKE.exe

FSIARGS=""
FSIARGS2=""
OS=${OS:-"unknown"}

echo $OSTYPE
if [ "$OS" != "Windows_NT" ]
then
# Can't use FSIARGS="--fsiargs -d:MONO" in zsh, so split it up
# (Can't use arrays since dash can't handle them)
FSIARGS="--fsiargs"
FSIARGS2="-d:MONO"
fi

run() {
if [ "$OS" != "Windows_NT" ]
then
mono "$@"
else
"$@"
fi
}

yesno() {
# NOTE: Defaults to NO
read -p "$1 [y/N] " ynresult
case "$ynresult" in
[yY]*) true ;;
*) false ;;
esac
}

set +e
run $PAKET_BOOTSTRAPPER_EXE
bootstrapper_exitcode=$?
set -e

if [ "$OS" != "Windows_NT" ] &&
[ $bootstrapper_exitcode -ne 0 ] &&
[ $(certmgr -list -c Trust | grep X.509 | wc -l) -le 1 ] &&
[ $(certmgr -list -c -m Trust | grep X.509 | wc -l) -le 1 ]
then
echo "Your Mono installation has no trusted SSL root certificates set up."
echo "This may result in the Paket bootstrapper failing to download Paket"
echo "because Github's SSL certificate can't be verified. One way to fix"
echo "this issue would be to download the list of SSL root certificates"
echo "from the Mozilla project by running the following command:"
echo ""
echo " mozroots --import --sync"
echo ""
echo "This will import over 100 SSL root certificates into your Mono"
echo "certificate repository."
echo ""
if yesno "Run 'mozroots --import --sync' now?"
then
mozroots --import --sync
else
echo "Attempting to continue without running mozroots. This might fail."
fi
# Re-run bootstrapper whether or not the user ran mozroots, because maybe
# they fixed the problem in a separate terminal window.
run $PAKET_BOOTSTRAPPER_EXE
fi

run $PAKET_EXE restore

[ ! -e build.fsx ] && run $PAKET_EXE update
[ ! -e build.fsx ] && run $FAKE_EXE init.fsx
run $FAKE_EXE "$@" $FSIARGS $FSIARGS2 build.fsx

17 changes: 14 additions & 3 deletions example/Program.fs
@@ -1,12 +1,23 @@
// Learn more about F# at http://fsharp.org

open System
open Suave
open Suave.Filters
open Suave.Operators
open Suave.Successful

[<EntryPoint>]
let main argv =

if Type.GetType("Mono.Runtime") <> null then
printfn "Hello World from F#! on mono"
printfn "Hello World from F# on mono"
elif Type.GetType("System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader") <> null then
printfn "Hello World from F# on core"
else
printfn "Hello World from F#! on core?"
//Threading.Thread.Sleep(100000)
printfn "Hello World from F# on full"
let app =
choose [
OK "Hello World!"
]
startWebServer defaultConfig app
0 // return an integer exit code
3 changes: 2 additions & 1 deletion example/example.fsproj
Expand Up @@ -7,8 +7,9 @@
<ItemGroup>
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="Suave" Version="2.*"/>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final"/>
<DotNetCliToolReference Include="dotnet-mono" Version="0.1.0-alpha009"/>
<DotNetCliToolReference Include="dotnet-mono" Version="0.1.0-alpha010"/>
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions paket.dependencies
@@ -0,0 +1,5 @@
source https://www.nuget.org/api/v2

group Build
source https://www.nuget.org/api/v2
nuget FAKE
6 changes: 6 additions & 0 deletions paket.lock
@@ -0,0 +1,6 @@


GROUP Build
NUGET
remote: https://www.nuget.org/api/v2
FAKE (4.56)

0 comments on commit cfd4700

Please sign in to comment.