[ArPow] Add test-templates repo to arpow tarball (#11013)

This commit is contained in:
Michael Simons 2021-06-30 22:30:51 -05:00 committed by GitHub
parent fb7e06599f
commit a465da6364
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 85 additions and 13 deletions

View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.DotNet.Test.ProjectTemplates.6.0" Version="1.0.2-beta4.21321.1">
<Uri>https://github.com/dotnet/test-templates</Uri>
<Sha>6898c1c70c2d14e9725ddab6e1ebe8084c4d7e27</Sha>
<SourceBuild RepoName="test-templates" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="6.0.100-preview.6.21321.1" CoherentParentDependency="Microsoft.NET.Sdk">
<Uri>https://github.com/mono/linker</Uri>
<Sha>f2588193553431636b9853b0f87209fa395a72c5</Sha>

View file

@ -9,6 +9,7 @@
<GlobalJsonFile>$(ProjectDirectory)global.json</GlobalJsonFile>
<NuGetConfigFile>$(ProjectDirectory)NuGet.config</NuGetConfigFile>
<LogVerbosityOptOut>true</LogVerbosityOptOut>
<OutputPlacementRepoApiImplemented>false</OutputPlacementRepoApiImplemented>
</PropertyGroup>
<ItemGroup>

View file

@ -34,6 +34,7 @@
<RepositoryReference Include="command-line-api" />
<RepositoryReference Include="source-build" />
<RepositoryReference Include="symreader" />
<RepositoryReference Include="test-templates" />
<RepositoryReference Include="xdt" />
<RepositoryReference Include="xliff-tasks" />
@ -42,7 +43,6 @@
<!-- Package source-build artifacts -->
<RepositoryReference Include="package-source-build" />
</ItemGroup>
</Otherwise>
</Choose>

View file

@ -5,6 +5,7 @@
<BuildCommand>$(StandardSourceBuildCommand) $(StandardSourceBuildArgs)</BuildCommand>
<NuGetConfigFile>$(ProjectDirectory)NuGet.config</NuGetConfigFile>
<OutputPlacementRepoApiImplemented>false</OutputPlacementRepoApiImplemented>
</PropertyGroup>
<ItemGroup>

View file

@ -1,14 +1,9 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<BuildCommandArgs>--restore --build --pack</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) --configuration $(Configuration)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) --binaryLog</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) -ci</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg)</BuildCommandArgs>
<BuildCommand>$(ProjectDirectory)build$(ShellExtension) $(BuildCommandArgs)</BuildCommand>
<BuildCommandArgs>$(StandardSourceBuildArgs) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg)</BuildCommandArgs>
<BuildCommand>$(StandardSourceBuildCommand) $(BuildCommandArgs)</BuildCommand>
<GlobalJsonFile>$(ProjectDirectory)global.json</GlobalJsonFile>
<NuGetConfigFile>$(ProjectDirectory)NuGet.config</NuGetConfigFile>

View file

@ -8,6 +8,7 @@
<GlobalJsonFile>$(ProjectDirectory)global.json</GlobalJsonFile>
<NuGetConfigFile>$(ProjectDirectory)NuGet.config</NuGetConfigFile>
<LogVerbosityOptOut>true</LogVerbosityOptOut>
<OutputPlacementRepoApiImplemented>false</OutputPlacementRepoApiImplemented>
</PropertyGroup>
<ItemGroup>

View file

@ -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;

View file

@ -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;
}
}
}

View file

@ -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;
}