Skip to content

Commit

Permalink
Force to Download Package
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Dec 7, 2024
1 parent 4f157d2 commit b2033b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 47 deletions.
3 changes: 3 additions & 0 deletions Build/IAzureSignTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public interface IAzureSignTool : IClean, ICompile
.Executes(() =>
{
ricaun.Nuke.Tools.AzureSignToolUtils.DownloadAzureSignTool();
Serilog.Log.Information("DownloadAzureSignTool");
ricaun.Nuke.Tools.AzureSignToolUtils.DownloadNuGetKeyVaultSignTool();
Serilog.Log.Information("DownloadNuGetKeyVaultSignTool");

ricaun.Nuke.Tools.AzureSignToolUtils.EnsureAzureToolIsInstalled();
Serilog.Log.Information("EnsureAzureToolIsInstalled");
});
}
57 changes: 11 additions & 46 deletions ricaun.Nuke/Tools/AzureSignToolUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.IO;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.IO;
using Nuke.Common.Tooling;

namespace ricaun.Nuke.Tools
{
Expand Down Expand Up @@ -78,16 +79,13 @@ private static string PackageDownload(string packageId)
/// </summary>
public static void DownloadAzureSignTool()
{
try
{
_ = AzureSignToolTasks.AzureSignToolPath;
}
catch (Exception)
var packageId = AzureSignToolTasks.AzureSignToolPackageId;
var packageIdExe = packageId.ToUpper() + "_EXE";

if (ToolPathResolver.TryGetEnvironmentExecutable(packageIdExe) is null)
{
var packageId = AzureSignToolTasks.AzureSignToolPackageId;
var packageToolExe = PackageDownload(packageId);

Environment.SetEnvironmentVariable(packageId.ToUpper() + "_EXE", packageToolExe);
Environment.SetEnvironmentVariable(packageIdExe, packageToolExe);
}

_ = AzureSignToolTasks.AzureSignToolPath;
Expand All @@ -98,51 +96,18 @@ public static void DownloadAzureSignTool()
/// </summary>
public static void DownloadNuGetKeyVaultSignTool()
{
try
{
_ = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPath;
}
catch (Exception)
var packageId = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPackageId;
var packageIdExe = packageId.ToUpper() + "_EXE";

if (ToolPathResolver.TryGetEnvironmentExecutable(packageIdExe) is null)
{
var packageId = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPackageId;
var packageToolExe = PackageDownload(packageId);

Environment.SetEnvironmentVariable(packageId.ToUpper() + "_EXE", packageToolExe);
Environment.SetEnvironmentVariable(packageIdExe, packageToolExe);
}

_ = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPath;
}

private static void DownloadNuGetKeyVaultSignTool_()
{
try
{
_ = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPath;
}
catch (Exception)
{
var toolFolder = GetToolInstallationPath();
var packageId = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPackageId;

if (Globbing.GlobFiles(toolFolder, $"{packageId}.exe").FirstOrDefault() is AbsolutePath packageToolPathExists)
{
Environment.SetEnvironmentVariable(packageId.ToUpper() + "_EXE", packageToolPathExists);
}

DotNetTasks.DotNetToolInstall(x => x
.SetPackageName(packageId)
.SetToolInstallationPath(toolFolder)
);

if (Globbing.GlobFiles(toolFolder, $"{packageId}.exe").FirstOrDefault() is AbsolutePath packageToolPath)
{
Environment.SetEnvironmentVariable(packageId.ToUpper() + "_EXE", packageToolPath);
}
}

_ = NuGetKeyVaultSignToolTasks.NuGetKeyVaultSignToolPath;
}

/// <summary>
/// Signs the specified file using Azure Sign Tool or NuGet Key Vault Sign Tool.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion ricaun.Nuke/ricaun.Nuke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<PropertyGroup>
<PackageId>ricaun.Nuke</PackageId>
<Version>1.9.0-alpha.4</Version>
<Version>1.9.0-alpha.5</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit b2033b2

Please sign in to comment.