Skip to content

Commit

Permalink
consolidated nuget version and added more data to failed index of pac…
Browse files Browse the repository at this point in the history
…kages
  • Loading branch information
SergeyFilippov committed Nov 15, 2023
1 parent bec27b2 commit 1dfd84c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
11 changes: 10 additions & 1 deletion src/BaGet.Core/Indexing/PackageIndexingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ public async Task<PackageIndexingResult> IndexAsync(Stream packageStream, Cancel
Stream readmeStream;
Stream iconStream;

string packageProcessedName = string.Empty;

try
{
using (var packageReader = new PackageArchiveReader(packageStream, leaveStreamOpen: true))
{
package = packageReader.GetPackageMetadata();
package.Published = _time.UtcNow;
packageProcessedName = package.Title + ":" + package.Version;

nuspecStream = await packageReader.GetNuspecAsync(cancellationToken);
nuspecStream = await nuspecStream.AsTemporaryFileStreamAsync(cancellationToken);
Expand Down Expand Up @@ -74,7 +77,13 @@ public async Task<PackageIndexingResult> IndexAsync(Stream packageStream, Cancel
}
catch (Exception e)
{
_logger.LogError(e, "Uploaded package is invalid");
var message = "Uploaded package is invalid.";
if (!string.IsNullOrEmpty(packageProcessedName))
{
message += Environment.NewLine + packageProcessedName;
}

_logger.LogError(e, message);

return PackageIndexingResult.InvalidPackage;
}
Expand Down

0 comments on commit 1dfd84c

Please sign in to comment.