Lots of minor cleanup and simplification.
This commit is contained in:
parent
c42fb4c641
commit
b25079d9e6
12 changed files with 56 additions and 135 deletions
|
@ -62,20 +62,20 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
BundledTemplatesWithInstallPaths = BundledTemplates.Select(t =>
|
||||
{
|
||||
var templateWithInstallPath = new TaskItem(t);
|
||||
templateWithInstallPath.SetMetadata("BundledTemplateInstallPath", groups[t.GetMetadata("TemplateFrameworkVersion")].BundledTemplateInstallPath);
|
||||
templateWithInstallPath.SetMetadata("BundledTemplateInstallPath", groups[t.GetMetadata("TemplateFrameworkVersion")].InstallPath);
|
||||
return templateWithInstallPath;
|
||||
}).ToArray();
|
||||
|
||||
TemplatesComponents = groups.Select(g =>
|
||||
{
|
||||
string majorMinorWithoutDots = g.Value.BundledTemplateMajorMinorVersion.Replace(".", "");
|
||||
string majorMinorWithoutDots = g.Value.MajorMinorVersion.Replace(".", "");
|
||||
var componentItem = new TaskItem($"NetCore{majorMinorWithoutDots}Templates");
|
||||
var templateBaseFilename = $"dotnet-{majorMinorWithoutDots}templates";
|
||||
componentItem.SetMetadata("TemplateBaseFilename", templateBaseFilename);
|
||||
componentItem.SetMetadata("TemplatesMajorMinorVersion", g.Value.BundledTemplateMajorMinorVersion);
|
||||
componentItem.SetMetadata("TemplatesMajorMinorVersion", g.Value.MajorMinorVersion);
|
||||
var installerUpgradeCode = GenerateGuidFromName.GenerateGuid(string.Join("-", templateBaseFilename, FullNugetVersion, ProductMonikerRid) + InstallerExtension).ToString().ToUpper();
|
||||
componentItem.SetMetadata("InstallerUpgradeCode", installerUpgradeCode);
|
||||
componentItem.SetMetadata("MSIVersion", GenerateMsiVersionFromFullVersion.GenerateMsiVersion(CombinedBuildNumberAndRevision, g.Value.BundledTemplateMajorMinorPatchVersion));
|
||||
componentItem.SetMetadata("MSIVersion", GenerateMsiVersionFromFullVersion.GenerateMsiVersion(CombinedBuildNumberAndRevision, g.Value.MajorMinorPatchVersion));
|
||||
|
||||
var brandName = System.Version.Parse(g.Key).Major >= 5 ?
|
||||
$"Microsoft .NET {g.Key} Templates" :
|
||||
|
@ -89,24 +89,20 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return true;
|
||||
}
|
||||
|
||||
public static
|
||||
(string BundledTemplateInstallPath,
|
||||
string BundledTemplateMajorMinorVersion,
|
||||
string BundledTemplateMajorMinorPatchVersion)
|
||||
Calculate(string aspNetCorePackageVersionTemplate)
|
||||
public static BundledTemplate Calculate(string aspNetCorePackageVersionTemplate)
|
||||
{
|
||||
var aspNetCoreTemplate = NuGetVersion.Parse(aspNetCorePackageVersionTemplate);
|
||||
|
||||
NuGetVersion baseMajorMinorPatch = GetBaseMajorMinorPatch(aspNetCoreTemplate);
|
||||
|
||||
string bundledTemplateInstallPath = aspNetCoreTemplate.IsPrerelease
|
||||
? $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}-{aspNetCoreTemplate.Release}"
|
||||
: $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}";
|
||||
|
||||
return (
|
||||
bundledTemplateInstallPath,
|
||||
$"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}",
|
||||
$"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}");
|
||||
return new BundledTemplate
|
||||
{
|
||||
InstallPath = bundledTemplateInstallPath,
|
||||
MajorMinorVersion = $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}",
|
||||
MajorMinorPatchVersion = $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}"
|
||||
};
|
||||
}
|
||||
|
||||
private static NuGetVersion GetBaseMajorMinorPatch(NuGetVersion aspNetCoreTemplate)
|
||||
|
@ -127,4 +123,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return baseMajorMinorPatch;
|
||||
}
|
||||
}
|
||||
|
||||
public record BundledTemplate
|
||||
{
|
||||
public string InstallPath { get; set; }
|
||||
public string MajorMinorVersion { get; set; }
|
||||
public string MajorMinorPatchVersion { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
private string GetMode() => Mode;
|
||||
|
||||
private string GetRecursive()
|
||||
{
|
||||
if(Recursive)
|
||||
{
|
||||
return "--recursive";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private string GetRecursive() => Recursive ? "--recursive" : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build.Framework
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
//public static readonly string ProjectFileName = "project.json";
|
||||
public static readonly string ExeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Build.Framework;
|
||||
|
@ -63,11 +62,11 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
if (toolResult)
|
||||
{
|
||||
var files = Directory.GetFiles(Path.GetDirectoryName(TempOutputPath));
|
||||
var dest = Path.GetDirectoryName(DestinationPath);
|
||||
var destination = Path.GetDirectoryName(DestinationPath);
|
||||
// Copy both dll and pdb files to the destination folder
|
||||
foreach(var file in files)
|
||||
{
|
||||
File.Copy(file, Path.Combine(dest, Path.GetFileName(file)), overwrite: true);
|
||||
File.Copy(file, Path.Combine(destination, Path.GetFileName(file)), overwrite: true);
|
||||
// Delete file in temp
|
||||
File.Delete(file);
|
||||
}
|
||||
|
@ -84,13 +83,11 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
|
||||
protected override string ToolName => "crossgen2";
|
||||
|
||||
protected override MessageImportance StandardOutputLoggingImportance
|
||||
// Default is low, but we want to see output at normal verbosity.
|
||||
=> MessageImportance.Normal;
|
||||
// Default is low, but we want to see output at normal verbosity.
|
||||
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.Normal;
|
||||
|
||||
protected override MessageImportance StandardErrorLoggingImportance
|
||||
// This turns stderr messages into msbuild errors below.
|
||||
=> MessageImportance.High;
|
||||
// This turns stderr messages into msbuild errors below.
|
||||
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||
|
||||
protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance)
|
||||
{
|
||||
|
@ -116,35 +113,15 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
}
|
||||
}
|
||||
|
||||
protected override string GenerateFullPathToTool()
|
||||
{
|
||||
if (CrossgenPath != null)
|
||||
{
|
||||
return CrossgenPath;
|
||||
}
|
||||
|
||||
return "crossgen2";
|
||||
}
|
||||
protected override string GenerateFullPathToTool() => CrossgenPath ?? "crossgen2";
|
||||
|
||||
protected override string GenerateCommandLineCommands() => $"{GetInPath()} {GetOutPath()} {GetArchitecture()} {GetPlatformAssemblyPaths()} {GetCreateSymbols()}";
|
||||
|
||||
private string GetArchitecture() => $"--targetarch {Architecture}";
|
||||
|
||||
private string GetCreateSymbols()
|
||||
{
|
||||
var option = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "--pdb" : "--perfmap";
|
||||
return $"{option}";
|
||||
}
|
||||
private string GetCreateSymbols() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "--pdb" : "--perfmap";
|
||||
|
||||
private string GetReadyToRun()
|
||||
{
|
||||
if (ReadyToRun)
|
||||
{
|
||||
return "-readytorun";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private string GetReadyToRun() => ReadyToRun ? "-readytorun" : null;
|
||||
|
||||
private string GetInPath() => $"\"{SourceAssembly}\"";
|
||||
|
||||
|
@ -152,8 +129,7 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
|
||||
private string GetPlatformAssemblyPaths()
|
||||
{
|
||||
var platformAssemblyPaths = String.Empty;
|
||||
|
||||
var platformAssemblyPaths = string.Empty;
|
||||
if (PlatformAssemblyPaths != null)
|
||||
{
|
||||
foreach (var excludeTaskItem in PlatformAssemblyPaths)
|
||||
|
|
|
@ -37,17 +37,15 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override string GenerateFullPathToTool()
|
||||
{
|
||||
string path = ToolPath;
|
||||
|
||||
// if ToolPath was not provided by the MSBuild script
|
||||
if (string.IsNullOrEmpty(path))
|
||||
if (string.IsNullOrEmpty(ToolPath))
|
||||
{
|
||||
Log.LogError($"Could not find the Path to {ToolName}");
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return path;
|
||||
return ToolPath;
|
||||
}
|
||||
|
||||
protected override string GetWorkingDirectory() => WorkingDirectory ?? base.GetWorkingDirectory();
|
||||
|
@ -65,16 +63,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance) => Log.LogMessage(messageImportance, singleLine, null);
|
||||
|
||||
protected override ProcessStartInfo GetProcessStartInfo(
|
||||
string pathToTool,
|
||||
string commandLineCommands,
|
||||
string responseFileSwitch)
|
||||
protected override ProcessStartInfo GetProcessStartInfo(string pathToTool, string commandLineCommands, string responseFileSwitch)
|
||||
{
|
||||
var psi = base.GetProcessStartInfo(
|
||||
pathToTool,
|
||||
commandLineCommands,
|
||||
responseFileSwitch);
|
||||
|
||||
var psi = base.GetProcessStartInfo(pathToTool, commandLineCommands, responseFileSwitch);
|
||||
foreach (var environmentVariableName in new EnvironmentFilter().GetEnvironmentVariableNamesToRemove())
|
||||
{
|
||||
psi.Environment.Remove(environmentVariableName);
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
|
@ -19,16 +18,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected abstract string Args { get; }
|
||||
|
||||
protected override ProcessStartInfo GetProcessStartInfo(
|
||||
string pathToTool,
|
||||
string commandLineCommands,
|
||||
string responseFileSwitch)
|
||||
protected override ProcessStartInfo GetProcessStartInfo(string pathToTool, string commandLineCommands, string responseFileSwitch)
|
||||
{
|
||||
var psi = base.GetProcessStartInfo(
|
||||
pathToTool,
|
||||
commandLineCommands,
|
||||
responseFileSwitch);
|
||||
|
||||
var psi = base.GetProcessStartInfo(pathToTool, commandLineCommands, responseFileSwitch);
|
||||
foreach (var environmentVariableName in new EnvironmentFilter().GetEnvironmentVariableNamesToRemove())
|
||||
{
|
||||
psi.Environment.Remove(environmentVariableName);
|
||||
|
@ -39,23 +31,21 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
public string WorkingDirectory { get; set; }
|
||||
|
||||
protected override string ToolName => $"dotnet{Constants.ExeSuffix}";
|
||||
protected override string ToolName => $"dotnet{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty)}";
|
||||
|
||||
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||
|
||||
protected override string GenerateFullPathToTool()
|
||||
{
|
||||
string path = ToolPath;
|
||||
|
||||
// if ToolPath was not provided by the MSBuild script
|
||||
if (string.IsNullOrEmpty(path))
|
||||
// if ToolPath was not provided by the MSBuild script
|
||||
if (string.IsNullOrEmpty(ToolPath))
|
||||
{
|
||||
Log.LogError($"Could not find the Path to {ToolName}");
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return path;
|
||||
return ToolPath;
|
||||
}
|
||||
|
||||
protected override string GetWorkingDirectory() => WorkingDirectory ?? base.GetWorkingDirectory();
|
||||
|
|
|
@ -47,13 +47,10 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
|
||||
var retVal = true;
|
||||
|
||||
if (Directory.Exists(DestinationDirectory))
|
||||
if (Directory.Exists(DestinationDirectory) && CleanDestination == true)
|
||||
{
|
||||
if (CleanDestination == true)
|
||||
{
|
||||
Log.LogMessage(MessageImportance.Low, "'{0}' already exists, trying to delete before unzipping...", DestinationDirectory);
|
||||
Directory.Delete(DestinationDirectory, recursive: true);
|
||||
}
|
||||
Log.LogMessage(MessageImportance.Low, "'{0}' already exists, trying to delete before unzipping...", DestinationDirectory);
|
||||
Directory.Delete(DestinationDirectory, recursive: true);
|
||||
}
|
||||
|
||||
if (!File.Exists(SourceArchive))
|
||||
|
@ -178,16 +175,7 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
return retVal;
|
||||
}
|
||||
|
||||
private bool ShouldExtractItem(string path)
|
||||
{
|
||||
if (DirectoriesToCopy != null)
|
||||
{
|
||||
return DirectoriesToCopy.Any(p => path.StartsWith(p.ItemSpec));
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private bool ShouldExtractItem(string path) => DirectoriesToCopy?.Any(p => path.StartsWith(p.ItemSpec)) ?? false;
|
||||
|
||||
protected override string ToolName => "tar";
|
||||
|
||||
|
|
|
@ -19,21 +19,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
if (NuGetVersion.TryParse(RuntimePackVersion, out var version))
|
||||
{
|
||||
if (version.IsPrerelease && version.Patch == 0)
|
||||
{
|
||||
DefaultRuntimeFrameworkVersion = RuntimePackVersion;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultRuntimeFrameworkVersion = new NuGetVersion(version.Major, version.Minor, 0).ToFullString();
|
||||
}
|
||||
DefaultRuntimeFrameworkVersion = version.IsPrerelease && version.Patch == 0 ?
|
||||
RuntimePackVersion :
|
||||
new NuGetVersion(version.Major, version.Minor, 0).ToFullString();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
Log.LogWarning($"GetComponentCommit failed for VersionDetailsXmlFile={VersionDetailsXmlFile}, DependencyName={DependencyName}: {ex}");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var runtimeJsonRoot = JObject.Parse(runtimeJsonContents);
|
||||
string [] runtimeIdentifiers = ((JObject)runtimeJsonRoot["runtimes"]).Properties().Select(p => p.Name).ToArray();
|
||||
AvailableRuntimePackRuntimeIdentifiers = runtimeIdentifiers.Select(rid => new TaskItem(rid)).ToArray();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
@ -118,7 +117,7 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
|
||||
private string GetExcludes()
|
||||
{
|
||||
var excludes = String.Empty;
|
||||
var excludes = string.Empty;
|
||||
|
||||
if (ExcludePatterns != null)
|
||||
{
|
||||
|
|
|
@ -71,9 +71,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private async Task<CommandResult> ExecuteAsyncInternal(string executable, string args)
|
||||
{
|
||||
var stdOut = new List<String>();
|
||||
var stdOut = new List<string>();
|
||||
|
||||
var stdErr = new List<String>();
|
||||
var stdErr = new List<string>();
|
||||
|
||||
CurrentProcess = CreateProcess(executable, args);
|
||||
|
||||
|
@ -118,8 +118,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new CommandResult(
|
||||
CurrentProcess.StartInfo,
|
||||
CurrentProcess.ExitCode,
|
||||
String.Join(System.Environment.NewLine, stdOut),
|
||||
String.Join(System.Environment.NewLine, stdErr));
|
||||
string.Join(System.Environment.NewLine, stdOut),
|
||||
string.Join(System.Environment.NewLine, stdErr));
|
||||
}
|
||||
|
||||
private Process CreateProcess(string executable, string args)
|
||||
|
|
Loading…
Reference in a new issue