Minor simplification and cleanup. The record I created didn't work for the 4.7.2 build, so changed it to class.

This commit is contained in:
Michael Yanni 2023-11-13 13:20:00 -08:00
parent b25079d9e6
commit 32c3e4e8d0
6 changed files with 24 additions and 60 deletions

View file

@ -27,15 +27,8 @@ namespace Microsoft.DotNet.Cli.Build
var resultItem = new TaskItem(item); var resultItem = new TaskItem(item);
item.CopyMetadataTo(resultItem); item.CopyMetadataTo(resultItem);
if (File.Exists(resultItem.GetMetadata("FullPath")) && var isPe = File.Exists(resultItem.GetMetadata("FullPath")) && HasMetadata(resultItem.GetMetadata("FullPath"));
HasMetadata(resultItem.GetMetadata("FullPath"))) resultItem.SetMetadata("IsPE", isPe.ToString());
{
resultItem.SetMetadata("IsPE", "True");
}
else
{
resultItem.SetMetadata("IsPE", "False");
}
resultItemsList.Add(resultItem); resultItemsList.Add(resultItem);
} }

View file

@ -27,7 +27,6 @@ namespace Microsoft.DotNet.Cli.Build
private const string s_dotnetBlobContainerName = "dotnet"; private const string s_dotnetBlobContainerName = "dotnet";
private string _connectionString { get; set; }
private string _containerName { get; set; } private string _containerName { get; set; }
private CloudBlobContainer _blobContainer { get; set; } private CloudBlobContainer _blobContainer { get; set; }
@ -41,14 +40,7 @@ namespace Microsoft.DotNet.Cli.Build
{ {
var storageCredentials = new StorageCredentials(accountName, accountKey); var storageCredentials = new StorageCredentials(accountName, accountKey);
var storageAccount = new CloudStorageAccount(storageCredentials, true); var storageAccount = new CloudStorageAccount(storageCredentials, true);
return GetDotnetBlobContainer(storageAccount, containerName); return storageAccount.CreateCloudBlobClient().GetContainerReference(containerName);
}
private CloudBlobContainer GetDotnetBlobContainer(CloudStorageAccount storageAccount, string containerName)
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
return blobClient.GetContainerReference(containerName);
} }
public string UploadFile(string file, Product product, string version) public string UploadFile(string file, Product product, string version)
@ -105,11 +97,7 @@ namespace Microsoft.DotNet.Cli.Build
} }
} }
public IEnumerable<string> ListBlobs(Product product, string version) public IEnumerable<string> ListBlobs(Product product, string version) => ListBlobs($"{product}/{version}");
{
string virtualDirectory = $"{product}/{version}";
return ListBlobs(virtualDirectory);
}
public IEnumerable<string> ListBlobs(string virtualDirectory) public IEnumerable<string> ListBlobs(string virtualDirectory)
{ {
@ -120,10 +108,7 @@ namespace Microsoft.DotNet.Cli.Build
return blobFiles.Results.Select(bf => bf.Uri.PathAndQuery.Replace($"/{_containerName}/", string.Empty)); return blobFiles.Results.Select(bf => bf.Uri.PathAndQuery.Replace($"/{_containerName}/", string.Empty));
} }
public string AcquireLeaseOnBlob( public string AcquireLeaseOnBlob(string blob, TimeSpan? maxWaitDefault = null, TimeSpan? delayDefault = null)
string blob,
TimeSpan? maxWaitDefault = null,
TimeSpan? delayDefault = null)
{ {
TimeSpan maxWait = maxWaitDefault ?? TimeSpan.FromSeconds(120); TimeSpan maxWait = maxWaitDefault ?? TimeSpan.FromSeconds(120);
TimeSpan delay = delayDefault ?? TimeSpan.FromMilliseconds(500); TimeSpan delay = delayDefault ?? TimeSpan.FromMilliseconds(500);
@ -194,13 +179,11 @@ namespace Microsoft.DotNet.Cli.Build
try try
{ {
DeleteBlob(path); DeleteBlob(path);
return true; return true;
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine($"Deleting blob {path} failed with \r\n{e.Message}"); Console.WriteLine($"Deleting blob {path} failed with \r\n{e.Message}");
return false; return false;
} }
} }

View file

