static Gac() { var keywords = new List <string>(); keywords.Add("msco"); keywords.Add("System"); keywords.Add("Microsoft."); keywords.Add("WindowsBase"); keywords.Add("WindowsForms"); keywords.Add("Presentation"); keywords.Add("Policy."); keywords.Add("UIAutomation"); keywords.Add("Env"); keywords.Add("vjs"); keywords.Add("Vslang"); keywords.Add("EnvDTE"); keywords.Add("EnvDTE"); SystemAssemblyNames = new HashSet <string>(); if (!NLiteEnvironment.IsMono) { foreach (var a in GacCache.GetAssemblyStringNames()) { if (!string.IsNullOrEmpty(keywords.FirstOrDefault(p => a.StartsWith(p)))) { SystemAssemblyNames.Add(a); } } } keywords.Clear(); AssemblyNameCache = new Dictionary <int, string>(); }
/// <summary> /// 得到Gac中所有的AssemblyName /// </summary> /// <returns></returns> public static IEnumerable <AssemblyName> GetAssemblyNames() { //if (UfaEnvironment.IsMono) // return Enumerable.Empty<AssemblyName>(); return(GacCache.GetAssemblyNames()); }
public static AssemblyName GetAssemblyName(string strName, Version version) { var assemblyName = strName.ToLower(); IAssemblyName an; try { IAssemblyEnum ae = GacCache.CreateGACEnum(); while (GacCache.GetNextAssembly(ae, out an) == 0) { if (GacCache.GetName(an).ToLower().Contains(assemblyName)) { if (version == null) { return(GetAssemblyName(an)); } if (GetVersion(an) == version) { return(GetAssemblyName(an)); } } } } finally { } return(null); }
static IAssemblyName CreateAssemblyName(string name) { IAssemblyName an; GacCache.CreateAssemblyNameObject(out an, name, 2, (IntPtr)0); return(an); }
static IAssemblyEnum CreateGACEnum() { IAssemblyEnum ae; GacCache.CreateAssemblyEnum(out ae, (IntPtr)0, null, ASM_CACHE_FLAGS.ASM_CACHE_GAC, (IntPtr)0); return(ae); }
static String GetDownloadPath() { uint bufferSize = 255; StringBuilder buffer = new StringBuilder((int)bufferSize); GacCache.GetCachePath(ASM_CACHE_FLAGS.ASM_CACHE_DOWNLOAD, buffer, ref bufferSize); return(buffer.ToString()); }
/// <summary> /// Use this method as a start for the GAC API /// </summary> /// <returns>IAssemblyCache COM interface</returns> static IAssemblyCache CreateAssemblyCache() { IAssemblyCache ac; GacCache.CreateAssemblyCache(out ac, 0); return(ac); }
/// <summary> /// 得到Gac中所有的AssemblyName /// </summary> /// <returns></returns> public static IEnumerable <AssemblyName> GetAssemblyNames() { if (NLiteEnvironment.IsMono) { return(Enumerable.Empty <AssemblyName>()); } return(GacCache.GetAssemblyNames()); }
protected SolutionBase(SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver) : this(tfc, solutionTask) { if (solutionTask.SolutionFile != null) { _file = solutionTask.SolutionFile; } else { LoadProjectGuids(new ArrayList(solutionTask.Projects.FileNames), false); LoadProjectGuids(new ArrayList(solutionTask.ReferenceProjects.FileNames), true); LoadProjects(gacCache, refResolver, CollectionsUtil.CreateCaseInsensitiveHashtable()); } }
public MSBuildProjectReference( ReferencesResolver referencesResolver, ProjectBase parent, SolutionBase solution, TempFileCollection tfc, GacCache gacCache, DirectoryInfo outputDir, string pguid, string pname, string rpath, string priv) : base(referencesResolver, parent) { _helper = new MSBuildReferenceHelper(priv, true); string projectFile = solution.GetProjectFileFromGuid(pguid); _project = LoadProject(solution, tfc, gacCache, outputDir, projectFile); }
protected FileReferenceBase(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache) : base(referencesResolver, parent) { if (xmlDefinition == null) { throw new ArgumentNullException("xmlDefinition"); } if (gacCache == null) { throw new ArgumentNullException("gacCache"); } _xmlDefinition = xmlDefinition; _gacCache = gacCache; }
public static IEnumerable <string> GetAssemblyStringNames() { IAssemblyName an; try { IAssemblyEnum ae = GacCache.CreateGACEnum(); while (GacCache.GetNextAssembly(ae, out an) == 0) { yield return(GacCache.GetName(an)); } } finally { } }
static AssemblyName GetAssemblyName(IAssemblyName nameRef) { AssemblyName name = new AssemblyName(); try { name.Name = GacCache.GetName(nameRef); name.Version = GacCache.GetVersion(nameRef); name.CultureInfo = GacCache.GetCulture(nameRef); name.SetPublicKeyToken(GacCache.GetPublicKeyToken(nameRef)); } catch { } return(name); }
public static string GetAssemblyFullName(string strName) { var assemblyName = strName.ToLower(); IAssemblyName an; try { IAssemblyEnum ae = GacCache.CreateGACEnum(); while (GacCache.GetNextAssembly(ae, out an) == 0) { var name = GacCache.GetName(an).ToLower(); if (name == assemblyName) { return(GetAssemblyName(an).ToString()); } } } finally { } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="ProjectBase" /> class. /// </summary> protected ProjectBase(XmlElement xmlDefinition, SolutionTask solutionTask, TempFileCollection temporaryFiles, GacCache gacCache, ReferencesResolver referencesResolver, DirectoryInfo outputDir) { if (xmlDefinition == null) { throw new ArgumentNullException("xmlDefinition"); } if (solutionTask == null) { throw new ArgumentNullException("solutionTask"); } if (temporaryFiles == null) { throw new ArgumentNullException("temporaryFiles"); } if (gacCache == null) { throw new ArgumentNullException("gacCache"); } if (referencesResolver == null) { throw new ArgumentNullException("referencesResolver"); } _projectConfigurations = new ConfigurationDictionary(); _buildConfigurations = new ConfigurationDictionary(); _extraOutputFiles = CollectionsUtil.CreateCaseInsensitiveHashtable(); // ensure the specified project is actually supported by this project VerifyProjectXml(xmlDefinition); _solutionTask = solutionTask; _temporaryFiles = temporaryFiles; _outputDir = outputDir; _gacCache = gacCache; _refResolver = referencesResolver; _productVersion = DetermineProductVersion(xmlDefinition); }
public MSBuildProject(SolutionBase solution, string projectPath, XmlElement xmlDefinition, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver, DirectoryInfo outputDir) : base(xmlDefinition, solutionTask, tfc, gacCache, refResolver, outputDir) { string cfgname = solutionTask.Configuration; string platform = solutionTask.Platform; _msbuild = MSBuildEngine.CreateMSEngine(solutionTask); _msproj = new Microsoft.Build.BuildEngine.Project(_msbuild); _msproj.FullFileName = projectPath; _msproj.LoadXml(xmlDefinition.OuterXml); _msproj.GlobalProperties.SetProperty("Configuration", cfgname); SetPlatform(platform); if (outputDir != null) { _msproj.GlobalProperties.SetProperty("OutputPath", outputDir.FullName); } //evaluating _guid = _msproj.GetEvaluatedProperty("ProjectGuid"); _projectDirectory = new DirectoryInfo(_msproj.GetEvaluatedProperty("ProjectDir")); _projectPath = _msproj.GetEvaluatedProperty("ProjectPath"); ProjectEntry projectEntry = solution.ProjectEntries [_guid]; if (projectEntry != null && projectEntry.BuildConfigurations != null) { foreach (ConfigurationMapEntry ce in projectEntry.BuildConfigurations) { Configuration projectConfig = ce.Value; ProjectConfigurations[projectConfig] = new MSBuildConfiguration(this, _msproj, projectConfig); } } else { Configuration projectConfig = new Configuration(cfgname, platform); ProjectConfigurations[projectConfig] = new MSBuildConfiguration(this, _msproj, projectConfig); } //references _references = new ArrayList(); Microsoft.Build.BuildEngine.BuildItemGroup refs = _msproj.GetEvaluatedItemsByName("Reference"); foreach (Microsoft.Build.BuildEngine.BuildItem r in refs) { string rpath = r.FinalItemSpec; string priv = r.GetMetadata("Private"); string hintpath = r.GetMetadata("HintPath"); ReferenceBase reference = new MSBuildAssemblyReference( xmlDefinition, ReferencesResolver, this, gacCache, rpath, priv, hintpath); _references.Add(reference); } refs = _msproj.GetEvaluatedItemsByName("ProjectReference"); foreach (Microsoft.Build.BuildEngine.BuildItem r in refs) { string pguid = r.GetMetadata("Project"); string pname = r.GetMetadata("Name"); string rpath = r.FinalItemSpec; string priv = r.GetMetadata("Private"); ReferenceBase reference = new MSBuildProjectReference( ReferencesResolver, this, solution, tfc, gacCache, outputDir, pguid, pname, rpath, priv); _references.Add(reference); } }
public GenericSolution(SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver) : base(solutionTask, tfc, gacCache, refResolver) { }
public SolutionBase GetInstance(string solutionContent, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver) { return(new WhidbeySolution(solutionContent, solutionTask, tfc, gacCache, refResolver)); }
public ProjectBase LoadProject(SolutionBase solution, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver referencesResolver, DirectoryInfo outputDir, string path) { // check if this a new project if (!_cachedProjects.Contains(path)) { ProjectBase project = CreateProject(solution, solutionTask, tfc, gacCache, referencesResolver, outputDir, path); _cachedProjects[path] = project; } return((ProjectBase)_cachedProjects[path]); }
private ProjectBase CreateProject(SolutionBase solution, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver referencesResolver, DirectoryInfo outputDir, string projectPath) { // determine the filename of the project string projectFileName = ProjectFactory.GetProjectFileName(projectPath); // determine the extension of the project file string projectExt = Path.GetExtension(projectFileName).ToLower( CultureInfo.InvariantCulture); // fast-skip setup projects since the project files is not XML-based if (projectExt == ".vdproj") { return(null); } // holds the XML definition of the project XmlElement xmlDefinition; try { XmlDocument doc = LoadProjectXml(projectPath); xmlDefinition = doc.DocumentElement; } catch (Exception ex) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Error loading project '{0}'.", projectPath), Location.UnknownLocation, ex); } IProjectBuildProvider provider = FindProvider(projectExt, xmlDefinition); if (provider != null) { return(provider.GetInstance(solution, projectPath, xmlDefinition, solutionTask, tfc, gacCache, referencesResolver, outputDir)); } // either the project file is invalid or we don't support it throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Project '{0}' is invalid or not supported (at this time).", projectPath), Location.UnknownLocation); }
public ProjectBase GetInstance(SolutionBase solution, string projectPath, XmlElement xmlDefinition, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver, DirectoryInfo outputDir) { return(new VBProject(solution, projectPath, xmlDefinition, solutionTask, tfc, gacCache, refResolver, outputDir)); }
public SolutionBase LoadSolution(SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver) { if (solutionTask.SolutionFile == null) { return(new GenericSolution(solutionTask, tfc, gacCache, refResolver)); } else { // determine the solution file format version // will hold the content of the solution file string fileContents; using (StreamReader sr = new StreamReader(solutionTask.SolutionFile.FullName, Encoding.Default, true)) { fileContents = sr.ReadToEnd(); } ISolutionBuildProvider provider = FindProvider(fileContents); if (provider != null) { return(provider.GetInstance(fileContents, solutionTask, tfc, gacCache, refResolver)); } throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Solution format of file '{0}' is not supported.", solutionTask.SolutionFile), Location.UnknownLocation); } }
public JSharpProject(SolutionBase solution, string projectPath, XmlElement xmlDefinition, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver, DirectoryInfo outputDir) : base(solution, projectPath, xmlDefinition, solutionTask, tfc, gacCache, refResolver, outputDir) { }
public ManagedProjectReference(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, SolutionBase solution, TempFileCollection tfc, GacCache gacCache, DirectoryInfo outputDir) : base(referencesResolver, parent) { if (xmlDefinition == null) { throw new ArgumentNullException("xmlDefinition"); } if (solution == null) { throw new ArgumentNullException("solution"); } if (tfc == null) { throw new ArgumentNullException("tfc"); } if (gacCache == null) { throw new ArgumentNullException("gacCache"); } XmlAttribute privateAttribute = xmlDefinition.Attributes["Private"]; if (privateAttribute != null) { _isPrivateSpecified = true; _isPrivate = bool.Parse(privateAttribute.Value); } // determine path of project file string projectFile = solution.GetProjectFileFromGuid( xmlDefinition.GetAttribute("Project")); // load referenced project _project = LoadProject(solution, tfc, gacCache, outputDir, projectFile); }
public VcAssemblyReference(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache) : base(xmlDefinition, referencesResolver, parent, gacCache) { XmlAttribute privateAttribute = xmlDefinition.Attributes["CopyLocal"]; if (privateAttribute != null) { _isPrivateSpecified = true; _isPrivate = bool.Parse(privateAttribute.Value); } // determine name of reference by taking filename part of relative // path, without extension XmlAttribute relativePathAttribute = XmlDefinition.Attributes["RelativePath"]; if (relativePathAttribute != null) { _name = Path.GetFileNameWithoutExtension(relativePathAttribute.Value); } _assemblyFile = ResolveAssemblyReference(); }
public ManagedAssemblyReference(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache) : base(xmlDefinition, referencesResolver, parent, gacCache) { XmlAttribute privateAttribute = xmlDefinition.Attributes["Private"]; if (privateAttribute != null) { _isPrivateSpecified = true; _isPrivate = bool.Parse(privateAttribute.Value); } // determine name of reference XmlAttribute assemblyNameAttribute = XmlDefinition.Attributes["AssemblyName"]; if (assemblyNameAttribute != null) { _name = assemblyNameAttribute.Value; } _assemblyFile = ResolveAssemblyReference(); }
protected ProjectBase LoadProject(SolutionBase solution, TempFileCollection tfc, GacCache gacCache, DirectoryInfo outputDir, string projectFile) { if (ProjectStack.Contains(projectFile)) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Circular reference to \"{0}\" detected in project \"{1}\".", Path.GetFileNameWithoutExtension(projectFile), Parent.Name), Location.UnknownLocation); } try { ProjectStack.Push(projectFile); Log(Level.Verbose, "Loading referenced project '{0}'.", projectFile); return(SolutionTask.ProjectFactory.LoadProject(solution, SolutionTask, tfc, gacCache, ReferencesResolver, outputDir, projectFile)); } finally { ProjectStack.Pop(); } }
public Solution(string solutionContent, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver) : base(solutionTask, tfc, gacCache, refResolver) { Regex reProjects = new Regex(@"Project\(\""(?<package>\{.*?\})\"".*?\""(?<name>.*?)\"".*?\""(?<project>.*?)\"".*?\""(?<guid>.*?)\""(?<all>[\s\S]*?)EndProject", RegexOptions.Multiline); MatchCollection projectMatches = reProjects.Matches(solutionContent); Hashtable explicitProjectDependencies = CollectionsUtil.CreateCaseInsensitiveHashtable(); foreach (Match projectMatch in projectMatches) { string project = projectMatch.Groups["project"].Value; string guid = projectMatch.Groups["guid"].Value; // translate partial project path or URL to absolute path string fullProjectPath = TranslateProjectPath(solutionTask.SolutionFile.DirectoryName, project); // check if project file actually exists if (!System.IO.File.Exists(fullProjectPath)) { throw CreateProjectDoesNotExistException(fullProjectPath); } if (ManagedProjectBase.IsEnterpriseTemplateProject(fullProjectPath)) { RecursiveLoadTemplateProject(fullProjectPath); } else { // add project path to collection ProjectEntries.Add(new ProjectEntry(guid, fullProjectPath)); } // set-up project dependencies Regex reDependencies = new Regex(@"^\s+" + guid + @"\.[0-9]+ = (?<dep>\{\S*\}?)\s*$", RegexOptions.Multiline); MatchCollection dependencyMatches = reDependencies.Matches(solutionContent); foreach (Match dependencyMatch in dependencyMatches) { string dependency = dependencyMatch.Groups["dep"].Value; if (!explicitProjectDependencies.ContainsKey(guid)) { explicitProjectDependencies[guid] = CollectionsUtil.CreateCaseInsensitiveHashtable(); } ((Hashtable)explicitProjectDependencies[guid])[dependency] = null; } // set-up project configuration Regex reProjectBuildConfig = new Regex(@"^\s+" + guid + @"\.(?<solutionConfiguration>[^|]+)\.Build\.0\s*=\s*(?<projectConfiguration>[^|]+)\|\s*\S*", RegexOptions.Multiline); MatchCollection projectBuildMatches = reProjectBuildConfig.Matches(solutionContent); // initialize hashtable that will hold the project build configurations Hashtable projectBuildConfiguration = CollectionsUtil.CreateCaseInsensitiveHashtable(); if (projectBuildMatches.Count > 0) { foreach (Match projectBuildMatch in projectBuildMatches) { string solutionConfiguration = projectBuildMatch.Groups["solutionConfiguration"].Value; string projectConfiguration = projectBuildMatch.Groups["projectConfiguration"].Value; projectBuildConfiguration[solutionConfiguration] = projectConfiguration; } } // add project build configuration, this signals that project was // loaded in context of solution file ProjectBuildConfigurations[guid] = projectBuildConfiguration; } LoadProjectGuids(new ArrayList(solutionTask.Projects.FileNames), false); LoadProjectGuids(new ArrayList(solutionTask.ReferenceProjects.FileNames), true); LoadProjects(gacCache, refResolver, explicitProjectDependencies); }
public Resource(ManagedProjectBase project, FileInfo resourceSourceFile, string resourceSourceFileRelativePath, string dependentFile, SolutionTask solutionTask, GacCache gacCache) { _project = project; _resourceSourceFile = resourceSourceFile; _resourceSourceFileRelativePath = resourceSourceFileRelativePath; _dependentFile = dependentFile; _solutionTask = solutionTask; _culture = CompilerBase.GetResourceCulture(resourceSourceFile.FullName, dependentFile); }
protected AssemblyReferenceBase(XmlElement xmlDefinition, ReferencesResolver referencesResolver, ProjectBase parent, GacCache gacCache) : base(xmlDefinition, referencesResolver, parent, gacCache) { }