public void AddIceBuilderToProject(EnvDTE.Project p) { Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(p.FullName); if (MSBuildUtils.AddIceBuilderToProject(project)) { if (DTEUtil.IsCppProject(p)) { VCUtil.SetupSliceFilter(p); } else { String includeDirectories = ProjectUtil.GetProperty(p, PropertyNames.IncludeDirectories); if (String.IsNullOrEmpty(includeDirectories)) { ProjectUtil.SetProperty(p, PropertyNames.IncludeDirectories, @"$(IceHome)\slice"); } else if (includeDirectories.IndexOf(@"$(IceHome)\slice") == -1) { ProjectUtil.SetProperty(p, PropertyNames.IncludeDirectories, String.Format(@"$(IceHome)\slice;{0}", includeDirectories)); } ProjectUtil.AddAssemblyReference(p, "Ice"); } p.Save(); IVsHierarchy hier = DTEUtil.GetIVsHierarchy(p); Guid projectGUID = Guid.Empty; IVsSolution.GetGuidOfProject(hier, out projectGUID); IVsSolution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, hier, 0); project.Save(); IVsSolution4.ReloadProject(ref projectGUID); } }
public void Apply() { try { Settings.OutputDir = ConfigurationView.OutputDir; Settings.AllowIcePrefix = ConfigurationView.Ice == CheckState.Checked ? true : false; Settings.Checksum = ConfigurationView.Checksum == CheckState.Checked ? true : false; Settings.Stream = ConfigurationView.Streaming == CheckState.Checked ? true : false; Settings.Tie = ConfigurationView.Tie == CheckState.Checked ? true : false; Settings.Underscore = ConfigurationView.Underscores == CheckState.Checked ? true : false; Settings.IncludeDirectories = String.Join(";", ConfigurationView.IncludeDirectories.Values); Settings.AdditionalOptions = ConfigurationView.AdditionalOptions; List <String> referencedAssemblies = ConfigurationView.ReferencedAssemblies; String assembliesDir = ProjectUtil.GetEvaluatedProperty(Project, "IceAssembliesDir"); foreach (String assembly in ConfigurationView.Assemblies) { EnvDTE.Project p = DTEUtil.GetProject(Project as IVsHierarchy); if (ProjectUtil.HasAssemblyReference(p, assembly)) { if (!referencedAssemblies.Contains(assembly)) { ProjectUtil.RemoveAssemblyReference(p, assembly); } } else { if (referencedAssemblies.Contains(assembly)) { ProjectUtil.AddAssemblyReference(p, assembliesDir, assembly); } } } Settings.Save(); ConfigurationView.Dirty = false; } catch (Exception ex) { Package.UnexpectedExceptionWarning(ex); throw; } }
public void AddIceBuilderToProject(IVsProject p) { Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true); if (MSBuildUtils.AddIceBuilderToProject(project)) { if (DTEUtil.IsCppProject(p)) { VCUtil.SetupSliceFilter(DTEUtil.GetProject(p as IVsHierarchy)); } else { String includeDirectories = ProjectUtil.GetProperty(p, PropertyNames.IncludeDirectories); if (String.IsNullOrEmpty(includeDirectories)) { ProjectUtil.SetProperty(p, PropertyNames.IncludeDirectories, @"$(IceHome)\slice"); } else if (includeDirectories.IndexOf(@"$(IceHome)\slice") == -1) { ProjectUtil.SetProperty(p, PropertyNames.IncludeDirectories, String.Format(@"$(IceHome)\slice;{0}", includeDirectories)); } ProjectUtil.AddAssemblyReference(DTEUtil.GetProject(p as IVsHierarchy), "Ice"); } ProjectUtil.SaveProject(p); IVsHierarchy hier = p as IVsHierarchy; Guid projectGUID = Guid.Empty; IVsSolution.GetGuidOfProject(hier, out projectGUID); IVsSolution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, hier, 0); project.Save(); try { ProjectCollection.GlobalProjectCollection.UnloadProject(project); } catch (System.Exception) { //expected if the project is not in the global project collection } IVsSolution4.ReloadProject(ref projectGUID); } }