From 77d966e1b013c53b43dcd16b8307dca9d78ae484 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 11 Jan 2024 20:01:19 +0100 Subject: [PATCH] Simplify repo tasks infra and sources --- .../content/eng/tools/Directory.Build.props | 2 +- .../content/eng/tools/init-build.proj | 171 ++++++++++-------- .../eng/tools/tasks/Directory.Build.props | 22 +-- ...Net.SourceBuild.Tasks.LeakDetection.csproj | 18 +- ...soft.DotNet.SourceBuild.Tasks.XPlat.csproj | 19 +- .../ReplaceTextInFile.cs | 36 ---- .../UpdateJson.cs | 19 +- .../SourceBuild.MSBuildSdkResolver.csproj | 15 +- 8 files changed, 140 insertions(+), 162 deletions(-) delete mode 100644 src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/ReplaceTextInFile.cs diff --git a/src/SourceBuild/content/eng/tools/Directory.Build.props b/src/SourceBuild/content/eng/tools/Directory.Build.props index 17a556ec5..63c892c31 100644 --- a/src/SourceBuild/content/eng/tools/Directory.Build.props +++ b/src/SourceBuild/content/eng/tools/Directory.Build.props @@ -2,7 +2,7 @@ true diff --git a/src/SourceBuild/content/eng/tools/init-build.proj b/src/SourceBuild/content/eng/tools/init-build.proj index fb742f925..92eeca062 100644 --- a/src/SourceBuild/content/eng/tools/init-build.proj +++ b/src/SourceBuild/content/eng/tools/init-build.proj @@ -1,45 +1,35 @@ + + + + netstandard2.0 + true + + - - - - - - - - - - $(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)%3B$(PrebuiltSourceBuiltPackagesPath) - - - - - - - - - - - + Outputs="$(BaseIntermediateOutputPath)UnpackTarballs.complete" > + + $([MSBuild]::NormalizeDirectory('$(PrereqsPackagesDir)', 'archive')) + - @@ -48,71 +38,101 @@ the build to be working without prebuilts. --> - + - - + + + + - + - - tasks\Microsoft.DotNet.SourceBuild.Tasks.XPlat\Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj;tasks\SourceBuild.MSBuildSdkResolver\SourceBuild.MSBuildSdkResolver.csproj - - + Outputs="$(BaseIntermediateOutputPath)BuildMSBuildSdkResolver.complete"> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - tasks\Microsoft.DotNet.SourceBuild.Tasks.LeakDetection\Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj + ROOTFS_DIR=$(ArtifactsObjDir)crossrootfs/arm + ROOTFS_DIR=$(ArtifactsObjDir)crossrootfs/armel - - - - - - - + + + + Outputs="$(BaseIntermediateOutputPath)ExtractToolPackage.complete"> - - - - - - - + + + + + + Outputs="$(BaseIntermediateOutputPath)PoisonPrebuiltPackages.complete"> + + .source-built.xml + $(PackageReportDir)poison-source-built-catalog.xml + + @@ -147,8 +166,12 @@ - + + + + + diff --git a/src/SourceBuild/content/eng/tools/tasks/Directory.Build.props b/src/SourceBuild/content/eng/tools/tasks/Directory.Build.props index 65f8365de..f00026353 100644 --- a/src/SourceBuild/content/eng/tools/tasks/Directory.Build.props +++ b/src/SourceBuild/content/eng/tools/tasks/Directory.Build.props @@ -1,29 +1,21 @@ + - - AnyCPU + $(ReferencePackagesDir);$(PrebuiltPackagesPath);$(PrebuiltSourceBuiltPackagesPath) - - - - - - + diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj index 27510e6db..33b0acaa8 100644 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj +++ b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj @@ -3,25 +3,19 @@ $(NetCurrent) true - $(LeakDetectionTasksBinDir) - - 15.7.179 - - - 15.7.179 - + + + + + - - - - - + diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj index a28c1b5a3..d3a161702 100644 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj +++ b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj @@ -2,26 +2,17 @@ $(NetCurrent) - $(XPlatTasksBinDir) - - 15.7.179 - - - 15.7.179 - - - 15.7.179 - - - 15.7.179 - + + + + - + diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/ReplaceTextInFile.cs b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/ReplaceTextInFile.cs deleted file mode 100644 index dcd6b28f1..000000000 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/ReplaceTextInFile.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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; - -namespace Microsoft.DotNet.Build.Tasks -{ - public class ReplaceTextInFile : Task - { - [Required] - public string InputFile { get; set; } - - [Required] - public string OldText { get; set; } - - [Required] - public string NewText { get; set; } - - - public override bool Execute() - { - string fileContents = File.ReadAllText(InputFile); - string newLineChars = FileUtilities.DetectNewLineChars(fileContents); - - fileContents = fileContents.Replace(OldText, NewText); - - File.WriteAllText(InputFile, FileUtilities.NormalizeNewLineChars(fileContents, newLineChars)); - - return true; - } - } -} diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs index 8b65026fc..b79e1783e 100644 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs +++ b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs @@ -23,21 +23,25 @@ namespace Microsoft.DotNet.Build.Tasks [Required] public string PathToAttribute { get; set; } - [Required] + // New attribute value. May be null. If null, + // the token is removed. public string NewAttributeValue { get; set; } public bool SkipUpdateIfMissingKey { get; set; } public override bool Execute() { + // Using a character that isn't allowed in the package id + const char Delimiter = ':'; + string json = File.ReadAllText(JsonFilePath); string newLineChars = FileUtilities.DetectNewLineChars(json); JObject jsonObj = JObject.Parse(json); - string[] escapedPathToAttributeParts = PathToAttribute.Replace("\\.", "\x1F").Split('.'); + string[] escapedPathToAttributeParts = PathToAttribute.Split(Delimiter); for (int i = 0; i < escapedPathToAttributeParts.Length; ++i) { - escapedPathToAttributeParts[i] = escapedPathToAttributeParts[i].Replace("\x1F", "."); + escapedPathToAttributeParts[i] = escapedPathToAttributeParts[i]; } UpdateAttribute(jsonObj, escapedPathToAttributeParts, NewAttributeValue); @@ -61,7 +65,14 @@ namespace Microsoft.DotNet.Build.Tasks if (path.Length == 1) { - jsonObj[pathItem] = newValue; + if (newValue == null) + { + jsonObj[pathItem].Parent.Remove(); + } + else + { + jsonObj[pathItem] = newValue; + } return; } diff --git a/src/SourceBuild/content/eng/tools/tasks/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.csproj b/src/SourceBuild/content/eng/tools/tasks/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.csproj index f6fa859e9..04f354465 100644 --- a/src/SourceBuild/content/eng/tools/tasks/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.csproj +++ b/src/SourceBuild/content/eng/tools/tasks/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.csproj @@ -2,19 +2,22 @@ netstandard2.0 - $(DotNetSdkResolversDir)$(MSBuildProjectName)\$(MSBuildProjectName).dll + + $([MSBuild]::NormalizePath('$(DotNetRoot)', 'sdk', '$(NETCoreSdkVersion)', 'SdkResolvers', '$(MSBuildProjectName)', '$(MSBuildProjectName).dll')) + + - + - - - - + + + +