Skip to content

Commit 46590d4

Browse files
committed
Merge pull request #548 from theimowski/master
convert-from-nuget - warn if there's a Nuget feed that cannot be connected to
2 parents 14bd543 + 049720a commit 46590d4

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎src/Paket.Core/NugetConvert.fs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ let createDependenciesFileR (rootDirectory : DirectoryInfo) nugetEnv mode =
251251
if nugetEnv.NugetConfig.PackageSources = [] then [Constants.DefaultNugetStream,None] else nugetEnv.NugetConfig.PackageSources
252252
|> List.map (fun (n, auth) -> n, auth |> Option.map (CredsMigrationMode.toAuthentication mode n))
253253
|> List.map (fun source ->
254-
try source |> PackageSource.Parse |> Rop.succeed
255-
with _ -> source |> fst |> PackageSourceParseError |> Rop.fail)
254+
try source |> PackageSource.Parse |> succeed
255+
with _ -> source |> fst |> PackageSourceParseError |> fail
256+
|> successTee PackageSource.warnIfNoConnection)
257+
256258
|> Rop.collect
257259

258260
sources

‎src/Paket.Core/PackageSources.fs‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module Paket.PackageSources
22

33
open System
4+
open System.IO
45
open System.Text.RegularExpressions
5-
open Logging
6+
7+
open Paket.Logging
8+
open Paket.Rop
69

710
type EnvironmentVariable =
811
{ Variable : string
@@ -91,4 +94,15 @@ type PackageSource =
9194

9295
static member NugetSource url = Nuget { Url = url; Authentication = None }
9396

97+
static member warnIfNoConnection (source,_) =
98+
match source with
99+
| Nuget {Url = url; Authentication = auth} ->
100+
use client = Utils.createWebClient (auth |> Option.map toBasicAuth)
101+
try client.DownloadData url |> ignore
102+
with _ ->
103+
traceWarnfn "Unable to ping remote Nuget feed: %s." url
104+
| LocalNuget path ->
105+
if not <| File.Exists path then
106+
traceWarnfn "Local Nuget feed doesn't exist: %s." path
107+
94108
let DefaultNugetSource = PackageSource.NugetSource Constants.DefaultNugetStream

0 commit comments

Comments
 (0)