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

Remove NUGET_v2 stuff #1215

Open
wants to merge 2 commits 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
6 changes: 3 additions & 3 deletions source/Calamari.Common/Calamari.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
<DefineConstants>$(DefineConstants);USE_ALPHAFS_FOR_LONG_FILE_PATH_SUPPORT;HAS_SSL3</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<DefineConstants>$(DefineConstants);USE_NUGET_V3_LIBS;WORKAROUND_FOR_EMPTY_STRING_BUG;HAS_NULLABLE_REF_TYPES</DefineConstants>
<DefineConstants>$(DefineConstants);WORKAROUND_FOR_EMPTY_STRING_BUG;HAS_NULLABLE_REF_TYPES</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net462' ">
<NoWarn>CS8600;CS8601;CS8602;CS8603;CS8604</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="NuGet.Commands" Version="3.5.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
Expand All @@ -28,14 +27,15 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net462' ">
<Reference Include="System.Security" />
<Reference Include="System.Net" />
<PackageReference Include="NuGet.CommandLine" Version="2.8.6" />
<PackageReference Include="NuGet.Core" Version="2.14.0" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
<PackageReference Include="AlphaFS" Version="2.1.3-octopus0006" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="4.8.0" />
<PackageReference Include="NuGet.CommandLine" Version="4.9.6" />
<PackageReference Include="NuGet.Commands" Version="4.9.6" />
<PackageReference Include="Globfish" Version="1.0.4" />
<PackageReference Include="JavaPropertiesParser" Version="0.2.1" />
<PackageReference Include="Microsoft.Web.Xdt" Version="3.1.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#if USE_NUGET_V3_LIBS
using NuGet.Packaging;
#else
using NuGet;
#endif
using NuGet.Packaging;
using System;
using System.IO;
using Calamari.Common.Plumbing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if USE_NUGET_V3_LIBS
using System;
using System;
using NuGet.Versioning;
using Octopus.Versioning;

Expand All @@ -23,5 +22,4 @@ public static NuGetVersion ToNuGetVersion(this IVersion version)
version.Metadata);
}
}
}
#endif
}
8 changes: 3 additions & 5 deletions source/Calamari.Shared/Calamari.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<TargetFrameworks>net462;netstandard2.1</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
<DefineConstants>$(DefineConstants);USE_NUGET_V2_LIBS;SUPPORTS_POLLY;USE_OCTODIFF_EXE;WINDOWS_CERTIFICATE_STORE_SUPPORT</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_POLLY;USE_OCTODIFF_EXE;WINDOWS_CERTIFICATE_STORE_SUPPORT</DefineConstants>
<PlatformTarget>anycpu</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<DefineConstants>$(DefineConstants);USE_NUGET_V3_LIBS;SUPPORTS_POLLY</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_POLLY</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462' ">
<NoWarn>CS8600;CS8601;CS8602;CS8603;CS8604;DE0003;DE0004</NoWarn>
Expand All @@ -56,9 +56,9 @@
<PackageReference Include="Microsoft.Web.Xdt" Version="3.1.0" />
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
<PackageReference Include="Polly" Version="5.4.0" />
<PackageReference Include="NuGet.Commands" Version="4.9.6" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="NuGet.Commands" Version="3.5.0" />
<PackageReference Include="Markdown" Version="2.1.0" />
<PackageReference Include="System.Threading.AccessControl" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
Expand All @@ -73,8 +73,6 @@
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
<PackageReference Include="Microsoft.Web.Administration" Version="7.0.0.0" />
<PackageReference Include="Microsoft.Web.Deployment" Version="3.6.0" />
<PackageReference Include="NuGet.CommandLine" Version="2.8.6" />
<PackageReference Include="NuGet.Core" Version="2.14.0" />
<PackageReference Include="AlphaFS" Version="2.1.3-octopus0006" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration.Install" />
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
using Calamari.Integration.Packages.NuGet;
using Octopus.Versioning;
using PackageName = Calamari.Common.Features.Packages.PackageName;
#if USE_NUGET_V2_LIBS
using NuGet;
#else
using NuGet.Packaging;
#endif

namespace Calamari.Integration.Packages.Download
{
Expand Down Expand Up @@ -124,11 +119,8 @@ PackagePhysicalFileMetadata DownloadPackage(
void CheckWhetherThePackageHasDependencies(PackagePhysicalFileMetadata pkg)
{
var nuGetMetadata = new LocalNuGetPackage(pkg.FullFilePath).Metadata;
#if USE_NUGET_V3_LIBS
var dependencies = nuGetMetadata.DependencyGroups.SelectMany(ds => ds.Packages).ToArray();
#else
var dependencies = nuGetMetadata.DependencySets.SelectMany(ds => ds.Dependencies).ToArray();
#endif

if (dependencies.Any())
Log.Info(
"NuGet packages with dependencies are not currently supported, and dependencies won't be installed on the Tentacle. The package '{0} {1}' appears to have the following dependencies: {2}. For more information please see {3}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,61 +98,11 @@ private void DownloadPackageAction(string packageId, IVersion version, Uri feedU
return;
}

#if USE_NUGET_V2_LIBS
var timeout = GetHttpTimeout();

if (IsHttp(feedUri.ToString()))
{
if (NuGetV3Downloader.CanHandle(feedUri, feedCredentials, timeout))
{
NuGetV3Downloader.DownloadPackage(packageId, version, feedUri, feedCredentials, targetFilePath, timeout);
}
else
{
WarnIfHttpTimeoutHasBeenSet();
NuGetV2Downloader.DownloadPackage(packageId, version.ToString(), feedUri, feedCredentials, targetFilePath);
}
}
#else
else
{
WarnIfHttpTimeoutHasBeenSet();
NuGetV3LibDownloader.DownloadPackage(packageId, version, feedUri, feedCredentials, targetFilePath);
}
#endif
}

#if USE_NUGET_V2_LIBS
TimeSpan GetHttpTimeout()
{
const string expectedTimespanFormat = "c";

// Equal to Timeout.InfiniteTimeSpan, which isn't available in net40
var defaultTimeout = new TimeSpan(0, 0, 0, 0, -1);

var rawTimeout = variables.Get(KnownVariables.NugetHttpTimeout);
if (string.IsNullOrWhiteSpace(rawTimeout))
{
return defaultTimeout;
}

if (TimeSpan.TryParseExact(rawTimeout, expectedTimespanFormat, null, out var parsedTimeout))
{
return parsedTimeout;
}

var exampleTimespan = new TimeSpan(0, 0, 1, 0).ToString(expectedTimespanFormat);

var message = $"The variable {KnownVariables.NugetHttpTimeout} couldn't be parsed as a timespan. " +
$"Expected a value like '{exampleTimespan}' but received '{rawTimeout}'. " +
$"Defaulting to '{defaultTimeout.ToString(expectedTimespanFormat)}'.";

Log.Warn(message);
return defaultTimeout;
WarnIfHttpTimeoutHasBeenSet();
NuGetV3LibDownloader.DownloadPackage(packageId, version, feedUri, feedCredentials, targetFilePath);
}

#endif

void WarnIfHttpTimeoutHasBeenSet()
{
if (variables.IsSet(KnownVariables.NugetHttpTimeout))
Expand Down
Loading