protected override void ApplyProjectReferenceAdded(ProjectId projectId, ProjectReference projectReference) { if (projectId == null) { throw new ArgumentNullException("projectId"); } if (projectReference == null) { throw new ArgumentNullException("projectReference"); } IVisualStudioHostProject hostProject; IVsHierarchy hierarchy; EnvDTE.Project project; GetProjectData(projectId, out hostProject, out hierarchy, out project); IVisualStudioHostProject refHostProject; IVsHierarchy refHierarchy; EnvDTE.Project refProject; GetProjectData(projectReference.ProjectId, out refHostProject, out refHierarchy, out refProject); VSLangProj.VSProject vsProject = (VSLangProj.VSProject)project.Object; vsProject.References.AddProject(refProject); }
public VisualBasicVSProjectEvents( [Import(ExportContractNames.VsTypes.CpsVSProject)] VSLangProj.VSProject vsProject, UnconfiguredProject project) { _vsProject = vsProject; ImportsEventsImpl = new OrderPrecedenceImportCollection <ImportsEvents>(projectCapabilityCheckProvider: project); }
private void LoadProjectReferenceTypesFromCurrentProject(Dictionary <string, Type> availableTypes, IServiceProvider provider, Project currentProject) { List <Project> referencedProjects = new List <Project>(); if (!DteHelper2.IsWebProject(currentProject)) { Vs.VSProject vsProject = currentProject.Object as Vs.VSProject; foreach (Vs.Reference reference in vsProject.References) { if (reference.SourceProject != null) { referencedProjects.Add(reference.SourceProject); } } } else { Web.VSWebSite webProject = currentProject.Object as Web.VSWebSite; foreach (Web.AssemblyReference reference in webProject.References) { Project project = GetSourceProject(reference); if (project != null) { referencedProjects.Add(project);; } } } LoadTypesFromProjects(referencedProjects, availableTypes, provider, currentProject); }
/// <summary> /// Adds (or verifies we already have) all the given assembly references in the active project /// </summary> /// <param name="references">Set of references to add to active project</param> private void AddReferences(IEnumerable <string> references) { if (references.Any()) { // Get active project -- throws if not available Project project = this.ActiveProject; VSLangProj.VSProject vsProject = project.Object as VSLangProj.VSProject; if (vsProject != null) { // Unconditionally add every reference. // The References.Add method contains the logic to check for an existing // reference of the same identity, and if found, will not change anything. foreach (string assemblyReference in references) { VSLangProj.Reference reference = vsProject.References.Add(assemblyReference); // The assembly reference string can have the full assembly identity format ('AssemblyName, Version=xxxx, Culture ...') // or it can be the full assembly file path. // If the assembly reference is a full path, assume it is not in the GAC and copy it locally to the project // so it can find it and also for bin-deployment support. if (ShouldCopyLocal(assemblyReference)) { reference.CopyLocal = true; } } } } }
protected override void ApplyProjectReferenceRemoved(ProjectId projectId, ProjectReference projectReference) { if (projectId == null) { throw new ArgumentNullException("projectId"); } if (projectReference == null) { throw new ArgumentNullException("projectReference"); } IVisualStudioHostProject hostProject; IVsHierarchy hierarchy; EnvDTE.Project project; GetProjectData(projectId, out hostProject, out hierarchy, out project); IVisualStudioHostProject refHostProject; IVsHierarchy refHierarchy; EnvDTE.Project refProject; GetProjectData(projectReference.ProjectId, out refHostProject, out refHierarchy, out refProject); VSLangProj.VSProject vsProject = (VSLangProj.VSProject)project.Object; foreach (VSLangProj.Reference reference in vsProject.References) { if (reference.SourceProject == refProject) { reference.Remove(); } } }
private void SetCodeAnalysisOnReferences(string rulesPath) { if (!DteHelper2.IsWebProject(this.project)) { Vs.VSProject vsProject = this.project.Object as Vs.VSProject; foreach (Vs.Reference reference in vsProject.References) { if (reference.SourceProject != null) { SetCodeAnalysisOnProject(reference.SourceProject, rulesPath); } } } else { Web.VSWebSite webProject = this.project.Object as Web.VSWebSite; foreach (Web.AssemblyReference reference in webProject.References) { Project project = GetSourceProject(reference); if (project != null) { SetCodeAnalysisOnProject(project, rulesPath); } } } }
protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, MetadataReference metadataReference) { if (projectId == null) { throw new ArgumentNullException("projectId"); } if (metadataReference == null) { throw new ArgumentNullException("metadataReference"); } IVisualStudioHostProject hostProject; IVsHierarchy hierarchy; EnvDTE.Project project; GetProjectData(projectId, out hostProject, out hierarchy, out project); string filePath = GetMetadataPath(metadataReference); if (filePath != null) { VSLangProj.VSProject vsProject = (VSLangProj.VSProject)project.Object; VSLangProj.Reference reference = vsProject.References.Find(filePath); if (reference != null) { reference.Remove(); } } }
public VSProjectTestImpl( VSLangProj.VSProject vsProject, IProjectThreadingService threadingService, ActiveConfiguredProject <ProjectProperties> projectProperties, UnconfiguredProject project) : base(vsProject, threadingService, projectProperties, project) { }
public VSProjectTestImpl( VSLangProj.VSProject vsProject, IProjectThreadingService threadingService, IActiveConfiguredValue <ProjectProperties> projectProperties, UnconfiguredProject project, BuildManager buildManager) : base(vsProject, threadingService, projectProperties, project, buildManager) { }
private VisualBasicVSImports CreateInstance( VSLangProj.VSProject vsProject = null, IProjectThreadingService threadingService = null, ActiveConfiguredProject <ConfiguredProject> activeConfiguredProject = null, IProjectAccessor projectAccessor = null, IUnconfiguredProjectVsServices vsServices = null, VisualBasicNamespaceImportsList importList = null) { return(new VisualBasicVSImports(vsProject, threadingService, activeConfiguredProject, projectAccessor, vsServices, importList)); }
private static VSProject CreateInstance( VSLangProj.VSProject vsproject, IProjectThreadingService threadingService, ActiveConfiguredProject <ProjectProperties> projectProperties, UnconfiguredProject?project = null, BuildManager?buildManager = null) { project ??= UnconfiguredProjectFactory.Create(); return(new VSProject(vsproject, threadingService, projectProperties, project, buildManager !)); }
internal VSProject( [Import(ExportContractNames.VsTypes.CpsVSProject)] VSLangProj.VSProject vsProject, IProjectThreadingService threadingService, ActiveConfiguredProject <ProjectProperties> projectProperties) { Requires.NotNull(vsProject, nameof(vsProject)); Requires.NotNull(threadingService, nameof(threadingService)); Requires.NotNull(projectProperties, nameof(projectProperties)); _vsProject = vsProject; _threadingService = threadingService; _projectProperties = projectProperties; }
internal VSProject( [Import(ExportContractNames.VsTypes.CpsVSProject)] VSLangProj.VSProject vsProject, IProjectThreadingService threadingService, ActiveConfiguredProject <ProjectProperties> projectProperties, UnconfiguredProject project) { _vsProject = vsProject; _threadingService = threadingService; _projectProperties = projectProperties; ImportsImpl = new OrderPrecedenceImportCollection <Imports>(projectCapabilityCheckProvider: project); VSProjectEventsImpl = new OrderPrecedenceImportCollection <VSProjectEvents>(projectCapabilityCheckProvider: project); }
private static VSProject CreateInstance( VSLangProj.VSProject vsproject = null, IProjectThreadingService threadingService = null, ActiveConfiguredProject <ProjectProperties> projectProperties = null, UnconfiguredProject project = null) { if (project == null) { project = UnconfiguredProjectFactory.Create(); } return(new VSProject(vsproject, threadingService, projectProperties, project)); }
public void ProjectFinishedGenerating(Project project) { //MessageBox.Show("starting"); RegistryKey rk = Registry.LocalMachine; RegistryKey armSimKey = rk.OpenSubKey(@"SOFTWARE\University of Victoria\ARMSim.150"); if (armSimKey == null) { return; } string interfaceDLL = null; string installDirectory = null; using (armSimKey) { object obj = armSimKey.GetValue(@"Install Directory"); if (obj is string) { installDirectory = (string)obj; interfaceDLL = installDirectory + @"\ARMPluginInterfaces.dll"; } } if (installDirectory == null) { installDirectory = @"C:\Program Files\University of Victoria\ARMSim.150"; interfaceDLL = installDirectory + @"\ARMPluginInterfaces.dll"; } if (File.Exists(interfaceDLL)) { //EnvDTE.Project proj2 = (EnvDTE.Project)project.Object; VSLangProj.VSProject proj = (project.Object as VSLangProj.VSProject); proj.References.Add(interfaceDLL); proj.References.Add("System.Windows.Forms"); proj.References.Add("System.Drawing"); // config = proj.Project.ConfigurationManager.ActiveConfiguration; foreach (EnvDTE.Configuration config in proj.Project.ConfigurationManager) { EnvDTE.Properties configProps = config.Properties; EnvDTE.Property prop = configProps.Item("OutputPath"); prop.Value = installDirectory; } //foreach } } //ProjectFinishedGenerating
public VisualBasicVSImports( [Import(ExportContractNames.VsTypes.CpsVSProject)] VSLangProj.VSProject vsProject, IProjectThreadingService threadingService, IActiveConfiguredValue <ConfiguredProject> activeConfiguredProject, IProjectAccessor projectAccessor, IUnconfiguredProjectVsServices unconfiguredProjectVSServices, VisualBasicNamespaceImportsList importsList) { _vsProject = vsProject; _activeConfiguredProject = activeConfiguredProject; _projectAccessor = projectAccessor; _threadingService = threadingService; _unconfiguredProjectVSServices = unconfiguredProjectVSServices; _importsList = importsList; AddEventSource(this); }
private void MoveFile(string currentFile, Project currentProject, string selectedPath, string selectedProject) { if (string.IsNullOrEmpty(selectedPath) || !Directory.Exists(selectedPath)) { return; } var referencingProjects = GetReferencingProjects(); CodeRush.Documents.Active.Close(EnvDTE.vsSaveChanges.vsSaveChangesPrompt); var mainFile = Path.Combine(selectedPath, Path.GetFileName(currentFile)); List <string> files = GetDependentFiles(Path.GetDirectoryName(currentFile), CodeRush.ProjectItems.Active); if (FileAlreadyExists(selectedPath, mainFile, files)) { MessageBox.Show("A file already exists in the destination directory with the same name"); return; } var mainProjectItem = MoveFiles(currentFile, currentProject, selectedProject, mainFile); MoveDependentFiles(currentProject, files, mainProjectItem); File.Delete(currentFile); DeleteDependentFiles(files); var targetProject = CodeRush.Solution.FindEnvDTEProject(selectedProject); if (targetProject.Name != currentProject.Name) { CodeRush.Solution.FindEnvDTEProject(currentProject.Name).Save(currentProject.FileName); } targetProject.Save(targetProject.FullName); foreach (var projectName in referencingProjects) { if (projectName == targetProject.Name) { continue; } VSLangProj.VSProject vsProject = CodeRush.Solution.FindEnvDTEProject(projectName).Object as VSLangProj.VSProject; vsProject.References.AddProject(targetProject); } CodeRush.File.Activate(mainFile); }
private ProjectTracker(VSProject vsProject) { Contract.Requires(vsProject != null); Contract.Requires(vsProject.Project != null); Contract.Requires(ProjectIsAvailable(vsProject.Project)); //Keep a pointer to our project VS_Project = vsProject; EnvDTE_Project = vsProject.Project; Contract.Assume(EnvDTE_Project.Properties != null); //Get our name ProjectName = EnvDTE_Project.Name; UniqueProjectName = EnvDTE_Project.UniqueName; //Get our host Version frameworkVersion = null; frameworkVersion = GetTargetFramework(EnvDTE_Project); VSServiceProvider.Current.Logger.WriteToLog("fx version: " + frameworkVersion.ToString()); this._host = VSServiceProvider.Current.GetHost(frameworkVersion); //Eagerly add our project's references to the host's lib paths AddProjectReferencesPathsIntoHost(References, Host); //Subscribe to build events VSServiceProvider.Current.BuildBegin += OnBuildBegin; VSServiceProvider.Current.BuildDone += OnBuildDone; //Initialize build variables BuildNumber = 0; InBuild = false; //Get our assembly identity AssemblyIdentity = GetAssemblyIdentity(EnvDTE_Project, Host); //Set the contracts provider _contractsProvider = VSServiceProvider.Current.GetVersionedServicesFactory().CreateContractsProvider(this); }
public VisualBasicVSImports( [Import(ExportContractNames.VsTypes.CpsVSProject)] VSLangProj.VSProject vsProject, IProjectThreadingService threadingService, ActiveConfiguredProject <ConfiguredProject> activeConfiguredProject, IProjectLockService lockService, IUnconfiguredProjectVsServices unconfiguredProjectVSServices, VisualBasicNamespaceImportsList importsList) { Requires.NotNull(vsProject, nameof(vsProject)); Requires.NotNull(threadingService, nameof(threadingService)); Requires.NotNull(activeConfiguredProject, nameof(activeConfiguredProject)); Requires.NotNull(lockService, nameof(lockService)); Requires.NotNull(unconfiguredProjectVSServices, nameof(unconfiguredProjectVSServices)); Requires.NotNull(importsList, nameof(importsList)); _vsProject = vsProject; _activeConfiguredProject = activeConfiguredProject; _lockService = lockService; _threadingService = threadingService; _unconfiguredProjectVSServices = unconfiguredProjectVSServices; _importsList = importsList; AddEventSource(this); }
private static VSProject GetVsLangProjectProperties( VSLangProj.VSProject vsproject = null, IProjectThreadingService threadingService = null, ActiveConfiguredProject <ProjectProperties> projectProperties = null) { return(new VSProject(vsproject, threadingService, projectProperties)); }
public VSProjectWrapper(VSLangProj.VSProject vsproj) { _vsproj = vsproj; }
private VSProjectEventsTestImpl GetVSProjectEvents( VSLangProj.VSProject vsproject = null, UnconfiguredProject project = null) { return new VSProjectEventsTestImpl(vsproject, project); }
public VSProjectEventsTestImpl(VSLangProj.VSProject vsProject, UnconfiguredProject project) : base(vsProject, project) { }
private static VSProjectEventsTestImpl GetVSProjectEvents(VSLangProj.VSProject vsproject, UnconfiguredProject project) { return(new VSProjectEventsTestImpl(vsproject, project)); }