cli to msbuild
This commit is contained in:
5
.vscode/tasks.json
vendored
5
.vscode/tasks.json
vendored
@ -28,15 +28,14 @@
|
||||
},
|
||||
{
|
||||
"label": "buildcli",
|
||||
"command": "dotnet",
|
||||
"command": "msbuild",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"src/nuget-cli",
|
||||
"/p:Configuration=Debug",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary",
|
||||
"--ignore-failed-sources"
|
||||
"/restore"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
@ -16,7 +16,7 @@ namespace nuget_cli
|
||||
/// <summary>
|
||||
/// Creates HTTP POST request & uploads database to server. Author : Farhan Ghumra
|
||||
/// </summary>
|
||||
static internal async Task UploadFilesToServer(
|
||||
static internal void UploadFilesToServer(
|
||||
this PushReport report, Uri uri,
|
||||
FileInfo fi, string apikey)
|
||||
{
|
||||
@ -30,10 +30,10 @@ namespace nuget_cli
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
// client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
client.DefaultRequestHeaders.Add("X-NuGet-Client-Version", clientVersion);
|
||||
client.DefaultRequestHeaders.Add("X-NuGet-ApiKey", apikey);
|
||||
// client.DefaultRequestHeaders.Add("X-NuGet-Client-Version", clientVersion);
|
||||
// client.DefaultRequestHeaders.Add("X-NuGet-ApiKey", apikey);
|
||||
var dispo = new ContentDispositionHeaderValue("file");
|
||||
dispo.FileName = fi.Name;
|
||||
dispo.CreationDate = fi.CreationTime;
|
||||
@ -44,17 +44,26 @@ namespace nuget_cli
|
||||
Stream fileStream = fi.OpenRead();
|
||||
var streamcontent = new StreamContent(fileStream);
|
||||
streamcontent.Headers.ContentDisposition = dispo;
|
||||
formdata.Add(streamcontent, "file", fi.Name);
|
||||
formdata.Add(streamcontent, fi.Name, fi.Name);
|
||||
|
||||
// content.Add(formdata);
|
||||
client.BaseAddress = uri;
|
||||
HttpRequestMessage put = new HttpRequestMessage(HttpMethod.Put, uri);
|
||||
put.Content = formdata;
|
||||
put.Headers.Add("X-NuGet-Client-Version", clientVersion);
|
||||
put.Headers.Add("X-NuGet-ApiKey", apikey);
|
||||
put.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
var response = await client.PutAsync(uri, formdata);
|
||||
response.EnsureSuccessStatusCode();
|
||||
report.StatusCode = response.StatusCode.ToString();
|
||||
var respstream = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
Task<HttpResponseMessage> response = client.SendAsync(put);
|
||||
response.RunSynchronously();
|
||||
|
||||
response.Result.EnsureSuccessStatusCode();
|
||||
report.StatusCode = response.Result.StatusCode.ToString();
|
||||
var respstream = response.Result.Content.ReadAsStreamAsync().Result;
|
||||
var sr = new StreamReader(respstream);
|
||||
|
||||
report.Message = await sr.ReadToEndAsync();
|
||||
report.Message = sr.ReadToEndAsync().Result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nuget_cli
|
||||
{
|
||||
[Display(Name="nuget_cli")]
|
||||
|
||||
partial class Program
|
||||
{
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace nuget_cli
|
||||
|
||||
try
|
||||
{
|
||||
await report.UploadFilesToServer(new Uri(source), fi, apikey);
|
||||
await Task.Run(() => report.UploadFilesToServer(new Uri(source), fi, apikey));
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<RootNamespace>nuget_cli</RootNamespace>
|
||||
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.Options" Version="5.3.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<Reference Include="System.Net.Http" Version="4.0.0"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user