Use Newtonsoft.Json for UploadToLinuxPackageRepository (#7745)
This commit is contained in:
parent
3cebbb4ea3
commit
85ce73dfb5
2 changed files with 6 additions and 6 deletions
|
@ -8,7 +8,7 @@ using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NuGet.Protocol;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
||||||
{
|
{
|
||||||
|
@ -34,13 +34,13 @@ namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
||||||
|
|
||||||
public async Task<string> Execute(HttpClient client, Uri baseAddress)
|
public async Task<string> Execute(HttpClient client, Uri baseAddress)
|
||||||
{
|
{
|
||||||
var debianUploadJsonContent = new Dictionary<string, string>
|
var debianUploadJsonContent = JsonConvert.SerializeObject(new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
["name"] = _packageName,
|
["name"] = _packageName,
|
||||||
["version"] = AppendDebianRevisionNumber(_packageVersion),
|
["version"] = AppendDebianRevisionNumber(_packageVersion),
|
||||||
["fileId"] = _idInRepositoryService.Id,
|
["fileId"] = _idInRepositoryService.Id,
|
||||||
["repositoryId"] = _repositoryId
|
["repositoryId"] = _repositoryId
|
||||||
}.ToJson();
|
});
|
||||||
var content = new StringContent(debianUploadJsonContent,
|
var content = new StringContent(debianUploadJsonContent,
|
||||||
Encoding.UTF8,
|
Encoding.UTF8,
|
||||||
"application/json");
|
"application/json");
|
||||||
|
@ -49,7 +49,7 @@ namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
||||||
{
|
{
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
throw new FailedToAddPackageToPackageRepositoryException(
|
throw new FailedToAddPackageToPackageRepositoryException(
|
||||||
$"request:{debianUploadJsonContent} response:{response.ToJson()}");
|
$"request:{debianUploadJsonContent} response:{JsonConvert.SerializeObject(response)}");
|
||||||
return response.Headers.GetValues("Location").Single();
|
return response.Headers.GetValues("Location").Single();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NuGet.Protocol;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ namespace Microsoft.DotNet.Cli.Build.UploadToLinuxPackageRepository
|
||||||
if (!message.IsSuccessStatusCode)
|
if (!message.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
throw new FailedToAddPackageToPackageRepositoryException(
|
throw new FailedToAddPackageToPackageRepositoryException(
|
||||||
$"{message.ToJson()} failed to post file to {url} file name:{fileName} pathToPackageToUpload:{_pathToPackageToUpload}");
|
$"{JsonConvert.SerializeObject(message)} failed to post file to {url} file name:{fileName} pathToPackageToUpload:{_pathToPackageToUpload}");
|
||||||
}
|
}
|
||||||
return await message.Content.ReadAsStringAsync();
|
return await message.Content.ReadAsStringAsync();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue