-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
PackageDownloadUtils
to force download tool package in local to…
…ol folder
- Loading branch information
Showing
5 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Nuke.Common.IO; | ||
using System.IO; | ||
using Nuke.Common.Tools.DotNet; | ||
using System.Linq; | ||
|
||
namespace Nuke.NuGetKeyVaultSignTool | ||
{ | ||
public class PackageDownloadUtils | ||
{ | ||
private static AbsolutePath GetToolInstallationPath() | ||
{ | ||
AbsolutePath folder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | ||
return folder / "Tools"; | ||
} | ||
|
||
public static string PackageDownload(string packageId) | ||
{ | ||
var toolFolder = GetToolInstallationPath(); | ||
|
||
if (Globbing.GlobFiles(toolFolder, $"{packageId}.exe").FirstOrDefault() is AbsolutePath packageToolExeExists) | ||
{ | ||
return packageToolExeExists; | ||
} | ||
|
||
DotNetTasks.DotNetToolInstall(x => x | ||
.SetPackageName(packageId) | ||
.SetToolInstallationPath(toolFolder) | ||
); | ||
|
||
if (Globbing.GlobFiles(toolFolder, $"{packageId}.exe").FirstOrDefault() is AbsolutePath packageToolExe) | ||
{ | ||
return packageToolExe; | ||
} | ||
return null; | ||
} | ||
} | ||
} |