提交 f1056adf 编写于 作者: J Jared Parsons 提交者: GitHub

Merge pull request #20636 from KirillOsenkov/UpdateBinaryLogger

Upgrade to the StructuredLogger 1.1.130.
......@@ -17,7 +17,7 @@
<MicrosoftAzureKeyVaultVersion>2.0.6</MicrosoftAzureKeyVaultVersion>
<MicrosoftBuildVersion>15.1.0-preview-000458-02</MicrosoftBuildVersion>
<MicrosoftBuildFrameworkVersion>15.1.0-preview-000458-02</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildLoggingStructuredLoggerVersion>1.0.58</MicrosoftBuildLoggingStructuredLoggerVersion>
<MicrosoftBuildLoggingStructuredLoggerVersion>1.1.130</MicrosoftBuildLoggingStructuredLoggerVersion>
<MicrosoftBuildRuntimeVersion>15.1.0-preview-000458-02</MicrosoftBuildRuntimeVersion>
<MicrosoftBuildTasksCoreVersion>15.1.0-preview-000458-02</MicrosoftBuildTasksCoreVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>1.1.0</MicrosoftCodeAnalysisAnalyzersVersion>
......
......@@ -25,7 +25,7 @@ try {
# Need to parse out the current NuGet package version of Structured Logger
$structuredLoggerPath = Join-Path (Get-PackageDir "Microsoft.Build.Logging.StructuredLogger") "lib\net46\StructuredLogger.dll"
$configDir = Join-Path $binariesDir $config
$logPath = Join-Path $configDir "build.xml"
$logPath = Join-Path $configDir "roslyn.buildlog"
$solution = Join-Path $repoDir "Roslyn.sln"
if ($msbuild -eq "") {
......@@ -33,7 +33,7 @@ try {
}
Write-Host "Building Roslyn.sln with logging support"
Exec-Command $msbuild "/v:m /m /p:Configuration=$config /logger:StructuredLogger,$structuredLoggerPath;$logPath /nodeReuse:false /p:DeployExtension=false $solution"
Exec-Command $msbuild "/noconlog /v:m /m /p:Configuration=$config /logger:StructuredLogger,$structuredLoggerPath;$logPath /nodeReuse:false /p:DeployExtension=false $solution"
Write-Host ""
# Verify the state of our various build artifacts
......
......@@ -18,7 +18,8 @@ static void addRoslynJob(def myJob, String jobName, String branchName, Boolean i
archiveSettings.addFiles('Binaries/**/*.dmp')
archiveSettings.addFiles('Binaries/**/*.zip')
archiveSettings.addFiles('Binaries/**/*.png')
archiveSettings.addFiles('Binaries/**/*.xml')
archiveSettings.addFiles('Binaries/**/*.buildlog')
archiveSettings.addFiles('Binaries/**/*.binlog')
archiveSettings.excludeFiles('Binaries/Obj/**')
archiveSettings.excludeFiles('Binaries/Bootstrap/**')
archiveSettings.excludeFiles('Binaries/**/nuget*.zip')
......
......@@ -7,7 +7,6 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProjectGuid>{9C0660D9-48CA-40E1-BABA-8F6A1F11FE10}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BuildBoss</RootNamespace>
<AssemblyName>BuildBoss</AssemblyName>
<TargetFramework>net46</TargetFramework>
......@@ -24,6 +23,7 @@
<Reference Include="WindowsBase" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageReference Include="Microsoft.Build.Logging.StructuredLogger" Version="$(MicrosoftBuildLoggingStructuredLoggerVersion)" />
</ItemGroup>
<ItemGroup>
<Compile Include="ICheckerUtil.cs" />
......@@ -47,8 +47,5 @@
<None Include="App.config" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\..\..\build\Targets\Imports.targets" />
</Project>
\ No newline at end of file
......@@ -40,7 +40,7 @@ private static int MainCore(string[] args)
{
allGood &= ProcessSolution(arg);
}
else if (Path.GetExtension(arg) == ".xml")
else if (string.Equals(Path.GetExtension(arg), ".buildlog", StringComparison.OrdinalIgnoreCase))
{
allGood &= ProcessStructuredLog(arg);
}
......@@ -89,7 +89,7 @@ private static bool ProcessTargets(string targets)
private static bool ProcessStructuredLog(string logFilePath)
{
var util = new StructuredLoggerCheckerUtil(XDocument.Load(logFilePath));
var util = new StructuredLoggerCheckerUtil(logFilePath);
return CheckCore(util, $"Structured log {logFilePath}");
}
......
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.XPath;
using Microsoft.Build.Logging.StructuredLogger;
namespace BuildBoss
{
/// <summary>
/// The logic from this type is largely copied from:
/// This type invokes the analyzer here:
///
/// https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogViewer/BuildAnalyzer.cs
/// https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/Analyzers/DoubleWritesAnalyzer.cs
///
/// Once structured logger has a command line verification mode this code should be
/// deleted. The caller should instead use the structured logging tool for
/// verification. Until then this is simple enough to duplicate. Feature request
/// is here:
///
/// https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/42
/// </summary>
internal sealed class StructuredLoggerCheckerUtil : ICheckerUtil
{
internal static readonly StringComparer FilePathComparer = StringComparer.OrdinalIgnoreCase;
private const string s_copyingFileFrom = "Copying file from \"";
private const string s_creatingHardLink = "Creating hard link to copy \"";
private const string s_didNotCopy = "Did not copy from file \"";
private const string s_to = "\" to \"";
private readonly XDocument _document;
private readonly Dictionary<string, List<string>> _copyMap = new Dictionary<string, List<string>>(FilePathComparer);
private readonly string _logFilePath;
internal StructuredLoggerCheckerUtil(XDocument document)
internal StructuredLoggerCheckerUtil(string logFilePath)
{
_document = document;
_logFilePath = logFilePath;
}
public bool Check(TextWriter textWriter)
{
foreach (var element in _document.XPathSelectElements("//CopyTask"))
var build = Serialization.Read(_logFilePath);
var doubleWrites = DoubleWritesAnalyzer.GetDoubleWrites(build).ToArray();
if (doubleWrites.Any())
{
foreach (var message in element.Elements(XName.Get("Message")))
foreach (var doubleWrite in doubleWrites)
{
ProcessMessage(message);
}
}
var allGood = true;
foreach (var pair in _copyMap.OrderBy(x => x.Key))
{
var list = pair.Value;
if (list.Count > 1)
{
textWriter.WriteLine($"Multiple writes to {pair.Key}");
foreach (var item in list)
textWriter.WriteLine($"Multiple writes to {doubleWrite.Key}");
foreach (var source in doubleWrite.Value)
{
textWriter.WriteLine($"\t{item}");
textWriter.WriteLine($"\t{source}");
}
textWriter.WriteLine("");
allGood = false;
textWriter.WriteLine();
}
}
return allGood;
}
private void ProcessMessage(XElement element)
{
var text = element.Value.Trim();
if (text.StartsWith(s_copyingFileFrom))
{
ProcessCopyingFileFrom(text, s_copyingFileFrom, s_to);
}
else if (text.StartsWith(s_creatingHardLink))
{
ProcessCopyingFileFrom(text, s_creatingHardLink, s_to);
}
else if (text.StartsWith(s_didNotCopy))
{
// Ignore files which were not copied. This logic comes from the original
// analysis.
}
}
private void ProcessCopyingFileFrom(string text, string prefix, string infix)
{
var split = text.IndexOf(infix);
var prefixLength = prefix.Length;
int toLength = infix.Length;
var source = text.Substring(prefixLength, split - prefixLength);
var destination = text.Substring(split + toLength, text.Length - 2 - split - toLength);
List<string> list;
if (!_copyMap.TryGetValue(destination, out list))
{
list = new List<string>();
_copyMap[destination] = list;
return false;
}
list.Add(source);
return true;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册