@ -114,32 +114,29 @@ namespace Microsoft.DotNet.Build.Tasks
// --verbose : Set verbose output for FPM tool --Static // --verbose : Set verbose output for FPM tool --Static
// <All folder mappings> : Add all the folder mappings for package_root, docs, man pages --Static // <All folder mappings> : Add all the folder mappings for package_root, docs, man pages --Static
var parameters = new List<string>(); var parameters = new List<string>
parameters.Add("-s dir"); {
parameters.Add("-t rpm"); "-s dir",
parameters.Add(string.Concat("-n ", configJson.Package_Name)); "-t rpm",
parameters.Add(string.Concat("-v ", package_version)); string.Concat("-n ", configJson.Package_Name),
parameters.Add(string.Concat("-a ", configJson.Control.Architecture)); string.Concat("-v ", package_version),
string.Concat("-a ", configJson.Control.Architecture)
};
// Build the list of dependencies as -d <dep1> -d <dep2> // Build the list of dependencies as -d <dep1> -d <dep2>
if (configJson.Rpm_Dependencies != null) if (configJson.Rpm_Dependencies != null)
{ {
foreach (RpmDependency rpmdep in configJson.Rpm_Dependencies) foreach (RpmDependency rpmdep in configJson.Rpm_Dependencies)
{ {
string dependency = "";
if (rpmdep.Package_Name != "") if (rpmdep.Package_Name != "")
{ {
// If no version is specified then the dependency is just the package without >= check // If no version is specified then the dependency is just the package without >= check
if (rpmdep.Package_Version == "") string dependency = rpmdep.Package_Version != "" ?
{ string.Concat(rpmdep.Package_Name, " >= ", rpmdep.Package_Version) :
dependency = rpmdep.Package_Name; rpmdep.Package_Name;
parameters.Add(string.Concat("-d ", EscapeArg(dependency)));
} }
else
{
dependency = string.Concat(rpmdep.Package_Name, " >= ", rpmdep.Package_Version);
}
}
if (dependency != "") parameters.Add(string.Concat("-d ", EscapeArg(dependency)));
} }
} }
@ -180,14 +177,11 @@ namespace Microsoft.DotNet.Build.Tasks
// Map all the payload directories as they need to install on the system // Map all the payload directories as they need to install on the system
if (configJson.Install_Root != null) if (configJson.Install_Root != null)
parameters.Add(string.Concat(Path.Combine(InputDir, "package_root/="), parameters.Add(string.Concat(Path.Combine(InputDir, "package_root/="), configJson.Install_Root)); // Package Files
configJson.Install_Root)); // Package Files
if (configJson.Install_Man != null) if (configJson.Install_Man != null)
parameters.Add(string.Concat(Path.Combine(InputDir, "docs", "host/="), parameters.Add(string.Concat(Path.Combine(InputDir, "docs", "host/="), configJson.Install_Man)); // Man Pages
configJson.Install_Man)); // Man Pages
if (configJson.Install_Doc != null) if (configJson.Install_Doc != null)
parameters.Add(string.Concat(Path.Combine(InputDir, "templates", "copyright="), parameters.Add(string.Concat(Path.Combine(InputDir, "templates", "copyright="), configJson.Install_Doc)); // CopyRight File
configJson.Install_Doc)); // CopyRight File
return string.Join(" ", parameters); return string.Join(" ", parameters);
} }
@ -217,14 +211,12 @@ namespace Microsoft.DotNet.Build.Tasks
{ {
sb.Append('\\', 2 * backslashCount); sb.Append('\\', 2 * backslashCount);
} }
// Escape any preceding backslashes and the quote // Escape any preceding backslashes and the quote
else if (arg[i] == '"') else if (arg[i] == '"')
{ {
sb.Append('\\', (2 * backslashCount) + 1); sb.Append('\\', (2 * backslashCount) + 1);
sb.Append('"'); sb.Append('"');
} }
// Output any consumed backslashes and the character // Output any consumed backslashes and the character
else else
{ {
@ -252,6 +244,7 @@ namespace Microsoft.DotNet.Build.Tasks
{ {
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -124,7 +124,7 @@ namespace Microsoft.DotNet.Cli.Build
} }
} }
public record BundledTemplate public class BundledTemplate
{ {
public string InstallPath { get; set; } public string InstallPath { get; set; }
public string MajorMinorVersion { get; set; } public string MajorMinorVersion { get; set; }

View file

@ -121,8 +121,6 @@ namespace Microsoft.DotNet.Build.Tasks
private string GetCreateSymbols() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "--pdb" : "--perfmap"; private string GetCreateSymbols() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "--pdb" : "--perfmap";
private string GetReadyToRun() => ReadyToRun ? "-readytorun" : null;
private string GetInPath() => $"\"{SourceAssembly}\""; private string GetInPath() => $"\"{SourceAssembly}\"";
private string GetOutPath() => $"-o \"{TempOutputPath}\""; private string GetOutPath() => $"-o \"{TempOutputPath}\"";
@ -141,8 +139,6 @@ namespace Microsoft.DotNet.Build.Tasks
return platformAssemblyPaths; return platformAssemblyPaths;
} }
private string GetMissingDependenciesOk() => "-MissingDependenciesOK";
protected override void LogToolCommand(string message) => base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); protected override void LogToolCommand(string message) => base.LogToolCommand($"{GetWorkingDirectory()}> {message}");
} }
} }

View file

@ -12,7 +12,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
/// </summary> /// </summary>
internal static class FileNameUtilities internal static class FileNameUtilities
{ {
private const string DirectorySeparatorStr = "\\";
internal const char DirectorySeparatorChar = '\\'; internal const char DirectorySeparatorChar = '\\';
internal const char AltDirectorySeparatorChar = '/'; internal const char AltDirectorySeparatorChar = '/';
internal const char VolumeSeparatorChar = ':'; internal const char VolumeSeparatorChar = ':';