|
|
@ -9,7 +9,9 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using NuGet.Packaging;
|
|
|
|
using NuGet.Packaging;
|
|
|
|
|
|
|
|
using NuGet.Packaging.Core;
|
|
|
|
using nuget_host.Entities;
|
|
|
|
using nuget_host.Entities;
|
|
|
|
|
|
|
|
using nuget_host.Helpers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace nuget_host.Controllers
|
|
|
|
namespace nuget_host.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -39,7 +41,7 @@ namespace nuget_host.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var clientVersionId = Request.Headers["X-NuGet-Client-Version"];
|
|
|
|
var clientVersionId = Request.Headers["X-NuGet-Client-Version"];
|
|
|
|
var apiKey = Request.Headers["X-NuGet-ApiKey"];
|
|
|
|
var apiKey = Request.Headers["X-NuGet-ApiKey"];
|
|
|
|
ViewData["nuget client "] = "nuget {clientVersionId}";
|
|
|
|
ViewData["nuget client"] = "nuget {clientVersionId}";
|
|
|
|
|
|
|
|
|
|
|
|
var clearkey = protector.Unprotect(apiKey);
|
|
|
|
var clearkey = protector.Unprotect(apiKey);
|
|
|
|
if (clearkey!= Startup.RootApiKeySecret)
|
|
|
|
if (clearkey!= Startup.RootApiKeySecret)
|
|
|
@ -56,23 +58,23 @@ namespace nuget_host.Controllers
|
|
|
|
using (FileStream fw = new FileStream(initpath, FileMode.Open))
|
|
|
|
using (FileStream fw = new FileStream(initpath, FileMode.Open))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var archive = new System.IO.Compression.ZipArchive(fw);
|
|
|
|
var archive = new System.IO.Compression.ZipArchive(fw);
|
|
|
|
foreach (var filename in archive.GetFiles())
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var entry in archive.Entries)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (filename.EndsWith(".nuspec"))
|
|
|
|
if (entry.FullName.EndsWith(".nuspec"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// var entry = archive.GetEntry(filename);
|
|
|
|
// var entry = archive.GetEntry(filename);
|
|
|
|
var specstr = archive.OpenFile(filename);
|
|
|
|
var specstr = entry.Open();
|
|
|
|
NuspecReader reader = new NuspecReader(specstr);
|
|
|
|
NuGet.Packaging.Core.NuspecCoreReader reader = new NuspecCoreReader(specstr);
|
|
|
|
|
|
|
|
|
|
|
|
string pkgdesc = reader.GetDescription();
|
|
|
|
string pkgdesc = reader.GetDescription();
|
|
|
|
string pkgid = reader.GetId();
|
|
|
|
string pkgid = reader.GetId();
|
|
|
|
var version = reader.GetVersion();
|
|
|
|
var version = reader.GetVersion();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path = Path.Combine(nugetSettings.PackagesRootDir,
|
|
|
|
path = Path.Combine(nugetSettings.PackagesRootDir,
|
|
|
|
Path.Combine(pkgid,
|
|
|
|
Path.Combine(pkgid,
|
|
|
|
Path.Combine(version.ToFullString(),
|
|
|
|
Path.Combine(version.Version.ToString()),
|
|
|
|
$"{pkgid}-{version}.nupkg")));
|
|
|
|
$"{pkgid}-{version}.nupkg"));
|
|
|
|
var source = new FileInfo(initpath);
|
|
|
|
var source = new FileInfo(initpath);
|
|
|
|
var dest = new FileInfo(path);
|
|
|
|
var dest = new FileInfo(path);
|
|
|
|
var destdir = new DirectoryInfo(dest.DirectoryName);
|
|
|
|
var destdir = new DirectoryInfo(dest.DirectoryName);
|
|
|
|