Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sast/ds/nuget library upgrade from octo #1067

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageReference Include="NLog" Version="5.0.4" />
<PackageReference Include="NuGet.Common" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Frameworks" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging.Core" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging.Core.Types" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Versioning" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Common" Version="6.13.1" />
<PackageReference Include="NuGet.Frameworks" Version="6.13.1" />
<PackageReference Include="NuGet.Packaging" Version="6.13.1" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.9.1" />
<PackageReference Include="NuGet.Packaging.Core.Types" Version="4.2.0" />
<PackageReference Include="NuGet.Versioning" Version="6.13.1" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="TaskScheduler" Version="2.7.2" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion source/Octopus.Tentacle/Commands/ExtractCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ protected override void Start()
{
try
{
var extracted = packageInstaller.Value.Install(packageFile, destinationDirectory, log, true);
var extractedTask = packageInstaller.Value.Install(packageFile, destinationDirectory, log, true, CancellationToken.None);
var extracted = extractedTask.GetAwaiter().GetResult();
log.Info($"{extracted:n0} files extracted");
return;
}
Expand Down
10 changes: 4 additions & 6 deletions source/Octopus.Tentacle/Octopus.Tentacle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.2" />
<PackageReference Include="NuGet.Common" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Frameworks" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging.Core" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Packaging.Core.Types" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Versioning" Version="3.6.0-octopus-58692" />
<PackageReference Include="NuGet.Common" Version="6.13.1" />
<PackageReference Include="NuGet.Frameworks" Version="6.13.1" />
<PackageReference Include="NuGet.Packaging" Version="6.13.1" />
<PackageReference Include="NuGet.Versioning" Version="6.13.1" />
<PackageReference Include="Octopus.Diagnostics" Version="2.1.0" />
<PackageReference Include="Octopus.Time" Version="1.1.339" />
<PackageReference Include="Polly" Version="7.2.2" />
Expand Down
6 changes: 4 additions & 2 deletions source/Octopus.Tentacle/Packages/IPackageInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Octopus.Diagnostics;

namespace Octopus.Tentacle.Packages
{
public interface IPackageInstaller
{
int Install(string packageFile, string directory, ILog log, bool suppressNestedScriptWarning);
int Install(Stream packageStream, string directory, ILog log, bool suppressNestedScriptWarning);
Task<int> Install(string packageFile, string directory, ILog log, bool suppressNestedScriptWarning, CancellationToken cancellationToken);
Task<int> Install(Stream packageStream, string directory, ILog log, bool suppressNestedScriptWarning, CancellationToken cancellationToken);
}
}
20 changes: 12 additions & 8 deletions source/Octopus.Tentacle/Packages/NuGetPackageInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Common;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Configuration;
using Octopus.Diagnostics;
using Octopus.Tentacle.Util;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Packaging.Signing;

namespace Octopus.Tentacle.Packages
{
Expand All @@ -19,20 +22,21 @@ public NuGetPackageInstaller(IOctopusFileSystem fileSystem)
this.fileSystem = fileSystem;
}

public int Install(string packageFile, string directory, ILog log, bool suppressNestedScriptWarning)
public async Task<int> Install(string packageFile, string directory, ILog log, bool suppressNestedScriptWarning, CancellationToken cancellationToken)
{
using (var packageStream = fileSystem.OpenFile(packageFile, FileMode.Open, FileAccess.Read))
{
return Install(packageStream, directory, log, suppressNestedScriptWarning);
return await Install(packageStream, directory, log, suppressNestedScriptWarning, cancellationToken);
}
}

public int Install(Stream packageStream, string directory, ILog log, bool suppressNestedScriptWarning)
public async Task<int> Install(Stream packageStream, string directory, ILog log, bool suppressNestedScriptWarning, CancellationToken cancellationToken)
{
var extracted = PackageExtractor.ExtractPackage(packageStream,
var extracted = await PackageExtractor.ExtractPackageAsync(
string.Empty,
packageStream,
new SuppliedDirectoryPackagePathResolver(directory),
new PackageExtractionContext(NullLogger.Instance) { PackageSaveMode = PackageSaveMode.Files, XmlDocFileSaveMode = XmlDocFileSaveMode.None, CopySatelliteFiles = false },
CancellationToken.None);
new PackageExtractionContext(PackageSaveMode.Files, XmlDocFileSaveMode.None, ClientPolicyContext.GetClientPolicy(new NullSettings(), new NullLogger()), new NullLogger()) { CopySatelliteFiles = false }, cancellationToken);

return extracted.Count();
}
Expand Down