From 98070012a03925d36491c9302ac7f1df252f370d Mon Sep 17 00:00:00 2001 From: gdziadkiewicz Date: Fri, 26 Apr 2019 21:52:10 +0200 Subject: [PATCH 1/2] Add SelfContained, Force and Manifest to dotnet publish, --- src/app/Fake.DotNet.Cli/DotNet.fs | 20 ++++++++++++++++++- .../Fake.Core.UnitTests/Fake.DotNet.Cli.fs | 13 ++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/Fake.DotNet.Cli/DotNet.fs b/src/app/Fake.DotNet.Cli/DotNet.fs index 2f6f2c669ae..9bcc1d0ae0e 100644 --- a/src/app/Fake.DotNet.Cli/DotNet.fs +++ b/src/app/Fake.DotNet.Cli/DotNet.fs @@ -594,6 +594,10 @@ module DotNet = | true -> [ sprintf "--%s" name ] | false -> [] + /// [omit] + let private argOptionExplicit name value = + [ sprintf "--%s=%A" name value ] + /// [omit] let private buildCommonArgs (param: Options) = [ defaultArg param.CustomParams "" |> Args.fromWindowsCommandLine |> Seq.toList @@ -1202,10 +1206,18 @@ module DotNet = OutputPath: string option /// Defines what `*` should be replaced with in version field in project.json (--version-suffix) VersionSuffix: string option + /// The path to a target manifest file that contains the list of packages to be excluded from the publish step. (--manifest) + Manifest: string option + /// Publish the .NET Core runtime with your application so the runtime doesn't need to be installed on the target machine. + /// The default is 'true' if a runtime identifier is specified. (--self-contained) + SelfContained: bool option /// No build flag (--no-build) NoBuild: bool /// Doesn't execute an implicit restore when running the command. (--no-restore) NoRestore: bool + /// Force all dependencies to be resolved even if the last restore was successful. + /// This is equivalent to deleting project.assets.json. (--force) + Force: bool option /// Other msbuild specific parameters MSBuildParams : MSBuild.CliArguments } @@ -1221,6 +1233,9 @@ module DotNet = VersionSuffix = None NoBuild = false NoRestore = false + Force = None + SelfContained = None + Manifest = None MSBuildParams = MSBuild.CliArguments.Create() } [] @@ -1239,7 +1254,7 @@ module DotNet = { x with Common = f x.Common } /// [omit] - let private buildPublishArgs (param: PublishOptions) = + let internal buildPublishArgs (param: PublishOptions) = [ buildConfigurationArg param.Configuration param.Framework |> Option.toList |> argList2 "framework" @@ -1247,8 +1262,11 @@ module DotNet = param.BuildBasePath |> Option.toList |> argList2 "build-base-path" param.OutputPath |> Option.toList |> argList2 "output" param.VersionSuffix |> Option.toList |> argList2 "version-suffix" + param.Manifest |> Option.toList |> argList2 "manifest" param.NoBuild |> argOption "no-build" param.NoRestore |> argOption "no-restore" + param.SelfContained |> Option.map (argOptionExplicit "self-contained") |> Option.defaultValue [] + param.Force |> Option.map (argOptionExplicit "force") |> Option.defaultValue [] ] |> List.concat |> List.filter (not << String.IsNullOrEmpty) diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs index e4ce37fb529..49f64b32779 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs @@ -42,5 +42,18 @@ let tests = let expected = "--disable-buffering --api-key abc123 --no-symbols --no-service-endpoint --source MyNuGetSource --symbol-api-key MySymbolApiKey --symbol-source MySymbolSource --timeout 300" + Expect.equal cli expected "Push args generated correctly." + + testCase "Test that the dotnet publish self-contained works as expected" <| fun _ -> + let param = + { DotNet.PublishOptions.Create() with + SelfContained = Some false } + let cli = + param + |> DotNet.buildPublishArgs + |> Args.toWindowsCommandLine + + let expected = "--configuration Release --self-contained=false" + Expect.equal cli expected "Push args generated correctly." ] From 6a45f0473a60ed5ddb2d776f1779a90a0bd95dcd Mon Sep 17 00:00:00 2001 From: gdziadkiewicz Date: Sun, 28 Apr 2019 12:49:10 +0200 Subject: [PATCH 2/2] Add tests for force and manifest --- src/app/Fake.DotNet.Cli/DotNet.fs | 10 ++++--- .../Fake.Core.UnitTests/Fake.DotNet.Cli.fs | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/app/Fake.DotNet.Cli/DotNet.fs b/src/app/Fake.DotNet.Cli/DotNet.fs index 9bcc1d0ae0e..c75a8cfb552 100644 --- a/src/app/Fake.DotNet.Cli/DotNet.fs +++ b/src/app/Fake.DotNet.Cli/DotNet.fs @@ -1206,8 +1206,10 @@ module DotNet = OutputPath: string option /// Defines what `*` should be replaced with in version field in project.json (--version-suffix) VersionSuffix: string option - /// The path to a target manifest file that contains the list of packages to be excluded from the publish step. (--manifest) - Manifest: string option + /// Specifies one or several target manifests to use to trim the set of packages published with the app. + /// The manifest file is part of the output of the dotnet store command. + /// This option is available starting with .NET Core 2.0 SDK. (--manifest) + Manifest: string list option /// Publish the .NET Core runtime with your application so the runtime doesn't need to be installed on the target machine. /// The default is 'true' if a runtime identifier is specified. (--self-contained) SelfContained: bool option @@ -1262,11 +1264,11 @@ module DotNet = param.BuildBasePath |> Option.toList |> argList2 "build-base-path" param.OutputPath |> Option.toList |> argList2 "output" param.VersionSuffix |> Option.toList |> argList2 "version-suffix" - param.Manifest |> Option.toList |> argList2 "manifest" + param.Manifest |> Option.toList |> List.collect id |> argList2 "manifest" param.NoBuild |> argOption "no-build" param.NoRestore |> argOption "no-restore" param.SelfContained |> Option.map (argOptionExplicit "self-contained") |> Option.defaultValue [] - param.Force |> Option.map (argOptionExplicit "force") |> Option.defaultValue [] + param.Force |> Option.map (argOption "force") |> Option.defaultValue [] ] |> List.concat |> List.filter (not << String.IsNullOrEmpty) diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs index 49f64b32779..aeeaeb6656a 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs @@ -55,5 +55,31 @@ let tests = let expected = "--configuration Release --self-contained=false" + Expect.equal cli expected "Push args generated correctly." + + testCase "Test that the dotnet publish force works as expected" <| fun _ -> + let param = + { DotNet.PublishOptions.Create() with + Force = Some true } + let cli = + param + |> DotNet.buildPublishArgs + |> Args.toWindowsCommandLine + + let expected = "--configuration Release --force" + + Expect.equal cli expected "Push args generated correctly." + + testCase "Test that the dotnet publish manifest works as expected" <| fun _ -> + let param = + { DotNet.PublishOptions.Create() with + Manifest = Some ["Path1"; "Path2"] } + let cli = + param + |> DotNet.buildPublishArgs + |> Args.toWindowsCommandLine + + let expected = "--configuration Release --manifest Path1 --manifest Path2" + Expect.equal cli expected "Push args generated correctly." ]