diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/ReplaceTextInFile.cs b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/ReplaceTextInFile.cs new file mode 100644 index 000000000000..004457f4742f --- /dev/null +++ b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/ReplaceTextInFile.cs @@ -0,0 +1,36 @@ +// 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.UnifiedBuild.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/repo-projects/Directory.Build.targets b/src/SourceBuild/content/repo-projects/Directory.Build.targets index 2faa62b19256..ee2d16f204f5 100644 --- a/src/SourceBuild/content/repo-projects/Directory.Build.targets +++ b/src/SourceBuild/content/repo-projects/Directory.Build.targets @@ -35,6 +35,36 @@ $(PackageReportDir)prodcon-build.xml + + + + + + ]]> + + + %24(NoWarn);NU1903;$(RepoNoWarns) + +]]> + + + $(ProjectDirectory)Directory.Build.props + $(ProjectDirectory)src/Directory.Build.props + + + + @@ -392,6 +422,7 @@ Outputs="$(BaseIntermediateOutputPath)Build.complete" Condition="'$(BuildCommand)' != ''" DependsOnTargets="BuildRepoReferences; + AddNoWarns; UpdateNuGetConfig; UpdateGlobalJsonVersions; UpdateEngCommonFiles;