Skip to content

Commit

Permalink
Release 5.13.3 (#2306)
Browse files Browse the repository at this point in the history
Release 5.13.3
  • Loading branch information
matthid authored Apr 28, 2019
2 parents a0d36e0 + 85b3d80 commit 30b0949
Show file tree
Hide file tree
Showing 15 changed files with 924 additions and 759 deletions.
11 changes: 9 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Release Notes

## 5.13.3-alpha - tbd
## 5.13.4 - tbd

* tbd.
* tbd

## 5.13.3 - 2019-04-29

* ENHANCEMENT: Use NuGet Libraries for `getLastNuGetVersion` - see https://github.com/NuGet/NuGetGallery/issues/7085
* ENHANCEMENT: TeamCitySummary, added in ReportGenerator 4.1.3 Fixes #2300 - https://github.com/fsharp/FAKE/pull/2301
* BUGFIX: `Shell.mv` now has the correct documented behavior, consistent with parameter names - https://github.com/fsharp/FAKE/issues/2293
* BUGFIX: NuGet Push command syntax. Fixes #2299 - https://github.com/fsharp/FAKE/pull/2304

## 5.13.2 - 2019-04-23

Expand Down
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ group netcore
nuget Octokit
nuget Newtonsoft.Json
nuget Paket.Core // prerelease
nuget NuGet.Protocol ~> 4.0 strategy: min // To support net462...
nuget Mono.Cecil prerelease
nuget FSharp.Control.Reactive
nuget System.Reactive.Compatibility
Expand Down
1,417 changes: 730 additions & 687 deletions paket.lock

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion src/app/Fake.DotNet.Cli/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1202,10 +1206,20 @@ module DotNet =
OutputPath: string option
/// Defines what `*` should be replaced with in version field in project.json (--version-suffix)
VersionSuffix: 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
/// 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
}
Expand All @@ -1221,6 +1235,9 @@ module DotNet =
VersionSuffix = None
NoBuild = false
NoRestore = false
Force = None
SelfContained = None
Manifest = None
MSBuildParams = MSBuild.CliArguments.Create()
}
[<Obsolete("Use PublishOptions.Create instead")>]
Expand All @@ -1239,16 +1256,19 @@ 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"
param.Runtime |> Option.toList |> argList2 "runtime"
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 |> 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 (argOption "force") |> Option.defaultValue []
]
|> List.concat
|> List.filter (not << String.IsNullOrEmpty)
Expand Down
1 change: 1 addition & 0 deletions src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="VisibleTo.fs" />
<Compile Include="Restore.fs" />
<Compile Include="NuGet.fs" />
<Compile Include="Update.fs" />
Expand Down
42 changes: 26 additions & 16 deletions src/app/Fake.DotNet.NuGet/NuGet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -376,30 +376,40 @@ type NuGetParams with
member internal x.ToolOptions = ToolOptions.Create x.ToolPath "push" x.WorkingDir true
member internal x.Nupkg = (x.OutputPath @@ packageFileName x |> Path.getFullName)

let private toPushCliArgs param =
let ifTrue x b =
if b then Some x
else None
let internal toPushCliArgs param =
let toSeconds (t: TimeSpan) =
t.TotalSeconds
|> int
|> string

let stringToArg name values =
values
|> List.collect (fun v -> ["-" + name; v])

let boolToArg name value =
match value with
| true -> [ sprintf "-%s" name ]
| false -> []

[
param.ApiKey
param.DisableBuffering |> ifTrue "-DisableBuffering"
param.NoSymbols |> ifTrue "-NoSymbols"
param.NoServiceEndpoint |> ifTrue "-NoServiceEndpoint"
param.Source |> Option.map (sprintf "-Source %s")
param.SymbolApiKey |> Option.map (sprintf "-SymbolApiKey %s")
param.SymbolSource |> Option.map (sprintf "-SymbolSource %s")
param.Timeout |> Option.map string |> Option.map (sprintf "-Timeout %s")
param.ApiKey |> Option.toList |> stringToArg "ApiKey"
param.DisableBuffering |> boolToArg "DisableBuffering"
param.NoSymbols |> boolToArg "NoSymbols"
param.NoServiceEndpoint |> boolToArg "NoServiceEndpoint"
param.Source |> Option.toList |> stringToArg "Source"
param.SymbolApiKey |> Option.toList |> stringToArg "SymbolApiKey"
param.SymbolSource |> Option.toList |> stringToArg "SymbolSource"
param.Timeout |> Option.map toSeconds |> Option.toList |> stringToArg "Timeout"
]
|> List.choose id
|> Arguments.ofList
|> List.concat
|> List.filter (not << String.IsNullOrEmpty)

