diff --git a/eng/SourceBuild.Version.Details.xml b/eng/SourceBuild.Version.Details.xml index b37351bbb..c2a377b07 100644 --- a/eng/SourceBuild.Version.Details.xml +++ b/eng/SourceBuild.Version.Details.xml @@ -1,6 +1,11 @@ + + https://github.com/dotnet/test-templates + 6898c1c70c2d14e9725ddab6e1ebe8084c4d7e27 + + https://github.com/mono/linker f2588193553431636b9853b0f87209fa395a72c5 diff --git a/src/SourceBuild/tarball/content/repos/command-line-api.proj b/src/SourceBuild/tarball/content/repos/command-line-api.proj index b175fec4c..e904d3d5f 100644 --- a/src/SourceBuild/tarball/content/repos/command-line-api.proj +++ b/src/SourceBuild/tarball/content/repos/command-line-api.proj @@ -9,6 +9,7 @@ $(ProjectDirectory)global.json $(ProjectDirectory)NuGet.config true + false diff --git a/src/SourceBuild/tarball/content/repos/known-good.proj b/src/SourceBuild/tarball/content/repos/known-good.proj index 2741454e7..f81f8d67c 100644 --- a/src/SourceBuild/tarball/content/repos/known-good.proj +++ b/src/SourceBuild/tarball/content/repos/known-good.proj @@ -34,6 +34,7 @@ + @@ -42,7 +43,6 @@ - diff --git a/src/SourceBuild/tarball/content/repos/source-build.proj b/src/SourceBuild/tarball/content/repos/source-build.proj index c82af24d5..07f094829 100644 --- a/src/SourceBuild/tarball/content/repos/source-build.proj +++ b/src/SourceBuild/tarball/content/repos/source-build.proj @@ -5,6 +5,7 @@ $(StandardSourceBuildCommand) $(StandardSourceBuildArgs) $(ProjectDirectory)NuGet.config + false diff --git a/src/SourceBuild/tarball/content/repos/test-templates.proj b/src/SourceBuild/tarball/content/repos/test-templates.proj index 547dfc2c3..8e2e66892 100644 --- a/src/SourceBuild/tarball/content/repos/test-templates.proj +++ b/src/SourceBuild/tarball/content/repos/test-templates.proj @@ -1,14 +1,9 @@ - - --restore --build --pack - $(BuildCommandArgs) --configuration $(Configuration) - $(BuildCommandArgs) --binaryLog - $(BuildCommandArgs) -ci - $(BuildCommandArgs) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg) - $(ProjectDirectory)build$(ShellExtension) $(BuildCommandArgs) + $(StandardSourceBuildArgs) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg) + $(StandardSourceBuildCommand) $(BuildCommandArgs) $(ProjectDirectory)global.json $(ProjectDirectory)NuGet.config diff --git a/src/SourceBuild/tarball/content/repos/xdt.proj b/src/SourceBuild/tarball/content/repos/xdt.proj index d5acc1135..8e2e66892 100644 --- a/src/SourceBuild/tarball/content/repos/xdt.proj +++ b/src/SourceBuild/tarball/content/repos/xdt.proj @@ -8,6 +8,7 @@ $(ProjectDirectory)global.json $(ProjectDirectory)NuGet.config true + false diff --git a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddSourceToNuGetConfig.cs b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddSourceToNuGetConfig.cs index a00a8a550..1d6458678 100755 --- a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddSourceToNuGetConfig.cs +++ b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddSourceToNuGetConfig.cs @@ -5,6 +5,7 @@ using System; using System.IO; using System.Linq; +using System.Xml; using System.Xml.Linq; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -30,7 +31,9 @@ namespace Microsoft.DotNet.Build.Tasks public override bool Execute() { - XDocument d = XDocument.Load(NuGetConfigFile); + string xml = File.ReadAllText(NuGetConfigFile); + string newLineChars = FileUtilities.DetectNewLineChars(xml); + XDocument d = XDocument.Parse(xml); XElement packageSourcesElement = d.Root.Descendants().First(e => e.Name == "packageSources"); XElement toAdd = new XElement("add", new XAttribute("key", SourceName), new XAttribute("value", SourcePath)); XElement clearTag = new XElement("clear"); @@ -52,9 +55,9 @@ namespace Microsoft.DotNet.Build.Tasks packageSourcesElement.AddFirst(clearTag); } - using (FileStream fs = new FileStream(NuGetConfigFile, FileMode.Create, FileAccess.ReadWrite)) + using (var w = XmlWriter.Create(NuGetConfigFile, new XmlWriterSettings { NewLineChars = newLineChars, Indent = true })) { - d.Save(fs); + d.Save(w); } return true; diff --git a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/FileUtilities.cs b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/FileUtilities.cs new file mode 100644 index 000000000..0365a7272 --- /dev/null +++ b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/FileUtilities.cs @@ -0,0 +1,64 @@ +// 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; + +namespace Microsoft.DotNet.Build.Tasks +{ + public static class FileUtilities + { + public const string CR = "\r"; + public const string CRLF = "\r\n"; + public const string LF = "\n"; + + public static string DetectNewLineChars(string source) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + if (source.Contains(CRLF)) + { + return CRLF; + } + else if (source.Contains(LF)) + { + return LF; + } + else if (source.Contains(CR)) + { + return CR; + } + else + { + throw new ArgumentException("Unsupported new line characters", nameof(source)); + } + } + + public static string NormalizeNewLineChars(string source, string newLineChars) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source)); + } + + source = source.Replace(CRLF, LF).Replace(CR, LF); + if (newLineChars == CRLF) + { + source = source.Replace(LF, CRLF); + } + else if (newLineChars == CR) + { + source = source.Replace(LF, CR); + } + else if (newLineChars != LF) + { + throw new ArgumentException("Unsupported new line characters", nameof(newLineChars)); + } + + return source; + } + } +} diff --git a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs index 9820e4af2..8b65026fc 100644 --- a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs +++ b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/UpdateJson.cs @@ -30,7 +30,9 @@ namespace Microsoft.DotNet.Build.Tasks public override bool Execute() { - JObject jsonObj = JObject.Parse(File.ReadAllText(JsonFilePath)); + string json = File.ReadAllText(JsonFilePath); + string newLineChars = FileUtilities.DetectNewLineChars(json); + JObject jsonObj = JObject.Parse(json); string[] escapedPathToAttributeParts = PathToAttribute.Replace("\\.", "\x1F").Split('.'); for (int i = 0; i < escapedPathToAttributeParts.Length; ++i) @@ -39,7 +41,7 @@ namespace Microsoft.DotNet.Build.Tasks } UpdateAttribute(jsonObj, escapedPathToAttributeParts, NewAttributeValue); - File.WriteAllText(JsonFilePath, jsonObj.ToString()); + File.WriteAllText(JsonFilePath, FileUtilities.NormalizeNewLineChars(jsonObj.ToString(), newLineChars)); return true; }