提交 ae597ff5 编写于 作者: J Jared Parsons

Check for assembly resolution errors in bootstrap build

Our current setup for .Net Core requires us to do manual assembly redirection in our MSBuild Task.  The setup has no
good way to detect at compile time when our source code and NuGet references get out of date.  This change allows us
to at least detect at bootstrap time.
上级 c99a7a5f
......@@ -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>
......
......@@ -58,6 +58,10 @@ private static bool TryRedirect(AssemblyName name)
}
#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,14 @@ private static string NormalizePath(string path)
}
private string GetDirectory(Assembly assembly) => Path.GetDirectoryName(Utilities.GetLocation(assembly));
internal static void AddFailedLoad(AssemblyName name)
{
if (Path.GetExtension(name.Name) != ".resources")
{
s_failedLoadSet.TryAdd(name, 0);
}
}
}
#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.
先完成此消息的编辑!
想要评论请 注册