let rec private push (options : ToolOptions) (parameters : NuGetPushParams) nupkg =
parameters.ApiKey |> Option.iter (fun key -> TraceSecrets.register key "<NuGetKey>")
parameters.SymbolApiKey |> Option.iter (fun key -> TraceSecrets.register key "<NuGetSymbolKey>")

let args =
sprintf "%s \"%s\" %s" options.Command nupkg (toPushCliArgs parameters).ToWindowsCommandLine
let pushArgs = parameters |> toPushCliArgs |> Args.toWindowsCommandLine
let args = sprintf "%s \"%s\" %s" options.Command nupkg pushArgs

sprintf "%s %s in WorkingDir: %s Trials left: %d" options.ToolPath args (Path.getFullName options.WorkingDir) parameters.PushTrials
|> TraceSecrets.guardMessage
Expand Down
86 changes: 37 additions & 49 deletions src/app/Fake.DotNet.NuGet/NuGetVersion.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open Fake.Core
open Fake.Net
open Newtonsoft.Json
open System
open System.Threading
open System.Xml.Linq

type NuGetSearchItemResult =
Expand Down Expand Up @@ -45,57 +46,44 @@ type NuGetVersionArg =
Increment=IncMinor
DefaultVersion="1.0" }

type internal NuGetLogger () =
interface NuGet.Common.ILogger with
member x.Log(data) = () // printf "DEBUG: {data}".Dump();
member x.Log(level, date) = () // printf "DEBUG: {data}".Dump();
member x.LogAsync(data) = System.Threading.Tasks.Task.FromResult 1 :> System.Threading.Tasks.Task // printf "DEBUG: {data}".Dump();
member x.LogAsync(level, date) = System.Threading.Tasks.Task.FromResult 1 :> System.Threading.Tasks.Task // printf "DEBUG: {data}".Dump();
member x.LogDebug(data) = () // printf "DEBUG: {data}".Dump();
member x.LogVerbose(data) = () // $"VERBOSE: {data}".Dump();
member x.LogInformation(data) = () // $"INFORMATION: {data}".Dump();
member x.LogMinimal(data) = () // $"MINIMAL: {data}".Dump();
member x.LogWarning(data) = eprintf "WARNING: %s" data
member x.LogError(data) = eprintf "ERROR: %s" data
member x.LogInformationSummary(data) = () // eprintf "SUMMARY: %s" data

open global.NuGet.Protocol.Core
open global.NuGet.Protocol.Core.Types
open global.NuGet.Protocol


/// Retrieve current NuGet version number
let getLastNuGetVersion server (packageName:string) =
let escape = Uri.EscapeDataString
let url =
sprintf "%s/Search()?$filter=IsLatestVersion&searchTerm='%s'&includePrerelease=false"
server packageName
let headers, text =
Http.getWithHeaders null null (fun rh ->
rh.Add("Accept", "application/json, application/xml"))
url
let hasContentType = headers.ContainsKey "Content-Type"
let version =
if hasContentType && headers.["Content-Type"] |> List.exists (fun e -> e.Contains "application/json")
then
let json = JsonConvert.DeserializeObject<NuGetSearchResponse>(text)
json.d.results
|> Seq.filter (fun i -> i.Id = packageName)
|> Seq.sortByDescending (fun i -> i.Published)
|> Seq.tryHead
|> fun i ->
match i with
| Some v -> Some (SemVer.parse v.Version)
| None -> None
else
let xml = XDocument.Parse text
let xmlns = "http://www.w3.org/2005/Atom"
let xmlnsd="http://schemas.microsoft.com/ado/2007/08/dataservices"
let xmlnsm="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xml.Descendants(XName.Get("entry", xmlns))
|> Seq.filter (
fun entry ->
entry.Elements(XName.Get("title", xmlns))
|> Seq.exists (
fun t ->
t.Attribute(XName.Get "type").Value = "text"
&& t.Value = packageName
)
)
|> Seq.tryHead
|> function
| Some e ->
e.Descendants(XName.Get ("properties", xmlnsm))
|> fun props ->
props.Elements(XName.Get ("Version", xmlnsd))
|> Seq.tryHead
|> function
| Some n -> Some (SemVer.parse n.Value)
| None -> None
| None -> None
version
let getLastNuGetVersion server (packageName:string) : SemVerInfo option =
async {
let logger = new NuGetLogger()
let providers = new ResizeArray<Lazy<NuGet.Protocol.Core.Types.INuGetResourceProvider>>()

providers.AddRange(global.NuGet.Protocol.Core.Types.Repository.Provider.GetCoreV3())
let packageSource = new NuGet.Configuration.PackageSource(server)
let sourceRepository = new NuGet.Protocol.Core.Types.SourceRepository(packageSource, providers)
let! packageMetadataResource = sourceRepository.GetResourceAsync<NuGet.Protocol.Core.Types.PackageMetadataResource>() |> Async.AwaitTask
let cacheContext = new SourceCacheContext()
let! searchMetadata = packageMetadataResource.GetMetadataAsync(packageName, true, true, cacheContext, logger, CancellationToken.None) |> Async.AwaitTask
return
searchMetadata
|> Seq.choose (fun m -> try Some <| SemVer.parse m.Identity.Version.OriginalVersion with _ -> None)
|> Seq.sortByDescending (fun v -> v)
|> Seq.tryHead
}
|> Async.RunSynchronously


