- Setup PAKET and add FAKE dependency
- set up F# project
- create script (add references)
- defined targets
Helpers:
Helpers:
REM Using NuGet instead of PAKET | |
@echo off | |
cls | |
REM build <target> | |
".\.nuget\NuGet.exe" update -self | |
".\.nuget\NuGet.exe" "Install" "FAKE" "-OutputDirectory" "tools" "-ExcludeVersion" | |
SET TARGET="Default" | |
SET SCRIPT="build\scripts\Targets.fsx" | |
IF NOT [%1]==[] (set TARGET="%1") | |
ECHO starting build using target=%TARGET% | |
"tools\FAKE\tools\Fake.exe" "%SCRIPT%" "target=%TARGET%" |
@echo off | |
cls | |
REM build <target> | |
.paket\paket.bootstrapper.exe | |
if errorlevel 1 ( | |
exit /b %errorlevel% | |
) | |
.paket\paket.exe restore | |
if errorlevel 1 ( | |
exit /b %errorlevel% | |
) | |
SET TARGET="Testing" | |
SET SCRIPT="build\scripts\Targets.fsx" | |
IF NOT [%1]==[] (set TARGET="%1") | |
ECHO starting build using target=%TARGET% | |
"packages\build\FAKE\tools\Fake.exe" "%SCRIPT%" "target=%TARGET%" |
#!/usr/bin/env bash | |
FAKE="packages/build/FAKE/tools/FAKE.exe" | |
BUILDSCRIPT="build/scripts/Targets.fsx" | |
mono .paket/paket.bootstrapper.exe | |
if [[ -f .paket.lock ]]; then mono .paket/paket.exe restore; fi | |
if [[ ! -f .paket.lock ]]; then mono .paket/paket.exe install; fi | |
mono $FAKE $@ --fsiargs -d:MONO $BUILDSCRIPT "cmdline=$@" |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
open Fake | |
module Settings = | |
//get current directory: __SOURCE_DIRECTORY__ | |
let public CleanBinFolders = | |
!! "./**/bin" | |
-- "./src/**/Tools/**/bin" | |
let public CleanObjFolders = | |
!! "./**/obj" | |
-- "./src/**/Tools/**/obj" | |
let public NuGetPackagesConfigFilesList = | |
!! "./**/packages.config" | |
-- "./**/Tools/*.config" | |
let public NuGetSourcesList = [ | |
"https://api.nuget.org/v3/index.json" | |
"https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" | |
"https://dotnet.myget.org/F/cli-deps/api/v3/index.json" | |
] | |
let public SolutionFile = !! "./MySolution.sln" | |
let public TestLibraries = | |
!! "./src/**/bin/**/*Test*.dll" | |
-- "./src/**/Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll" | |
-- "./src/**/Microsoft.*.Testing.dll" | |
-- "./src/Tools/**/*.dll" | |
let public NUnitPath = "./tools/NUnit-2.6.4/" | |
let public NUnit3Path = "./tools/NUnit.Console-3.6.1/nunit3-console.exe" |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
#load "Settings.fsx" | |
open Fake | |
open Settings | |
Target "Clean" <| fun _ -> | |
try | |
trace "Cleaning 'bin' folders..." | |
CleanDirs Settings.CleanBinFolders | |
trace "Cleaning 'obj' folders..." | |
CleanDirs Settings.CleanObjFolders | |
with | |
| ex -> | |
trace ex.Message | |
() |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
#load "Settings.fsx" | |
open Fake | |
open Settings | |
Target "RestorePackages" <| fun _ -> | |
trace "Restoring NuGet packages..." | |
// RestorePackages() // alternative to run accross all packages.config within Basecone sub folders. | |
try | |
Settings.NuGetPackagesConfigFilesList | |
|> Seq.iter (RestorePackage (fun p -> | |
{ p with Sources = Settings.NuGetSourcesList } ) | |
) | |
with | |
| ex -> | |
trace ex.Message | |
() |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
#load "Settings.fsx" | |
open Fake | |
open Settings | |
Target "Build" (fun _ -> | |
trace ("Building solution: " + Settings.SolutionFile.ToString()) | |
Settings.SolutionFile | |
|> MSBuild "" "Build" | |
[ | |
"Configuration", "Debug" | |
"Platform", "Any CPU" | |
] | |
|> Log "Build-Output: " | |
) |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
#load "Settings.fsx" | |
open System.IO | |
open Fake | |
open Fake.NUnitCommon | |
open Settings | |
Target "RunTests" (fun _ -> | |
Seq.iter trace Settings.TestLibraries // print DLLs that match pattern | |
for unitTestDll in Settings.TestLibraries do | |
let workingDir = Path.GetDirectoryName(unitTestDll) | |
let assemblies = seq { yield unitTestDll } | |
NUnit (fun p -> | |
{ p with | |
// check http://fake.build/apidocs/fake-testing-nunit3.html for more parameters | |
// check http://fake.build/apidocs/fake-nunitcommon-nunitparams.html for more parameters | |
ToolPath = Settings.NUnitPath | |
ToolName = "nunit-console-x86.exe" | |
StopOnError = true | |
DisableShadowCopy = true | |
WorkingDir = workingDir | |
}) assemblies | |
) |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
#load "Settings.fsx" | |
open Fake | |
open Fake.NuGet | |
open Settings | |
Target "PublishPackages" <| fun _ -> | |
trace "To Do: Publish packages..." | |
// check https://fake.build/apidocs/fake-nugethelper.html | |
// NuGetPublish (fun nugetParams -> | |
// { nugetParams with | |
// AccessKey = "nuget_api_key" | |
// PublishUrl = "nuget_feed_url" | |
// Project = "project_name" | |
// Version = "project_version" | |
// WorkingDir = "nupkg_file_location" | |
// } | |
// ) |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
open Fake | |
open Fake.OctoTools | |
Target "Release" <| fun _ -> | |
trace "To Do: Trigger Deploy to XPTO environment..." | |
// check http://fake.build/apidocs/fake-octotools.html | |
// let release = { releaseOptions with Project = "My Web Service" } | |
// let deploy = { deployOptions with DeployTo = "TestEnv" } | |
// Octo (fun octoParams -> | |
// { octoParams with | |
// ToolPath = "./packages/octopustools"; | |
// Server = { Server = "http://octopus.com/api"; ApiKey = "YOUR-CI-API-KEY-HERE" }; | |
// Command = CreateRelease (release, Some deploy); } | |
// ) |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
#load @"Settings.fsx" | |
#load @"Clean.fsx" | |
#load @"RestorePackages.fsx" | |
#load @"Build.fsx" | |
#load @"RunTests.fsx" | |
#load @"PublishPackages.fsx" | |
#load @"Release.fsx" | |
open Fake | |
Target "Default" (fun _ -> | |
trace "Starting targets..." | |
) | |
"Clean" ==> "RestorePackages" ==> "Build" ==> "RunTests" ==> "PublishPackages" ==> "Release" | |
"RunTests" ==> "Default" // Set default Target | |
RunTargetOrDefault "Default" |
<?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>5dd3f544-6c7e-40c4-9523-1876b9d35f1c</ProjectGuid> | |
<OutputType>Exe</OutputType> | |
<RootNamespace>Scripts</RootNamespace> | |
<AssemblyName>Scripts</AssemblyName> | |
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> | |
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion> | |
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |
<Name>Scripts</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\Scripts.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\Scripts.XML</DocumentationFile> | |
<Prefer32Bit>true</Prefer32Bit> | |
</PropertyGroup> | |
<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)" /> | |
<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" /> | |
</ItemGroup> | |
<ItemGroup> | |
<None Include="Settings.fsx" /> | |
<None Include="Clean.fsx" /> | |
<None Include="RestorePackages.fsx" /> | |
<None Include="Build.fsx" /> | |
<None Include="RunTests.fsx" /> | |
<None Include="PublishPackages.fsx" /> | |
<None Include="Release.fsx" /> | |
<None Include="Targets.fsx" /> | |
</ItemGroup> | |
<!-- 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> |
// A FAKE extension module for working with FSX files. | |
// https://github.com/CompositionalIT/Fake.Fsx | |
// Add this line to your paket.dependencies: | |
// github CompositionalIT/Fake.Fsx | |
#load "./paket-files/CompositionalIT/Fake.Fsx/Fake.Fsx.fsx" | |
open Fake | |
open Fake.Fsx | |
Target "ValidateScripts" (fun _ -> | |
ValidateScripts [ "src/Script1.fsx"; "Script2.fsx" ]) | |
// The rest of the script... | |
RunTargetOrDefault "ValidateScripts" |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
open Fake | |
let buildDir = "./build/" | |
let appReferences = | |
!! "src/app/**/*.csproj" | |
++ "src/app/**/and-this.fsproj" | |
-- "src/app/**/but-not-this.csproj" | |
Target "BuildApp" (fun _ -> | |
MSBuildRelease buildDir "Build" appReferences | |
|> Log "AppBuild-Output: " | |
) |
open System.Management.Automation | |
Target "BuildMigrations" (fun _ -> | |
!! "src/app/**/migrations.csproj" | |
|> MSBuildRelease buildDir "Build" | |
) | |
Target "RunMigrations" (fun _ -> | |
MigrateToLatest connectionString [assembly] options | |
) | |
// Dependencies | |
"BuildMigrations" | |
==> "RunMigrations" |
#r "../packages/build/FAKE/tools/FakeLib.dll" | |
open Fake | |
Target "Test" <| fun _ -> | |
trace "Testing stuff..." | |
Target "Build" <| fun _ -> | |
trace "Building stuff..." | |
// define the dependencies | |
"Test" | |
==> "Build" | |
RunTargetOrDefault "Build" |