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);
item.CopyMetadataTo(resultItem);
if (File.Exists(resultItem.GetMetadata("FullPath")) &&
HasMetadata(resultItem.GetMetadata("FullPath")))
{
resultItem.SetMetadata("IsPE", "True");
}
else
{
resultItem.SetMetadata("IsPE", "False");
}
var isPe = File.Exists(resultItem.GetMetadata("FullPath")) && HasMetadata(resultItem.GetMetadata("FullPath"));
resultItem.SetMetadata("IsPE", isPe.ToString());
resultItemsList.Add(resultItem);
}

View file

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

View file

@ -114,32 +114,29 @@ namespace Microsoft.DotNet.Build.Tasks
// --verbose : Set verbose output for FPM tool --Static
// <All folder mappings> : Add all the folder mappings for package_root, docs, man pages --Static
var parameters = new List<string>();
parameters.Add("-s dir");
parameters.Add("-t rpm");
parameters.Add(string.Concat("-n ", configJson.Package_Name));
parameters.Add(string.Concat("-v ", package_version));
parameters.Add(string.Concat("-a ", configJson.Control.Architecture));
var parameters = new List<string>
{
"-s dir",
"-t rpm",
string.Concat("-n ", configJson.Package_Name),
string.Concat("-v ", package_version),
string.Concat("-a ", configJson.Control.Architecture)
};
// Build the list of dependencies as -d <dep1> -d <dep2>
if (configJson.Rpm_Dependencies != null)
{
foreach (RpmDependency rpmdep in configJson.Rpm_Dependencies)
{
string dependency = "";
if (rpmdep.Package_Name != "")
{
// If no version is specified then the dependency is just the package without >= check
if (rpmdep.Package_Version == "")
{
dependency = rpmdep.Package_Name;
}
else
{
dependency = string.Concat(rpmdep.Package_Name, " >= ", rpmdep.Package_Version);
}
string dependency = rpmdep.Package_Version != "" ?
string.Concat(rpmdep.Package_Name, " >= ", rpmdep.Package_Version) :
rpmdep.Package_Name;
parameters.Add(string.Concat("-d ", EscapeArg(dependency)));
}
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
if (configJson.Install_Root != null)
parameters.Add(string.Concat(Path.Combine(InputDir, "package_root/="),
configJson.Install_Root)); // Package Files
parameters.Add(string.Concat(Path.Combine(InputDir, "package_root/="), configJson.Install_Root)); // Package Files
if (configJson.Install_Man != null)
parameters.Add(string.Concat(Path.Combine(InputDir, "docs", "host/="),
configJson.Install_Man)); // Man Pages
parameters.Add(string.Concat(Path.Combine(InputDir, "docs", "host/="), configJson.Install_Man)); // Man Pages
if (configJson.Install_Doc != null)
parameters.Add(string.Concat(Path.Combine(InputDir, "templates", "copyright="),
configJson.Install_Doc)); // CopyRight File
parameters.Add(string.Concat(Path.Combine(InputDir, "templates", "copyright="), configJson.Install_Doc)); // CopyRight File
return string.Join(" ", parameters);
}
@ -217,14 +211,12 @@ namespace Microsoft.DotNet.Build.Tasks
{
sb.Append('\\', 2 * backslashCount);
}
// Escape any preceding backslashes and the quote
else if (arg[i] == '"')
{
sb.Append('\\', (2 * backslashCount) + 1);
sb.Append('"');
}
// Output any consumed backslashes and the character
else
{
@ -252,6 +244,7 @@ namespace Microsoft.DotNet.Build.Tasks
{
return true;
}
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 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 GetReadyToRun() => ReadyToRun ? "-readytorun" : null;
private string GetInPath() => $"\"{SourceAssembly}\"";
private string GetOutPath() => $"-o \"{TempOutputPath}\"";
@ -141,8 +139,6 @@ namespace Microsoft.DotNet.Build.Tasks
return platformAssemblyPaths;
}
private string GetMissingDependenciesOk() => "-MissingDependenciesOK";
protected override void LogToolCommand(string message) => base.LogToolCommand($"{GetWorkingDirectory()}> {message}");
}
}

View file

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