/// Compute next NuGet version number
Expand Down
7 changes: 7 additions & 0 deletions src/app/Fake.DotNet.NuGet/VisibleTo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

namespace System
open System.Runtime.CompilerServices

[<assembly: InternalsVisibleTo("Fake.Core.IntegrationTests")>]
[<assembly: InternalsVisibleTo("Fake.Core.UnitTests")>]
do ()
3 changes: 2 additions & 1 deletion src/app/Fake.DotNet.NuGet/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ group netcore
FSharp.Core
NETStandard.Library
System.Net.Http
Newtonsoft.Json
Newtonsoft.Json
NuGet.Protocol
2 changes: 1 addition & 1 deletion src/app/Fake.IO.FileSystem/Shell.fs
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,4 @@ module Shell =
/// Like "mv" in a shell. Moves/renames a file
/// <param name="src">The source</param>
/// <param name="dest">The destination</param>
let mv src dest = moveFile src dest
let mv src dest = moveFile dest src
1 change: 1 addition & 0 deletions src/app/Fake.Testing.ReportGenerator/ReportGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type ReportType =
| Badges
| CsvSummary
| Cobertura
| TeamCitySummary

type LogVerbosity =
| Verbose = 0
Expand Down
10 changes: 8 additions & 2 deletions src/test/Fake.Core.IntegrationTests/Fake.DotNet.NuGet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ open Expecto
[<Tests>]
let tests =
testList "Fake.DotNet.NuGetIntegrationTests" [
testCase "getLastNuGetVersion works - #2294" <| fun _ ->
// Unlikely to ever get any new updates
match NuGet.Version.getLastNuGetVersion "https://api.nuget.org/v3/index.json" "Yaaf.AdvancedBuilding" with
| None -> failwithf "Expected to retrieve version for package but got 'None'"
| Some v ->
Expect.equal v (SemVer.parse "0.14.1") "Expected 0.14.1"
testCase "getLastNuGetVersion works - #2124" <| fun _ ->
match NuGet.Version.getLastNuGetVersion "https://www.nuget.org/api/v2" "Dotnet.ProjInfo.Matthid" with
| None -> failwithf "Expected to retrieve version for package but got 'None'"
| Some v ->
Expect.equal (SemVer.parse "1.0.0") v "Expected 1.0.0"
Expect.equal v (SemVer.parse "1.0.0") "Expected 1.0.0"
testCase "getLastNuGetVersion works with myget - #2124" <| fun _ ->
match NuGet.Version.getLastNuGetVersion "https://www.myget.org/F/fake/api/v2" "Dotnet.ProjInfo.Matthid" with
| None -> failwithf "Expected to retrieve version for package but got 'None'"
| Some v ->
Expect.equal (SemVer.parse "1.0.0") v "Expected 1.0.0"
Expect.equal v (SemVer.parse "1.0.0") "Expected 1.0.0"
]
1 change: 1 addition & 0 deletions src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<Compile Include="Fake.DotNet.ILMerge.fs" />
<Compile Include="Fake.DotNet.FxCop.fs" />
<Compile Include="Fake.DotNet.MSBuild.fs" />
<Compile Include="Fake.DotNet.NuGet.fs" />
<Compile Include="Fake.DotNet.Testing.NUnit.fs" />
<Compile Include="Fake.DotNet.Testing.SpecFlow.fs" />
<Compile Include="Fake.DotNet.Fsi.fs" />
Expand Down
39 changes: 39 additions & 0 deletions src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,44 @@ 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."

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."
]
Loading

0 comments on commit 30b0949

Please sign in to comment.