diff --git a/build/Targets/Imports.targets b/build/Targets/Imports.targets index 1f010ff9198702b562f17fb9a511911cb5b55574..4b16a9b941bc314a4e5eef4020b7946d4983e752 100644 --- a/build/Targets/Imports.targets +++ b/build/Targets/Imports.targets @@ -353,7 +353,7 @@ Condition="!Exists('$(ToolsetCompilerPropsFilePath)')" /> - + diff --git a/src/Compilers/Core/MSBuildTask/AssemblyResolution.cs b/src/Compilers/Core/MSBuildTask/AssemblyResolution.cs index 1951262e4fea75f65c4e4a8597b5fd77f2c88efe..88a011d4a80bf5e63a6b819504b5e04483f5602e 100644 --- a/src/Compilers/Core/MSBuildTask/AssemblyResolution.cs +++ b/src/Compilers/Core/MSBuildTask/AssemblyResolution.cs @@ -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; } diff --git a/src/Compilers/Core/MSBuildTask/ValidateBootstrap.cs b/src/Compilers/Core/MSBuildTask/ValidateBootstrap.cs index 1379efa5b01b323b74979acedf47a48b5f516f1c..ead4e9a0b3f2f4292fba60261b663535120554df 100644 --- a/src/Compilers/Core/MSBuildTask/ValidateBootstrap.cs +++ b/src/Compilers/Core/MSBuildTask/ValidateBootstrap.cs @@ -1,7 +1,9 @@ // 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 /// public sealed class ValidateBootstrap : Task { + private static readonly ConcurrentDictionary s_failedLoadSet = new ConcurrentDictionary(); + 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 } diff --git a/src/Compilers/Core/MSBuildTask/project.json b/src/Compilers/Core/MSBuildTask/project.json index 695676191007fe767fec1684786e29e6ad9f1bed..66b6c6a624968faa6665ed7cd239015b3f4dc160 100644 --- a/src/Compilers/Core/MSBuildTask/project.json +++ b/src/Compilers/Core/MSBuildTask/project.json @@ -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 +}