refact
parent
36e1137e50
commit
b6098c28a6
@ -1,51 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": ".NET Core Launch (web)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
"program": "${workspaceFolder}/src/nuget-host/bin/Debug/netcoreapp2.1/nuget-host.dll",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}/src/nuget-host",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"requireExactSource": false,
|
|
||||||
"serverReadyAction": {
|
|
||||||
"action": "openExternally",
|
|
||||||
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"sourceFileMap": {
|
|
||||||
"/Views": "${workspaceFolder}/src/nuget-host/Views"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Core Launch cli",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "buildcli",
|
|
||||||
"program": "${workspaceFolder}/src/nuget-cli/bin/Debug/netcoreapp2.1/nuget-cli.dll",
|
|
||||||
"args": [ "push",
|
|
||||||
"-k", "lame-aki-key",
|
|
||||||
"-s", "http://localhost:5000/packages",
|
|
||||||
"lame.nupkg"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/src/nuget-cli",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"requireExactSource": false,
|
|
||||||
"serverReadyAction": {
|
|
||||||
"action": "openExternally",
|
|
||||||
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace nuget_cli
|
||||||
|
{
|
||||||
|
internal class PushCommand
|
||||||
|
{
|
||||||
|
static internal async Task<PushReport> RunAsync(string pkg, string source, string apikey)
|
||||||
|
{
|
||||||
|
var report = new PushReport {
|
||||||
|
PkgName = pkg
|
||||||
|
};
|
||||||
|
FileInfo fi = new FileInfo(pkg);
|
||||||
|
if (!fi.Exists)
|
||||||
|
throw new Exception("Le fichier n'existe pas");
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.DefaultRequestHeaders.Add("api-key", apikey);
|
||||||
|
client.BaseAddress = new Uri(source);
|
||||||
|
var content = new StreamContent(fi.OpenRead());
|
||||||
|
var response = await client.PutAsync(source, content);
|
||||||
|
report.StatusCode = response.StatusCode.ToString();
|
||||||
|
report.Message = await response.Content.ReadAsStringAsync();
|
||||||
|
report.Executed = true;
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
namespace nuget_cli
|
||||||
|
{
|
||||||
|
internal class PushReport
|
||||||
|
{
|
||||||
|
internal string PkgName { get; set; }
|
||||||
|
internal bool Executed { get; set; }
|
||||||
|
internal bool AlreadyPresent { get; set; }
|
||||||
|
internal string Message { get; set; }
|
||||||
|
internal string StatusCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue