From 049720a32e84317acdc631e76760ee1612acac62 Mon Sep 17 00:00:00 2001 From: Tomasz Heimowski Date: Wed, 14 Jan 2015 15:51:28 +0100 Subject: [PATCH] convert-from-nuget - warn if there's a Nuget feed that cannot be connected to --- src/Paket.Core/NugetConvert.fs | 6 ++++-- src/Paket.Core/PackageSources.fs | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Paket.Core/NugetConvert.fs b/src/Paket.Core/NugetConvert.fs index 83857b76db..a94a22a34e 100644 --- a/src/Paket.Core/NugetConvert.fs +++ b/src/Paket.Core/NugetConvert.fs @@ -251,8 +251,10 @@ let createDependenciesFileR (rootDirectory : DirectoryInfo) nugetEnv mode = if nugetEnv.NugetConfig.PackageSources = [] then [Constants.DefaultNugetStream,None] else nugetEnv.NugetConfig.PackageSources |> List.map (fun (n, auth) -> n, auth |> Option.map (CredsMigrationMode.toAuthentication mode n)) |> List.map (fun source -> - try source |> PackageSource.Parse |> Rop.succeed - with _ -> source |> fst |> PackageSourceParseError |> Rop.fail) + try source |> PackageSource.Parse |> succeed + with _ -> source |> fst |> PackageSourceParseError |> fail + |> successTee PackageSource.warnIfNoConnection) + |> Rop.collect sources diff --git a/src/Paket.Core/PackageSources.fs b/src/Paket.Core/PackageSources.fs index 80777475ae..7fb194d34b 100644 --- a/src/Paket.Core/PackageSources.fs +++ b/src/Paket.Core/PackageSources.fs @@ -1,8 +1,11 @@ module Paket.PackageSources open System +open System.IO open System.Text.RegularExpressions -open Logging + +open Paket.Logging +open Paket.Rop type EnvironmentVariable = { Variable : string @@ -91,4 +94,15 @@ type PackageSource = static member NugetSource url = Nuget { Url = url; Authentication = None } + static member warnIfNoConnection (source,_) = + match source with + | Nuget {Url = url; Authentication = auth} -> + use client = Utils.createWebClient (auth |> Option.map toBasicAuth) + try client.DownloadData url |> ignore + with _ -> + traceWarnfn "Unable to ping remote Nuget feed: %s." url + | LocalNuget path -> + if not <| File.Exists path then + traceWarnfn "Local Nuget feed doesn't exist: %s." path + let DefaultNugetSource = PackageSource.NugetSource Constants.DefaultNugetStream \ No newline at end of file