From 481d281d8f6824af94cf2339ce0d0a19b745b9cb Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Wed, 9 Oct 2024 15:14:10 +0000 Subject: [PATCH 1/2] Add nowarn for NU1903 --- .../ReplaceTextInFile.cs | 36 +++++++++++++++++++ .../repo-projects/Directory.Build.targets | 31 ++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/ReplaceTextInFile.cs 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..2388062b7a54 100644 --- a/src/SourceBuild/content/repo-projects/Directory.Build.targets +++ b/src/SourceBuild/content/repo-projects/Directory.Build.targets @@ -35,6 +35,37 @@ $(PackageReportDir)prodcon-build.xml + + + + + + ]]> + + + %24(NoWarn);NU1903;$(RepoNoWarns) + +]]> + + + $(ProjectDirectory)Directory.Build.props + $(ProjectDirectory)src/Directory.Build.props + + + + From fd2fb047468fa8e408312e0ce3b76a4bb8f9a596 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Wed, 9 Oct 2024 16:34:20 +0000 Subject: [PATCH 2/2] Update target invocation logic --- src/SourceBuild/content/repo-projects/Directory.Build.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SourceBuild/content/repo-projects/Directory.Build.targets b/src/SourceBuild/content/repo-projects/Directory.Build.targets index 2388062b7a54..ee2d16f204f5 100644 --- a/src/SourceBuild/content/repo-projects/Directory.Build.targets +++ b/src/SourceBuild/content/repo-projects/Directory.Build.targets @@ -37,7 +37,6 @@ @@ -423,6 +422,7 @@ Outputs="$(BaseIntermediateOutputPath)Build.complete" Condition="'$(BuildCommand)' != ''" DependsOnTargets="BuildRepoReferences; + AddNoWarns; UpdateNuGetConfig; UpdateGlobalJsonVersions; UpdateEngCommonFiles;