Skip to content

Commit

Permalink
Use dotnet tool manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Sep 29, 2019
1 parent 750cae3 commit b2b39f0
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 52 deletions.
24 changes: 24 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"isRoot": true,
"tools": {
"paket": {
"version": "5.219.6",
"commands": [
"paket"
]
},
"fake-cli": {
"version": "5.16.1",
"commands": [
"fake"
]
},
"nbgv": {
"version": "3.0.26",
"commands": [
"nbgv"
]
}
}
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Bug reports and feature proposals should be submitted on [the issue tracker](htt

In the instructions below, `build` means `./build.sh` on Linux and OSX, and `.\build.cmd` on Windows.

Alternatively, you can install Fake globally with `dotnet tool install -g fake-cli`, and run `fake build`.
Alternatively, you can restore the dotnet tools with `dotnet tools restore`, and then build with `dotnet fake build`.

### How to build

Expand Down
1 change: 1 addition & 0 deletions tools/Common.props → Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<PaketCommand>dotnet paket</PaketCommand>
<Company>IntelliFactory</Company>
<!-- UseSharedCompilation=true causes problems with locked Bolero.Build.dll -->
<UseSharedCompilation>false</UseSharedCompilation>
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ build_script:
- export NUGET_PACKAGES="$APPVEYOR_BUILD_FOLDER/.nuget"

# Chrome on AV is not latest
- dotnet tool install paket --tool-path .paket
- .paket/paket add Selenium.WebDriver.ChromeDriver --version 76.0.3809.12600
- dotnet tool restore
- dotnet paket add Selenium.WebDriver.ChromeDriver --version 76.0.3809.12600
- dotnet restore

- '$BUILD_SCRIPT -t pack -c Release -v "$SEMVER" --sourceLink /p:GhPages=true'
Expand Down
8 changes: 2 additions & 6 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
@echo off

if not exist .paket\paket.exe dotnet tool install paket --tool-path .paket
if not exist .paket\fake.exe dotnet tool install fake-cli --tool-path .paket
if not exist .paket\nbgv.exe dotnet tool install nbgv --tool-path .paket

.paket\fake build %*
if errorlevel 1 exit /b %errorlevel%
dotnet tool restore
dotnet fake build %*
15 changes: 3 additions & 12 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ open Utility

let config = getArg "-c" "Debug"
let version = getArgOpt "-v" >> Option.defaultWith (fun () ->
CreateProcess.fromRawCommand ".paket/nbgv" ["get-version"; "-v"; "SemVer2"]
|> CreateProcess.redirectOutput
|> Proc.run
|> fun r -> r.Result.Output.Trim()
dotnetOutput "nbgv" "get-version -v SemVer2" |> List.head
)
let testUploadUrl = getArgOpt "--push-tests"
let verbosity = getFlag "--verbose" >> function
Expand All @@ -48,7 +45,7 @@ let buildArgs o =

Target.description "Run the compilation phase proper"
Target.create "corebuild" (fun o ->
dotnet "build" "Bolero.sln %s" (buildArgs o)
dotnet "build" "Bolero.sln %s" (buildArgs o)
)

let [<Literal>] tagsFile = slnDir + "/src/Bolero/tags.csv"
Expand Down Expand Up @@ -123,13 +120,7 @@ Target.create "build" (fun _ ->

Target.description "Create the NuGet packages"
Target.create "pack" (fun o ->
Fake.DotNet.Paket.pack (fun p ->
{ p with
OutputPath = "build"
Version = version o
ToolPath = ".paket/paket"
}
)
dotnet "paket" "pack build --version %s" (version o)
)

Target.description "Run the Client test project"
Expand Down
9 changes: 2 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/bash
set -e

if [ "$OS" = "Windows_NT" ]; then EXE_EXT=.exe; else EXE_EXT=; fi

if ! [ -f ".paket/paket$EXE_EXT" ]; then dotnet tool install paket --tool-path .paket; fi
if ! [ -f ".paket/fake$EXE_EXT" ]; then dotnet tool install fake-cli --tool-path .paket; fi
if ! [ -f ".paket/nbgv$EXE_EXT" ]; then dotnet tool install nbgv --tool-path .paket; fi

.paket/fake build "$@"
dotnet tool restore
dotnet fake build "$@"
1 change: 0 additions & 1 deletion src/Bolero.Build/Bolero.Build.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Expand Down
1 change: 0 additions & 1 deletion src/Bolero.Server/Bolero.Server.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
1 change: 0 additions & 1 deletion src/Bolero/Bolero.fsproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
1 change: 0 additions & 1 deletion tests/Client/Client.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DefineConstants Condition="'$(GhPages)' != ''">$(DefineConstants);GHPAGES</DefineConstants>
Expand Down
1 change: 0 additions & 1 deletion tests/Remoting.Client/Remoting.Client.fsproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<BoleroTaskAssemblyPath>$(MSBuildThisFileDirectory)..\..\src\Bolero.Build\bin\$(Configuration)\netstandard2.0\Bolero.Build.dll</BoleroTaskAssemblyPath>
Expand Down
3 changes: 1 addition & 2 deletions tests/Remoting.Server/Remoting.Server.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
Expand All @@ -15,4 +14,4 @@
<ProjectReference Include="..\Remoting.Client\Remoting.Client.fsproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
</Project>
1 change: 0 additions & 1 deletion tests/Server/Server.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit.Client/Unit.Client.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<BoleroTaskAssemblyPath>$(MSBuildThisFileDirectory)..\..\src\Bolero.Build\src\$(Configuration)\netstandard2.0\Bolero.Build.dll</BoleroTaskAssemblyPath>
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Unit.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\tools\Common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
Expand Down
34 changes: 21 additions & 13 deletions tools/Utility.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,33 @@ open Fake.Core
open Fake.DotNet
open Fake.IO

let rundotnet dir env redirectOutput cmd args =
let env =
(Process.createEnvironmentMap(), env)
||> List.fold (fun map (k, v) -> Map.add k v map)
DotNet.exec
(DotNet.Options.withWorkingDirectory dir
>> DotNet.Options.withEnvironment env
>> DotNet.Options.withRedirectOutput redirectOutput)
cmd args

let dotnet' dir env cmd args =
Printf.kprintf (fun args ->
let env =
(Process.createEnvironmentMap(), env)
||> List.fold (fun map (k, v) -> Map.add k v map)
let r =
DotNet.exec
(DotNet.Options.withWorkingDirectory dir
>> DotNet.Options.withEnvironment env)
cmd args
for msg in r.Results do
eprintfn "%s" msg.Message
if not r.OK then
failwithf "dotnet %s failed" cmd
Printf.kprintf (rundotnet dir env false cmd >> fun r ->
if not r.OK then failwithf "dotnet %s failed" cmd
) args

let dotnet cmd args =
dotnet' slnDir [] cmd args

let dotnetOutput' dir env cmd args =
Printf.kprintf (rundotnet dir env true cmd >> fun r ->
if not r.OK then failwithf "dotnet %s failed" cmd
r.Messages
) args

let dotnetOutput cmd args =
dotnetOutput' slnDir [] cmd args

/// `cache f x` returns `f x` the first time,
/// and re-returns the first result on subsequent calls.
let cache f =
Expand Down

0 comments on commit b2b39f0

Please sign in to comment.