Skip to content

Commit

Permalink
MyGet login tested
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Sep 25, 2014
1 parent 0186415 commit faf6d2c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 0.3.0-alpha011 - 23.09.2014
#### 0.3.0-alpha012 - 23.09.2014
* New command: paket add [--interactive] - http://fsprojects.github.io/Paket/paket-add.html
* New command: paket simplify - http://fsprojects.github.io/Paket/paket-simplify.html
* Better Visual Studio integration by using paket.targets file - http://fsprojects.github.io/Paket/paket-init-auto-restore.html
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/private-feeds/expected/paket.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source https://www.myget.org/F/paket-test/ username: "paket" password: "[REPLACEME]"

nuget GoogleAnalyticsTracker.Core
4 changes: 4 additions & 0 deletions integration-tests/private-feeds/expected/paket.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NUGET
remote: https://www.myget.org/F/paket-test username: "paket" password: "[REPLACEME]"
specs:
GoogleAnalyticsTracker.Core (3.0.22)
3 changes: 3 additions & 0 deletions integration-tests/private-feeds/original/paket.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source https://www.myget.org/F/paket-test/ username: "paket" password: "[REPLACEME]"

nuget GoogleAnalyticsTracker.Core
1 change: 1 addition & 0 deletions integration-tests/private-feeds/original/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
paket install
17 changes: 16 additions & 1 deletion src/Paket/Nuget.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ open Ionic.Zip
open System.Xml
open System.Text.RegularExpressions
open Paket.Logging
open System.Text

let private loadNuGetOData raw =
let doc = XmlDocument()
Expand Down Expand Up @@ -254,6 +255,20 @@ let DownloadPackage(auth, url, name, version, force) =

let request = HttpWebRequest.Create(Uri nugetPackage.Url) :?> HttpWebRequest
request.AutomaticDecompression <- DecompressionMethods.GZip ||| DecompressionMethods.Deflate

match auth with
| None -> ()
| Some auth ->
// htttp://stackoverflow.com/questions/16044313/webclient-httpwebrequest-with-basic-authentication-returns-404-not-found-for-v/26016919#26016919
//this works ONLY if the server returns 401 first
//client DOES NOT send credentials on first request
//ONLY after a 401
//client.Credentials <- new NetworkCredential(auth.Username,auth.Password)

//so use THIS instead to send credenatials RIGHT AWAY
let credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(auth.Username + ":" + auth.Password))
request.Headers.[HttpRequestHeader.Authorization] <- String.Format("Basic {0}", credentials)

use! httpResponse = request.AsyncGetResponse()

use httpResponseStream = httpResponse.GetResponseStream()
Expand Down Expand Up @@ -347,7 +362,7 @@ let GetPackageDetails force sources package version =
getDetailsFromLocalFile path package version |> Async.RunSynchronously
|> fun x -> source,x
with _ -> tryNext rest
| [] -> failwithf "Couldn't get package details for package %s on %A" package sources
| [] -> failwithf "Couldn't get package details for package %s on %A." package (sources |> List.map (fun (s:PackageSource) -> s.ToString()))

let source, nugetObject = tryNext sources
{ Name = nugetObject.Name
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>..\..\bin\Paket.xml</DocumentationFile>
<StartArguments>update</StartArguments>
<StartArguments>update -f</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\paket</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket\integration-tests\private-feeds\original</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ let getFromUrl (auth:Auth option, url : string) =
return! client.AsyncDownloadString(Uri(url))
with
| exn ->
failwithf "Could not retrieve data from %s%s Message: %s" url Environment.NewLine exn.Message
failwithf "Could not retrieve data from %s%s Message: %s" url Environment.NewLine exn.Message
return ""
}

Expand Down

0 comments on commit faf6d2c

Please sign in to comment.