private IEnumerable <string> ResolveReferences(IEnumerable <string> folders, char referenceOption) { foreach (string referenceFolder in folders) { foreach (string reference in ComputeManagedAssemblies.GetManagedAssembliesInFolder(referenceFolder)) { string simpleName = Path.GetFileNameWithoutExtension(reference); if (!FrameworkExclusion.Exclude(simpleName, Index, out string reason)) { yield return($"-{referenceOption}:{reference}"); } } } }
public static bool Exclude(string simpleName, CompilerIndex index, out string reason) { FrameworkExclusion exclusion = Find(simpleName); if (exclusion != null && (exclusion.ExclusionType == ExclusionType.Ignore || exclusion.ExclusionType == ExclusionType.DontCrossgen2 && index == CompilerIndex.CPAOT)) { reason = exclusion.Reason; return(true); } else { reason = null; return(false); } }
public static bool Exclude(string simpleName, CompilerIndex index, out string reason) { FrameworkExclusion exclusion = Find(simpleName); if (exclusion != null && (exclusion.ExclusionType == ExclusionType.Ignore || exclusion.ExclusionType == ExclusionType.DontCrossgen2 && index == CompilerIndex.CPAOT)) { reason = exclusion.Reason; return(true); } if (simpleName.StartsWith("xunit.", StringComparison.OrdinalIgnoreCase)) { reason = "XUnit"; return(true); } reason = null; return(false); }
public CompileSerpCommand(BuildOptions options) { // This command does not work in the context of an app, just a loose set of rsp files so don't execute anything we compile options.NoJit = true; options.NoEtw = true; options.Release = true; options.LargeBubble = true; _options = options; if (_options.InputDirectory == null) { throw new ArgumentException("Specify --response-file or --input-directory containing multiple response files."); } if (_options.CoreRootDirectory == null) { throw new ArgumentException("--core-root-directory (--cr) is a required argument."); } if (_options.AspNetPath == null || !File.Exists(Path.Combine(_options.AspNetPath.FullName, "Microsoft.AspNetCore.dll"))) { throw new ArgumentException($"Error: Asp.NET Core path must contain Microsoft.AspNetCore.dll"); } SerpDir = _options.InputDirectory.FullName; BinDir = Path.Combine(SerpDir, "bin"); if (!File.Exists(Path.Combine(SerpDir, "runserp.cmd"))) { throw new ArgumentException($"Error: InputDirectory must point at a SERP build. Could not find {Path.Combine(SerpDir, "runserp.cmd")}"); } string allowListFilePath = Path.Combine(SerpDir, "App_Data", "AllowedDllList.txt"); if (!File.Exists(allowListFilePath)) { throw new ArgumentException($"File {allowListFilePath} was not found"); } // Add all assemblies from the various SERP packages (filtered by ShouldInclude) _packageCompileAssemblies = Directory.GetFiles(Path.Combine(SerpDir, "App_Data\\Answers\\Services\\Packages"), "*.dll", SearchOption.AllDirectories) .Where((string x) => ShouldInclude(x)) .ToList(); _packageReferenceAssemblies = new List <string>(); { HashSet <string> packageReferenceAssemblyDirectories = new HashSet <string>(); foreach (var binFile in _packageCompileAssemblies) { var directory = Path.GetDirectoryName(binFile); if (!packageReferenceAssemblyDirectories.Contains(directory)) { packageReferenceAssemblyDirectories.Add(directory); } } foreach (string binFile in ResolveReferences(packageReferenceAssemblyDirectories)) { _packageReferenceAssemblies.Add(binFile); } } _coreCompileAssemblies = new List <string>(); _coreReferenceAssemblies = new List <string>(); { // Add an allow-list of assemblies from bin. This unified list includes binaries from /bin and /App_data so filter just the /bin assemblies foreach (string item in new HashSet <string>(File.ReadAllLines(allowListFilePath))) { string binAssembly = Path.Combine(BinDir, item); if (File.Exists(binAssembly) && !FrameworkExclusion.Exclude(Path.GetFileNameWithoutExtension(binAssembly), CompilerIndex.CPAOT, out string reason)) { _coreCompileAssemblies.Add(binAssembly); } } HashSet <string> coreReferenceAssemblyDirectories = new HashSet <string>(); foreach (var binFile in _coreCompileAssemblies) { var directory = Path.GetDirectoryName(binFile); if (!coreReferenceAssemblyDirectories.Contains(directory)) { coreReferenceAssemblyDirectories.Add(directory); } } foreach (string binFile in ResolveReferences(coreReferenceAssemblyDirectories)) { _coreReferenceAssemblies.Add(binFile); } } _frameworkCompileAssemblies = new List <string>(); _frameworkReferenceAssemblies = new List <string>(); { foreach (string frameworkDll in ComputeManagedAssemblies.GetManagedAssembliesInFolder(options.CoreRootDirectory.FullName, "System.*.dll")) { string simpleName = Path.GetFileNameWithoutExtension(frameworkDll); if (!FrameworkExclusion.Exclude(simpleName, CompilerIndex.CPAOT, out string reason)) { _frameworkCompileAssemblies.Add(frameworkDll); } } foreach (string frameworkDll in ComputeManagedAssemblies.GetManagedAssembliesInFolder(options.CoreRootDirectory.FullName, "Microsoft.*.dll")) { string simpleName = Path.GetFileNameWithoutExtension(frameworkDll); if (!FrameworkExclusion.Exclude(simpleName, CompilerIndex.CPAOT, out string reason)) { _frameworkCompileAssemblies.Add(frameworkDll); } } _frameworkCompileAssemblies.Add(Path.Combine(options.CoreRootDirectory.FullName, "mscorlib.dll")); _frameworkCompileAssemblies.Add(Path.Combine(options.CoreRootDirectory.FullName, "netstandard.dll")); _frameworkReferenceAssemblies.AddRange(ComputeManagedAssemblies.GetManagedAssembliesInFolder(options.CoreRootDirectory.FullName, "System.*.dll")); _frameworkReferenceAssemblies.AddRange(ComputeManagedAssemblies.GetManagedAssembliesInFolder(options.CoreRootDirectory.FullName, "Microsoft.*.dll")); _frameworkReferenceAssemblies.Add(Path.Combine(options.CoreRootDirectory.FullName, "mscorlib.dll")); _frameworkReferenceAssemblies.Add(Path.Combine(options.CoreRootDirectory.FullName, "netstandard.dll")); } _aspCompileAssemblies = new List <string>(); _aspReferenceAssemblies = new List <string>(); { _aspCompileAssemblies.AddRange(ComputeManagedAssemblies.GetManagedAssembliesInFolder(options.AspNetPath.FullName, "Microsoft.AspNetCore.*.dll")); _aspCompileAssemblies.AddRange(ComputeManagedAssemblies.GetManagedAssembliesInFolder(options.AspNetPath.FullName, "Microsoft.Extensions.*.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "Microsoft.JSInterop.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "Microsoft.Net.Http.Headers.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "Microsoft.Win32.SystemEvents.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.Diagnostics.EventLog.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.Drawing.Common.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.IO.Pipelines.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.Security.Cryptography.Pkcs.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.Security.Cryptography.Xml.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.Security.Permissions.dll")); _aspCompileAssemblies.Add(Path.Combine(options.AspNetPath.FullName, "System.Windows.Extensions.dll")); _aspReferenceAssemblies = new List <string>(_aspCompileAssemblies); } }