Remove ReplaceTextInFile usage and unused task (#18087)
This commit is contained in:
parent
5a600f8e99
commit
7d1c36e327
5 changed files with 0 additions and 305 deletions
|
@ -6,7 +6,6 @@
|
|||
<Import Project="$(GitInfoAllRepoPropsFile)" />
|
||||
|
||||
<UsingTask AssemblyFile="$(LeakDetectionTasksAssembly)" TaskName="MarkAndCatalogPackages" />
|
||||
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="ReplaceTextInFile" />
|
||||
|
||||
<ItemGroup>
|
||||
<BuildTasksTarget Include="Restore;Build;InstallResolver" />
|
||||
|
@ -121,10 +120,6 @@
|
|||
<Exec Command="chmod 755 git-clone-to-dir.sh"
|
||||
WorkingDirectory="$(ArcadeBootstrapPackageDir)microsoft.dotnet.arcade.sdk/$(ARCADE_BOOTSTRAP_VERSION)/tools/SourceBuild/" />
|
||||
|
||||
<ReplaceTextInFile InputFile="$(ArcadeBootstrapPackageDir)microsoft.dotnet.arcade.sdk/$(ARCADE_BOOTSTRAP_VERSION)/tools/SourceBuild/SourceBuildArcadeTools.targets"
|
||||
OldText="%3CReadSourceBuildIntermediateNupkgDependencies"
|
||||
NewText="%3CReadSourceBuildIntermediateNupkgDependencies Condition="'%24%28DotNetBuildOffline%29' != 'true'"" />
|
||||
|
||||
<!-- Allow overriding of Arcade targets for SourceBuild to enable quicker
|
||||
dev turnaround for Preview 6 -->
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,86 +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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Build.Tasks
|
||||
{
|
||||
/*
|
||||
* This task replaces both types of path separators ('/' and '\') with the separator for the current
|
||||
* platform. This workaround a NuGet issue where `nuget pack` does not translate path separators causing
|
||||
* packages that don't appear to have the right assets in them.
|
||||
*/
|
||||
public class FixPathSeparator : Task
|
||||
{
|
||||
[Required]
|
||||
public ITaskItem[] NuSpecFiles { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
foreach (ITaskItem item in NuSpecFiles)
|
||||
{
|
||||
string pathToNuSpec = item.GetMetadata("FullPath");
|
||||
|
||||
XDocument doc = XDocument.Load(pathToNuSpec);
|
||||
|
||||
XElement contentFilesElement = doc.ElementIgnoringNamespace("package").ElementIgnoringNamespace("metadata").ElementIgnoringNamespace("contentFiles");
|
||||
XElement filesElement = doc.ElementIgnoringNamespace("package").ElementIgnoringNamespace("files");
|
||||
|
||||
if (contentFilesElement != null)
|
||||
{
|
||||
foreach (XElement element in contentFilesElement.ElementsIgnroingNamespace("files"))
|
||||
{
|
||||
UpdateDirectorySeperatorInAttribute(element, "include");
|
||||
UpdateDirectorySeperatorInAttribute(element, "exclude");
|
||||
}
|
||||
}
|
||||
|
||||
if (filesElement != null)
|
||||
{
|
||||
foreach (XElement element in filesElement.ElementsIgnroingNamespace("file"))
|
||||
{
|
||||
UpdateDirectorySeperatorInAttribute(element, "src");
|
||||
UpdateDirectorySeperatorInAttribute(element, "target");
|
||||
UpdateDirectorySeperatorInAttribute(element, "exclude");
|
||||
}
|
||||
}
|
||||
|
||||
using (FileStream fs = File.Open(pathToNuSpec, FileMode.Truncate))
|
||||
{
|
||||
doc.Save(fs);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void UpdateDirectorySeperatorInAttribute(XElement element, XName name)
|
||||
{
|
||||
XAttribute attribute = element.Attribute(name);
|
||||
|
||||
if (attribute != null)
|
||||
{
|
||||
element.SetAttributeValue(name, attribute.Value.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class XContainerExtensions
|
||||
{
|
||||
public static IEnumerable<XElement> ElementsIgnroingNamespace(this XContainer container, XName elementName)
|
||||
{
|
||||
return container.Elements().Where(e => e.Name.LocalName == elementName.LocalName);
|
||||
}
|
||||
|
||||
public static XElement ElementIgnoringNamespace(this XContainer container, XName elementName)
|
||||
{
|
||||
return container.ElementsIgnroingNamespace(elementName).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +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 Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Build.Tasks.Packaging
|
||||
{
|
||||
public abstract partial class PackagingTask : ITask
|
||||
{
|
||||
private Log _log = null;
|
||||
|
||||
internal Log Log
|
||||
{
|
||||
get { return _log ?? (_log = new Log(new TaskLoggingHelper(this))); }
|
||||
}
|
||||
|
||||
public PackagingTask()
|
||||
{
|
||||
}
|
||||
|
||||
public IBuildEngine BuildEngine
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ITaskHost HostObject
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public abstract bool Execute();
|
||||
}
|
||||
}
|
|
@ -1,38 +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 ReplaceTextInFiles : Task
|
||||
{
|
||||
[Required]
|
||||
public string[] InputFiles { get; set; }
|
||||
|
||||
[Required]
|
||||
public string OldText { get; set; }
|
||||
|
||||
[Required]
|
||||
public string NewText { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
foreach (string file in InputFiles)
|
||||
{
|
||||
string fileContents = File.ReadAllText(file);
|
||||
string newLineChars = FileUtilities.DetectNewLineChars(fileContents);
|
||||
|
||||
fileContents = fileContents.Replace(OldText, NewText);
|
||||
|
||||
File.WriteAllText(file, FileUtilities.NormalizeNewLineChars(fileContents, newLineChars));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
// Copied from https://github.com/aspnet/Universe/blob/1f8f30a1e834eff147ced0c669cef8828f9511c8/build/tasks/JoinItems.cs.
|
||||
// When this task is available in https://github.com/dotnet/Arcade, switch to use that version.
|
||||
// Modified to allow multiple Right matches using GroupJoin.
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace RepoTasks
|
||||
{
|
||||
public class JoinItems : Task
|
||||
{
|
||||
[Required]
|
||||
public ITaskItem[] Left { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] Right { get; set; }
|
||||
|
||||
// The metadata to use as the new item spec. If not specified, LeftKey is used.
|
||||
public string LeftItemSpec { get; set; }
|
||||
|
||||
// LeftKey and RightKey: The metadata to join on. If not set, then use the ItemSpec
|
||||
public string LeftKey { get; set; }
|
||||
|
||||
public string RightKey { get; set; }
|
||||
|
||||
|
||||
// LeftMetadata and RightMetadata: The metadata names to include in the result. Specify "*" to include all metadata
|
||||
public string[] LeftMetadata { get; set; }
|
||||
|
||||
public string[] RightMetadata { get; set; }
|
||||
|
||||
|
||||
[Output]
|
||||
public ITaskItem[] JoinResult { get; private set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
bool useAllLeftMetadata = LeftMetadata != null && LeftMetadata.Length == 1 && LeftMetadata[0] == "*";
|
||||
bool useAllRightMetadata = RightMetadata != null && RightMetadata.Length == 1 && RightMetadata[0] == "*";
|
||||
var newItemSpec = string.IsNullOrEmpty(LeftItemSpec)
|
||||
? LeftKey
|
||||
: LeftItemSpec;
|
||||
|
||||
JoinResult = Left.GroupJoin(Right,
|
||||
item => GetKeyValue(LeftKey, item),
|
||||
item => GetKeyValue(RightKey, item),
|
||||
(left, rights) =>
|
||||
{
|
||||
// If including all metadata from left items and none from right items, just return left items directly
|
||||
if (useAllLeftMetadata &&
|
||||
string.IsNullOrEmpty(LeftKey) &&
|
||||
string.IsNullOrEmpty(LeftItemSpec) &&
|
||||
(RightMetadata == null || RightMetadata.Length == 0))
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
// If including all metadata from all right items and none from left items, just return the right items directly
|
||||
if (useAllRightMetadata &&
|
||||
string.IsNullOrEmpty(RightKey) &&
|
||||
string.IsNullOrEmpty(LeftItemSpec) &&
|
||||
(LeftMetadata == null || LeftMetadata.Length == 0))
|
||||
{
|
||||
return rights.Aggregate(
|
||||
new TaskItem(),
|
||||
(agg, next) =>
|
||||
{
|
||||
CopyAllMetadata(next, agg);
|
||||
return agg;
|
||||
});
|
||||
}
|
||||
|
||||
var ret = new TaskItem(GetKeyValue(newItemSpec, left));
|
||||
|
||||
// Weird ordering here is to prefer left metadata in all cases, as CopyToMetadata doesn't overwrite any existing metadata
|
||||
if (useAllLeftMetadata)
|
||||
{
|
||||
CopyAllMetadata(left, ret);
|
||||
}
|
||||
|
||||
if (!useAllRightMetadata && RightMetadata != null)
|
||||
{
|
||||
foreach (string name in RightMetadata)
|
||||
{
|
||||
foreach (var right in rights)
|
||||
{
|
||||
ret.SetMetadata(name, right.GetMetadata(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!useAllLeftMetadata && LeftMetadata != null)
|
||||
{
|
||||
foreach (string name in LeftMetadata)
|
||||
{
|
||||
ret.SetMetadata(name, left.GetMetadata(name));
|
||||
}
|
||||
}
|
||||
|
||||
if (useAllRightMetadata)
|
||||
{
|
||||
foreach (var right in rights)
|
||||
{
|
||||
CopyAllMetadata(right, ret);
|
||||
}
|
||||
}
|
||||
|
||||
return (ITaskItem)ret;
|
||||
},
|
||||
StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void CopyAllMetadata(ITaskItem source, ITaskItem dest)
|
||||
{
|
||||
// CopyMetadata adds an OriginalItemSpec, which we don't want. So we subsequently remove it
|
||||
source.CopyMetadataTo(dest);
|
||||
dest.RemoveMetadata("OriginalItemSpec");
|
||||
}
|
||||
|
||||
static string GetKeyValue(string key, ITaskItem item)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return item.ItemSpec;
|
||||
}
|
||||
else
|
||||
{
|
||||
return item.GetMetadata(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue