Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1808: Convert DotNet API to "module based" #1812

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
62 changes: 61 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Windows
#if BOOTSTRAP
open Fake.DotNet
open Fake.DotNet.Cli
#else
open Fake.DotNet
#endif
open Fake.DotNet.Testing

// properties
Expand Down Expand Up @@ -411,13 +416,22 @@ Target.Create "DotNetCoreIntegrationTests" (fun _ ->
|> NUnit3.NUnit3 id
)

#if BOOTSTRAP
let withWorkDir wd (cliOpts: DotNet.Options) = { cliOpts with WorkingDirectory = wd }
#else
let withWorkDir wd (cliOpts:Cli.DotNetOptions) = { cliOpts with WorkingDirectory = wd }
#endif

Target.Create "DotNetCoreUnitTests" (fun _ ->
// dotnet run -p src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj
#if BOOTSTRAP
let processResult =
DotNet.Raw (withWorkDir root) "src/test/Fake.Core.UnitTests/bin/Release/netcoreapp2.0/Fake.Core.UnitTests.dll" "--summary"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or DotNet.Exec (but only a suggestion, it is as good as Raw, I just think we used Exec already on some places).
On the other side we also used Run on other places. This is indeed not a very consistent naming at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find Exec a good name.

Indeed using Run seems most natural but their is a run command in dotnet so it's can be confusing.

#else
let processResult =
Cli.DotNet (withWorkDir root) "src/test/Fake.Core.UnitTests/bin/Release/netcoreapp2.0/Fake.Core.UnitTests.dll" "--summary"
if processResult.ExitCode <> 0 then failwithf "Unit-Tests failed."
#endif
if processResult.ExitCode <> 0 then failwithf "Unit-Tests failed."
)

Target.Create "BootstrapTest" (fun _ ->
Expand Down Expand Up @@ -647,6 +661,16 @@ Target.Create "CreateNuGet" (fun _ ->


let LatestTooling options =
#if BOOTSTRAP
{ options with
DotNet.InstallerOptions = (fun io ->
{ io with
Branch = "release/2.1"
})
DotNet.Channel = None
DotNet.Version = DotNet.Version "2.1.4"
}
#else
{ options with
Cli.InstallerOptions = (fun io ->
{ io with
Expand All @@ -655,9 +679,18 @@ let LatestTooling options =
Cli.Channel = None
Cli.Version = Cli.Version "2.1.4"
}
#endif

#if BOOTSTRAP
Target.Create "InstallDotNetCore" (fun _ ->
DotNet.Install DotNet.Release_2_1_4
)
#else
Target.Create "InstallDotNetCore" (fun _ ->

Cli.DotNetCliInstall Cli.Release_2_1_4
)
#endif

let netCoreProjs =
!! (appDir </> "*/*.fsproj")
Expand Down Expand Up @@ -687,13 +720,23 @@ Target.Create "DotNetPackage_" (fun _ ->


// dotnet pack
#if BOOTSTRAP
DotNet.Pack (fun c ->
{ c with
Configuration = DotNet.Release
OutputPath = Some nugetDir
}) "Fake.sln"

let info = DotNet.Info id
#else
Cli.DotNetPack (fun c ->
{ c with
Configuration = Cli.Release
OutputPath = Some nugetDir
}) "Fake.sln"

let info = Cli.DotNetInfo id
#endif

// dotnet publish
runtimes
Expand All @@ -710,12 +753,21 @@ Target.Create "DotNetPackage_" (fun _ ->

//DotNetRestore (fun c -> {c with Runtime = Some runtime}) proj
let outDir = nugetDir @@ projName @@ runtimeName
#if BOOTSTRAP
DotNet.Publish (fun c ->
{ c with
Runtime = Some runtime
Configuration = DotNet.Release
OutputPath = Some outDir
}) proj
#else
Cli.DotNetPublish (fun c ->
{ c with
Runtime = Some runtime
Configuration = Cli.Release
OutputPath = Some outDir
}) proj
#endif
let source = outDir </> "dotnet"
if File.Exists source then
failwithf "Workaround no longer required?" //TODO: If this is not triggered delete this block
Expand All @@ -729,11 +781,19 @@ Target.Create "DotNetPackage_" (fun _ ->
// Publish portable as well (see https://docs.microsoft.com/en-us/dotnet/articles/core/app-types)
let netcoreFsproj = appDir </> "Fake.netcore/Fake.netcore.fsproj"
let outDir = nugetDir @@ "Fake.netcore" @@ "portable"
#if BOOTSTRAP
DotNet.Publish (fun c ->
{ c with
Framework = Some "netcoreapp2.0"
OutputPath = Some outDir
}) netcoreFsproj
#else
Cli.DotNetPublish (fun c ->
{ c with
Framework = Some "netcoreapp2.0"
OutputPath = Some outDir
}) netcoreFsproj
#endif

)

Expand Down
Loading