/// <summary> /// Set the target framework paths. /// This is used to optimize IO in the case of files requested from one /// of the FX folders. /// </summary> /// <param name="providedFrameworkPaths"></param> /// <param name="installedAssemblyTables"></param> internal void SetInstalledAssemblyInformation ( AssemblyTableInfo[] installedAssemblyTableInfos ) { redistList = RedistList.GetRedistList(installedAssemblyTableInfos); }
public bool IsInFramework(string frameworkIdentifier, string frameworkVersion) { Version version = null; if (!string.IsNullOrEmpty(frameworkVersion)) { // CA1307:Specify StringComparison. Suppressed since a valid string representation of a version would be parsed correctly even if the the first character is not "v". if (frameworkVersion.StartsWith("v")) { System.Version.TryParse(frameworkVersion.Substring(1), out version); } else { System.Version.TryParse(frameworkVersion, out version); } } if (string.IsNullOrEmpty(frameworkIdentifier) && version != null) { throw new ArgumentNullException("frameworkIdentifier"); } Dictionary <string, RedistList> redistDictionary = new Dictionary <string, RedistList>(); foreach (string moniker in ToolLocationHelper.GetSupportedTargetFrameworks()) { FrameworkNameVersioning frameworkName = new FrameworkNameVersioning(moniker); if ((string.IsNullOrEmpty(frameworkIdentifier) || frameworkName.Identifier.Equals(frameworkIdentifier, StringComparison.OrdinalIgnoreCase)) && (version == null || frameworkName.Version == version)) { IList <string> paths = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkName); foreach (string path in paths) { if (!redistDictionary.ContainsKey(path)) { redistDictionary.Add(path, RedistList.GetRedistListFromPath(path)); } } } } string fullName = GetFullName(AssemblyIdentity.FullNameFlags.Default); foreach (RedistList list in redistDictionary.Values) { if (list != null && list.IsFrameworkAssembly(fullName)) { return(true); } } return(false); }
/// <summary> /// For a given profile generate the exclusion list and return the list of redist list files read in so they can be logged at the end of the task execution. /// </summary> /// <param name="installedAssemblyTableInfo">Installed assembly info of the profile redist lists</param> /// <param name="fullRedistAssemblyTableInfo">Installed assemblyInfo for the full framework redist lists</param> /// <param name="blackList">Generated exclusion list</param> private void HandleProfile(AssemblyTableInfo[] installedAssemblyTableInfo, out AssemblyTableInfo[] fullRedistAssemblyTableInfo, out Hashtable blackList, out RedistList fullFrameworkRedistList) { // Redist list which will contain the full framework redist list. fullFrameworkRedistList = null; blackList = null; fullRedistAssemblyTableInfo = null; // Make sure the framework directory is on the FullFrameworkTablesLocation if it is being used. foreach (ITaskItem item in FullFrameworkAssemblyTables) { // Cannot be missing the FrameworkDirectory if we are using this property if (String.IsNullOrEmpty(item.GetMetadata("FrameworkDirectory"))) { Log.LogErrorWithCodeFromResources("ResolveAssemblyReference.FrameworkDirectoryOnProfiles", item.ItemSpec); return; } } fullRedistAssemblyTableInfo = GetInstalledAssemblyTableInfo(false, FullFrameworkAssemblyTables, new GetListPath(RedistList.GetRedistListPathsFromDisk), FullFrameworkFolders); if (fullRedistAssemblyTableInfo.Length > 0) { // Get the redist list which represents the Full framework, we need this so that we can generate the exclusion list fullFrameworkRedistList = RedistList.GetRedistList(fullRedistAssemblyTableInfo); if (fullFrameworkRedistList != null) { // Generate the black list by determining what assemblies are in the full framework but not in the profile. // The installedAssemblyTableInfo is the list of xml files for the Client Profile redist, these are the whitelist xml files. Log.LogMessageFromResources("ResolveAssemblyReference.ProfileExclusionListWillBeGenerated"); // Any errors reading the profile redist list will already be logged, we do not need to re-log the errors here. List<Exception> whiteListErrors = new List<Exception>(); List<string> whiteListErrorFilesNames = new List<string>(); blackList = fullFrameworkRedistList.GenerateBlackList(installedAssemblyTableInfo, whiteListErrors, whiteListErrorFilesNames); } // Could get into this situation if the redist list files were full of junk and no assemblies were read in. if (blackList == null) { Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.NoRedistAssembliesToGenerateExclusionList"); } } else { Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.NoProfilesFound"); } if (fullFrameworkRedistList != null) { // Any errors logged for the client profile redist list will have been logged after this method returns. // Some files may have been skipped. Log warnings for these. for (int i = 0; i < fullFrameworkRedistList.Errors.Length; ++i) { Exception e = fullFrameworkRedistList.Errors[i]; string filename = fullFrameworkRedistList.ErrorFileNames[i]; // Give the user a warning about the bad file (or files). Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.InvalidProfileRedistLocation", filename, RedistList.RedistListFolder, e.Message); } } }
private void HandleProfile(AssemblyTableInfo[] installedAssemblyTableInfo, out AssemblyTableInfo[] fullRedistAssemblyTableInfo, out Hashtable blackList, out RedistList fullFrameworkRedistList) { fullFrameworkRedistList = null; blackList = null; fullRedistAssemblyTableInfo = null; foreach (ITaskItem item in this.FullFrameworkAssemblyTables) { if (string.IsNullOrEmpty(item.GetMetadata("FrameworkDirectory"))) { base.Log.LogErrorWithCodeFromResources("ResolveAssemblyReference.FrameworkDirectoryOnProfiles", new object[] { item.ItemSpec }); return; } } fullRedistAssemblyTableInfo = this.GetInstalledAssemblyTableInfo(false, this.FullFrameworkAssemblyTables, new GetListPath(RedistList.GetRedistListPathsFromDisk), this.FullFrameworkFolders); if (fullRedistAssemblyTableInfo.Length > 0) { fullFrameworkRedistList = RedistList.GetRedistList(fullRedistAssemblyTableInfo); if (fullFrameworkRedistList != null) { base.Log.LogMessageFromResources("ResolveAssemblyReference.ProfileExclusionListWillBeGenerated", new object[0]); blackList = fullFrameworkRedistList.GenerateBlackList(installedAssemblyTableInfo); } if (blackList == null) { base.Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.NoRedistAssembliesToGenerateExclusionList", new object[0]); } } else { base.Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.NoProfilesFound", new object[0]); } if (fullFrameworkRedistList != null) { for (int i = 0; i < fullFrameworkRedistList.Errors.Length; i++) { Exception exception = fullFrameworkRedistList.Errors[i]; string str = fullFrameworkRedistList.ErrorFileNames[i]; base.Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.InvalidProfileRedistLocation", new object[] { str, RedistList.RedistListFolder, exception.Message }); } } }
/// <summary> /// Construct. /// </summary> /// <param name="redistList"></param> internal InstalledAssemblies(RedistList redistList) { _redistList = redistList; }
/// <summary> /// Set the target framework paths. /// This is used to optimize IO in the case of files requested from one /// of the FX folders. /// </summary> /// <param name="providedFrameworkPaths"></param> /// <param name="installedAssemblyTables"></param> internal void SetInstalledAssemblyInformation ( AssemblyTableInfo[] installedAssemblyTableInfos ) { _redistList = RedistList.GetRedistList(installedAssemblyTableInfos); }
/// <summary> /// Construct. /// </summary> internal InstalledAssemblies(RedistList redistList) { _redistList = redistList; }