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

Merge pull request #15915 from jaredpar/fix-server

Check for assembly resolution errors in bootstrap build
......@@ -353,7 +353,7 @@
Condition="!Exists('$(ToolsetCompilerPropsFilePath)')" />
</Target>
<Target Name="CheckBootstrapState" Condition="'$(BootstrapBuildPath)' != ''" BeforeTargets="CoreCompile">
<Target Name="CheckBootstrapState" Condition="'$(BootstrapBuildPath)' != ''" AfterTargets="CoreCompile">
<ValidateBootstrap BootstrapPath="$(BootstrapBuildPath)" />
</Target>
......
......@@ -54,10 +54,15 @@ private static bool TryRedirect(AssemblyName name)
return TryRedirect(name, s_b03f5f7f11d50a3a, 4, 0, 2, 0);
case "System.Diagnostics.StackTrace":
case "System.Security.AccessControl":
return TryRedirect(name, s_b03f5f7f11d50a3a, 4, 0, 3, 0);
}
#if DEBUG || BOOTSTRAP
ValidateBootstrap.AddFailedLoad(name);
#endif
return false;
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Build.Utilities;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Reflection;
using System;
......@@ -15,6 +17,8 @@ namespace Microsoft.CodeAnalysis.BuildTasks
/// </summary>
public sealed class ValidateBootstrap : Task
{
private static readonly ConcurrentDictionary<AssemblyName, byte> s_failedLoadSet = new ConcurrentDictionary<AssemblyName, byte>();
private string _bootstrapPath;
public string BootstrapPath
......@@ -26,6 +30,7 @@ public string BootstrapPath
public ValidateBootstrap()
{
}
public override bool Execute()
......@@ -54,6 +59,16 @@ public override bool Execute()
}
}
var failedLoads = s_failedLoadSet.Keys.ToList();
if (failedLoads.Count > 0)
{
foreach (var name in failedLoads.OrderBy(x => x.Name))
{
Log.LogError($"Assembly resolution failed for {name}");
allGood = false;
}
}
return allGood;
}
......@@ -74,6 +89,21 @@ private static string NormalizePath(string path)
}
private string GetDirectory(Assembly assembly) => Path.GetDirectoryName(Utilities.GetLocation(assembly));
internal static void AddFailedLoad(AssemblyName name)
{
switch (name.Name)
{
case "System":
case "System.Core":
case "Microsoft.Build.Tasks.CodeAnalysis.resources":
// These are failures are expected by design.
break;
default:
s_failedLoadSet.TryAdd(name, 0);
break;
}
}
}
#endif
}
......@@ -7,6 +7,7 @@
"Microsoft.Win32.Primitives": "4.3.0",
"System.AppContext": "4.3.0",
"System.Console": "4.3.0",
"System.Collections.Concurrent": "4.3.0",
"System.Diagnostics.Process": "4.3.0",
"System.Diagnostics.Tools": "4.3.0",
"System.IO.FileSystem": "4.3.0",
......@@ -31,4 +32,4 @@
]
}
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册