public virtual int get_ProjectCfg(out IVsProjectCfg p) { CCITracing.TraceCall(); p = config; return VSConstants.S_OK; }
public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { Debug.Assert(projectCfgCanonicalName != null, "Cannot open project configuration for a null configuration"); projectCfg = null; // Be robust in release if (projectCfgCanonicalName == null) { return NativeMethods.E_INVALIDARG; } Debug.Assert(this.Project != null && this.Project.MSBuildProject != null); string[] configs = this.Project.MSBuildProject.GetConditionedPropertyValues("Configuration"); foreach (string config in configs) { if (String.Compare(config, projectCfgCanonicalName, true, CultureInfo.CurrentUICulture) == 0) { projectCfg = new ProjectConfig(this.Project, config); return NativeMethods.S_OK; } } return NativeMethods.E_INVALIDARG; }
/// <summary> /// Gets the activate project configuration. /// </summary> internal static IVsProjectCfg GetActiveProjectCfg(this IServiceProvider serviceProvider, IVsHierarchy project) { var buildManager = (IVsSolutionBuildManager) serviceProvider.GetService(typeof (SVsSolutionBuildManager)); if (buildManager == null) throw new InvalidOperationException("No solution build manager found"); var ppIVsProjectCfg = new IVsProjectCfg[1]; buildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, project, ppIVsProjectCfg); return ppIVsProjectCfg[0]; }
public int OpenOutput(string szOutputCanonicalName, out IVsOutput ppIVsOutput) { IVsProjectCfg projCfg = _innerCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.OpenOutput(szOutputCanonicalName, out ppIVsOutput)); } ppIVsOutput = null; return(VSConstants.E_NOTIMPL); }
public int get_ProjectCfgProvider(out IVsProjectCfgProvider ppIVsProjectCfgProvider) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_ProjectCfgProvider(out ppIVsProjectCfgProvider)); } ppIVsProjectCfgProvider = null; return(VSConstants.E_NOTIMPL); }
public int get_RootURL(out string pbstrRootURL) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_RootURL(out pbstrRootURL)); } pbstrRootURL = null; return(VSConstants.E_NOTIMPL); }
public int get_BuildableProjectCfg(out IVsBuildableProjectCfg ppIVsBuildableProjectCfg) { IVsProjectCfg projCfg = _innerCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_BuildableProjectCfg(out ppIVsBuildableProjectCfg)); } ppIVsBuildableProjectCfg = null; return(VSConstants.E_NOTIMPL); }
public int get_TargetCodePage(out uint puiTargetCodePage) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_TargetCodePage(out puiTargetCodePage)); } puiTargetCodePage = 0; return(VSConstants.E_NOTIMPL); }
public int get_Platform(out Guid pguidPlatform) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_Platform(out pguidPlatform)); } pguidPlatform = Guid.Empty; return(VSConstants.E_NOTIMPL); }
public int EnumOutputs(out IVsEnumOutputs ppIVsEnumOutputs) { IVsProjectCfg projCfg = _innerCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.EnumOutputs(out ppIVsEnumOutputs)); } ppIVsEnumOutputs = null; return(VSConstants.E_NOTIMPL); }
public int get_IsSpecifyingOutputSupported(out int pfIsSpecifyingOutputSupported) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_IsSpecifyingOutputSupported(out pfIsSpecifyingOutputSupported)); } pfIsSpecifyingOutputSupported = 0; return(VSConstants.E_NOTIMPL); }
public int get_IsPackaged(out int pfIsPackaged) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_IsPackaged(out pfIsPackaged)); } pfIsPackaged = 0; return(VSConstants.E_NOTIMPL); }
public int get_CanonicalName(out string pbstrCanonicalName) { IVsProjectCfg projCfg = _webCfg as IVsProjectCfg; if (projCfg != null) { return(projCfg.get_CanonicalName(out pbstrCanonicalName)); } pbstrCanonicalName = null; return(VSConstants.E_NOTIMPL); }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public override int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (String.IsNullOrEmpty(projectCfgCanonicalName)) { throw new ArgumentNullException("projectCfgCanonicalName"); } ConfigCanonicalName config = new ConfigCanonicalName(projectCfgCanonicalName); projectCfg = this.GetProjectConfiguration(config); return(VSConstants.S_OK); }
/// <summary> /// Gets the build output group. /// </summary> internal static IVsOutputGroup2 GetBuildOutputGroup(this IVsProjectCfg projectCfg) { var projectCfg2 = projectCfg as IVsProjectCfg2; if (projectCfg2 == null) { throw new InvalidOperationException("No project config2 found"); } IVsOutputGroup outputGroup; ErrorHandler.ThrowOnFailure(projectCfg2.OpenOutputGroup("Built", out outputGroup)); return(outputGroup as IVsOutputGroup2); }
/// <summary> /// Gets the activate project configuration. /// </summary> internal static IVsProjectCfg GetActiveProjectCfg(this IServiceProvider serviceProvider, IVsHierarchy project) { var buildManager = (IVsSolutionBuildManager)serviceProvider.GetService(typeof(SVsSolutionBuildManager)); if (buildManager == null) { throw new InvalidOperationException("No solution build manager found"); } var ppIVsProjectCfg = new IVsProjectCfg[1]; buildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, project, ppIVsProjectCfg); return(ppIVsProjectCfg[0]); }
/// <summary> /// When building a wixproj in VS, the configuration of referenced projects cannot be determined /// by MSBuild or from within an MSBuild task. So we'll get them from the VS project system here. /// </summary> /// <param name="project">The project where the properties are being defined; also the project /// whose references are being examined.</param> internal static void DefineProjectReferenceConfigurations(WixProjectNode project) { StringBuilder configList = new StringBuilder(); IVsSolutionBuildManager solutionBuildManager = WixHelperMethods.GetService <IVsSolutionBuildManager, SVsSolutionBuildManager>(project.Site); List <WixProjectReferenceNode> referenceNodes = new List <WixProjectReferenceNode>(); project.FindNodesOfType(referenceNodes); foreach (WixProjectReferenceNode referenceNode in referenceNodes) { IVsHierarchy hierarchy = VsShellUtilities.GetHierarchy(referenceNode.ProjectMgr.Site, referenceNode.ReferencedProjectGuid); string configuration = null; IVsProjectCfg2 projectCfg2 = null; IVsProjectCfg[] projectCfgArray = new IVsProjectCfg[1]; int hr = solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, projectCfgArray); ErrorHandler.ThrowOnFailure(hr); projectCfg2 = projectCfgArray[0] as IVsProjectCfg2; if (projectCfg2 != null) { hr = projectCfg2.get_DisplayName(out configuration); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } } if (configuration != null) { if (configList.Length > 0) { configList.Append(';'); } configList.Append(referenceNode.ReferencedProjectName); configList.Append('='); configList.Append(configuration); } } if (configList.Length > 0) { project.BuildProject.SetGlobalProperty("VSProjectConfigurations", configList.ToString()); } }
private string GetBaseCfgCanonicalName() { IVsProjectCfg projectCfg = _baseCfg as IVsProjectCfg; if (projectCfg == null) { return(null); } string baseCfgCanonicalName; projectCfg.get_CanonicalName(out baseCfgCanonicalName); return(baseCfgCanonicalName); }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (projectCfgCanonicalName == null) { throw new ArgumentNullException("projectCfgCanonicalName"); } projectCfg = null; // Be robust in release if (projectCfgCanonicalName == null) { return(VSConstants.E_INVALIDARG); } Debug.Assert(this.project != null && this.project.BuildProject != null); string[] configs = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); string[] platforms = GetPropertiesConditionedOn(ProjectFileConstants.Platform); var configCanonicalName = new ConfigCanonicalName(projectCfgCanonicalName); foreach (string config in configs) { foreach (string platform in platforms) { if (configCanonicalName == new ConfigCanonicalName(config, platform)) { projectCfg = this.GetProjectConfiguration(configCanonicalName); if (projectCfg != null) { return(VSConstants.S_OK); } else { return(VSConstants.E_FAIL); } } } } return(VSConstants.E_INVALIDARG); }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public override int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (String.IsNullOrEmpty(projectCfgCanonicalName)) { throw new ArgumentNullException("projectCfgCanonicalName"); } string configName; string platformName; if (!ProjectConfig.TrySplitConfigurationCanonicalName(projectCfgCanonicalName, out configName, out platformName)) { projectCfg = null; return(VSConstants.E_INVALIDARG); } projectCfg = this.GetProjectConfiguration(configName, platformName); return(VSConstants.S_OK); }
public SampSharpFlavorConfig(SampSharpProjectFlavor project, IVsCfg baseProjectConfig, IVsProjectFlavorCfg innerProjectFlavorConfig) { _project = project; _baseProjectConfig = baseProjectConfig; _innerProjectFlavorConfig = innerProjectFlavorConfig; _projectConfig = (IVsProjectCfg2) baseProjectConfig; string configurationName; _projectConfig.get_CanonicalName(out configurationName); Configs.Add(baseProjectConfig, this); var debugGuid = typeof(IVsDebuggableProjectCfg).GUID; IntPtr baseDebugConfigurationPtr; innerProjectFlavorConfig.get_CfgType(ref debugGuid, out baseDebugConfigurationPtr); _baseDebugConfiguration = (IVsDebuggableProjectCfg) Marshal.GetObjectForIUnknown(baseDebugConfigurationPtr); Instance = this; }
public MonoProgramFlavorCfg(MonoProgramProjectFlavor project, IVsCfg baseProjectCfg, IVsProjectFlavorCfg innerProjectFlavorCfg) { this.project = project; this.baseProjectCfg = baseProjectCfg; this.innerProjectFlavorCfg = innerProjectFlavorCfg; projectConfig = (IVsProjectCfg2)baseProjectCfg; string configurationName; projectConfig.get_CanonicalName(out configurationName); cfgs.Add(baseProjectCfg, this); cfgsByDteProject[Tuple.Create(GetDTEProject(project), configurationName)] = this; var debugGuid = typeof(IVsDebuggableProjectCfg).GUID; IntPtr baseDebugConfigurationPtr; innerProjectFlavorCfg.get_CfgType(ref debugGuid, out baseDebugConfigurationPtr); baseDebugConfiguration = (IVsDebuggableProjectCfg)Marshal.GetObjectForIUnknown(baseDebugConfigurationPtr); }
/// <summary> /// Retrives the configuration and the platform using the IVsSolutionBuildManager2 interface. /// </summary> /// <param name="serviceProvider">A service provider.</param> /// <param name="hierarchy">The hierrachy whose configuration is requested.</param> /// <param name="configuration">The name of the active configuration.</param> /// <param name="platform">The name of the platform.</param> /// <returns>true if successfull.</returns> internal static bool TryGetActiveConfigurationAndPlatform(System.IServiceProvider serviceProvider, IVsHierarchy hierarchy, out string configuration, out string platform) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (hierarchy == null) { throw new ArgumentNullException("hierarchy"); } configuration = String.Empty; platform = String.Empty; IVsSolutionBuildManager2 solutionBuildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; if (solutionBuildManager == null) { return(false); } IVsProjectCfg[] activeConfigs = new IVsProjectCfg[1]; var res = solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, activeConfigs); if (ErrorHandler.Failed(res)) { return(false); } IVsProjectCfg activeCfg = activeConfigs[0]; // Can it be that the activeCfg is null? System.Diagnostics.Debug.Assert(activeCfg != null, "Cannot find the active configuration"); string canonicalName; ErrorHandler.ThrowOnFailure(activeCfg.get_CanonicalName(out canonicalName)); return(ProjectConfig.TrySplitConfigurationCanonicalName(canonicalName, out configuration, out platform)); }
public static async Task <string> ExpandProjectPropertiesAsync(string path, IVsHierarchy hierarchy, IServiceProvider provider) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (hierarchy is IVsBuildPropertyStorage propertyStorage) { Lazy <string> name = new Lazy <string>(delegate { ThreadHelper.ThrowIfNotOnUIThread(); if (provider.GetService <IVsSolutionBuildManager>() is IVsSolutionBuildManager manager) { IVsProjectCfg[] cfgArray = new IVsProjectCfg[1]; if (manager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, cfgArray) != 0 && cfgArray[0].get_DisplayName(out string value) != 0) { return(value); } } return(string.Empty); });
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (projectCfgCanonicalName == null) { throw new ArgumentNullException("projectCfgCanonicalName"); } projectCfg = null; // Be robust in release if (projectCfgCanonicalName == null) { return(VSConstants.E_INVALIDARG); } Debug.Assert(this.project != null && this.project.BuildProject != null); string[] configs = this.project.BuildProject.GetConditionedPropertyValues(ProjectFileConstants.Configuration); foreach (string config in configs) { if (String.Compare(config, projectCfgCanonicalName, StringComparison.OrdinalIgnoreCase) == 0) { projectCfg = this.GetProjectConfiguration(config); if (projectCfg != null) { return(VSConstants.S_OK); } else { return(VSConstants.E_FAIL); } } } return(VSConstants.E_INVALIDARG); }
/// <summary> /// Gets the variables and directories for the specified project. Variables will be in /// the form <c>ProjectName.VariableName</c>. /// </summary> /// <param name="variables">The <see cref="NameValueCollection"/> to add the variables to.</param> /// <param name="hierarchy">The <see cref="IVsHierarchy"/> (project) from which to retrieve the variables.</param> private void GetTargetVariables(NameValueCollection variables, IVsHierarchy hierarchy, string projectPrefix) { try { int hr = NativeMethods.S_OK; // Now we need to get a IVsProjectCfg2 object to get the TargetX variables. We do this // by querying the environment for the active configuration of the specified project. IVsSolutionBuildManager solutionBuildManager = Package.Instance.GetService(typeof(IVsSolutionBuildManager)) as IVsSolutionBuildManager; if (solutionBuildManager == null) { Tracer.WriteLine(classType, "GetTargetVariables", Tracer.Level.Warning, "Cannot get an instance of IVsSolutionBuildManager from the environment. Skipping the project's TargetX variables."); return; } IVsProjectCfg[] projectCfgArray = new IVsProjectCfg[1]; hr = solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, projectCfgArray); if (NativeMethods.Failed(hr)) { Tracer.WriteLineWarning(classType, "GetTargetVariables", "One of the projects in the solution does not support project configurations. Skipping the project's TargetX variables."); return; } IVsProjectCfg2 projectCfg2 = projectCfgArray[0] as IVsProjectCfg2; if (projectCfg2 == null) { Tracer.WriteLine(classType, "GetTargetVariables", Tracer.Level.Warning, "The IVsSolutionBuildManager.FindActiveProjectCfg returned a null object or an object that doesn't support IVsProjectCfg2. Skipping the project's TargetX variables."); return; } // Get the ConfigurationName and add it to the variables. string configurationName; NativeMethods.ThrowOnFailure(projectCfg2.get_DisplayName(out configurationName)); variables.Add(projectPrefix + "ConfigurationName", configurationName); // We need to get the Built output group from the list of project output groups. IVsOutputGroup outputGroup; NativeMethods.ThrowOnFailure(projectCfg2.OpenOutputGroup("Built", out outputGroup)); if (outputGroup == null) { Tracer.WriteLine(classType, "GetTargetVariables", Tracer.Level.Warning, "The project configuration '{0}' does not support the 'Built' output group. Skipping the TargetX variables.", configurationName); return; } // Get the key output canonical name from the Built output group. string keyOutputCanonicalName; NativeMethods.ThrowOnFailure(outputGroup.get_KeyOutput(out keyOutputCanonicalName)); // Search through the outputs until we find the key output. We have to call get_Outputs // twice: once to get the number of outputs (we do this by passing in 0 as the number // requested), and then once to get the actual outputs. uint numberRequested = 0; IVsOutput2[] outputArray = new IVsOutput2[numberRequested]; uint[] numberFetchedArray = new uint[1]; NativeMethods.ThrowOnFailure(outputGroup.get_Outputs(numberRequested, outputArray, numberFetchedArray)); // We should have the number of elements in the output array now, so get them. numberRequested = numberFetchedArray[0]; outputArray = new IVsOutput2[numberRequested]; NativeMethods.ThrowOnFailure(outputGroup.get_Outputs(numberRequested, outputArray, numberFetchedArray)); IVsOutput2 keyOutput = null; for (int i = 0; i < numberFetchedArray[0]; i++) { if (outputArray.Length <= i) { break; } IVsOutput2 output = outputArray[i]; string outputCanonicalName; NativeMethods.ThrowOnFailure(output.get_CanonicalName(out outputCanonicalName)); if (outputCanonicalName == keyOutputCanonicalName) { keyOutput = output; break; } } // Check to make sure that we found the key output. if (keyOutput == null) { Tracer.WriteLine(classType, "GetTargetVariables", Tracer.Level.Warning, "We identified the key output from configuration '{0}' as '{1}', but when we iterated through the outputs we couldn't find the key output. Skipping the TargetX variables.", configurationName, keyOutputCanonicalName); return; } // Now that we have the key output, we can finally create the TargetX variables from // the key output's deploy source URL. string deploySourceUrl; NativeMethods.ThrowOnFailure(keyOutput.get_DeploySourceURL(out deploySourceUrl)); // By convention, the deploy source URL starts with file:/// for file-based outputs. // Strip it off if it's there. if (deploySourceUrl.StartsWith("file:///")) { deploySourceUrl = deploySourceUrl.Substring("file:///".Length); } // Parse the TargetX variables from the deploy source URL. string targetPath = deploySourceUrl; string targetFileName = Path.GetFileName(targetPath); string targetDosFileName = this.EncodeDosFileName(targetFileName); string targetName = Path.GetFileNameWithoutExtension(targetFileName); string targetExt = PackageUtility.EnsureLeadingChar(Path.GetExtension(targetPath), '.'); string targetDir = PackageUtility.StripTrailingChar(Path.GetDirectoryName(targetPath), Path.DirectorySeparatorChar); // Add the TargetX variables to the collection. variables.Add(projectPrefix + "TargetDir", targetDir); variables.Add(projectPrefix + "TargetDosFileName", targetDosFileName); variables.Add(projectPrefix + "TargetExt", targetExt); variables.Add(projectPrefix + "TargetFileName", targetFileName); variables.Add(projectPrefix + "TargetName", targetName); variables.Add(projectPrefix + "TargetPath", targetPath); } catch (Exception e) { if (ErrorUtility.IsExceptionUnrecoverable(e)) { throw; } Tracer.WriteLineWarning(classType, "GetTargetVariables", "The project does not correctly implement all of its required IVsProjectCfg2 interfaces. Skipping the TargetX variables. Exception: {0}", e); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////// // uses the solution build manager interface to get the active config object // ////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetActiveConfiguration"]/*' /> public XmlElement GetActiveConfiguration(){ IVsSolutionBuildManager pSolutionBuildManger = this.Site.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; if (pSolutionBuildManger == null) return null; IVsProjectCfg[] pProjectCfg = new IVsProjectCfg[1]; HResult result = (HResult) pSolutionBuildManger.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, this, pProjectCfg); if (result == HResult.S_OK){ ProjectConfig current = pProjectCfg[0] as ProjectConfig; if (current != null) return current.Node; } return (XmlElement)this.projFile.SelectSingleNode("*/*/Build/Settings/Config"); }
/// <summary> /// The find active project cfg. /// </summary> /// <param name="pvReserved1"> /// The pv reserved 1. /// </param> /// <param name="pvReserved2"> /// The pv reserved 2. /// </param> /// <param name="pIVsHierarchy_RequestedProject"> /// The p i vs hierarchy_ requested project. /// </param> /// <param name="ppIVsProjectCfg_Active"> /// The pp i vs project cfg_ active. /// </param> /// <returns> /// The find active project cfg. /// </returns> /// <exception cref="NotImplementedException"> /// </exception> public int FindActiveProjectCfg(IntPtr pvReserved1, IntPtr pvReserved2, IVsHierarchy pIVsHierarchy_RequestedProject, IVsProjectCfg[] ppIVsProjectCfg_Active) { throw new NotImplementedException(); }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (projectCfgCanonicalName == null) throw new ArgumentNullException("projectCfgCanonicalName"); if (string.IsNullOrEmpty(projectCfgCanonicalName)) throw new ArgumentException("projectCfgCanonicalName cannot be null or empty"); projectCfg = null; // Be robust in release if(projectCfgCanonicalName == null) { return VSConstants.E_INVALIDARG; } Debug.Assert(this._project != null && this._project.BuildProject != null); string[] configs = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); string[] platforms = GetPlatformsFromProject(); foreach (string config in configs) { foreach (string platform in platforms) { if (string.Equals(string.Format("{0}|{1}", config, platform), projectCfgCanonicalName, StringComparison.OrdinalIgnoreCase)) { projectCfg = this.GetProjectConfiguration(config, platform); if (projectCfg != null) return VSConstants.S_OK; else return VSConstants.E_FAIL; } } } return VSConstants.E_INVALIDARG; }
/// <include file='doc\Project.uex' path='docs/doc[@for="ImageNames.OpenProjectCfg"]/*' /> public virtual int OpenProjectCfg(string name, out IVsProjectCfg cfg){ cfg = null; foreach (XmlElement e in this.projFile.SelectNodes("//Build/Settings/Config")){ if (name == e.GetAttribute("Name")){ cfg = new ProjectConfig(this, e); break; } } return 0; }
public virtual int get_ProjectCfg(out IVsProjectCfg p) { p = config; return VSConstants.S_OK; }
int IVsProjectCfgProvider.OpenProjectCfg(string szProjectCfgCanonicalName, out IVsProjectCfg ppIVsProjectCfg) { // TODO: Add ConfigurationProvider.OpenProjectCfg implementation ppIVsProjectCfg = null; return 0; }
public virtual void get_ProjectCfg(out IVsProjectCfg p) { CCITracing.TraceCall(); p = config; }
int IVsBuildableProjectCfg.get_ProjectCfg(out IVsProjectCfg ppIVsProjectCfg) { ppIVsProjectCfg = this.ProjectConfiguration; return NativeMethods.S_OK; }
/// <include file='doc\ProjectConfig.uex' path='docs/doc[@for="BuildableProjectConfig.get_ProjectCfg"]/*' /> public virtual int get_ProjectCfg(out IVsProjectCfg p) { CCITracing.TraceCall(); p = config; return NativeMethods.S_OK; }
int IVsBuildableProjectCfg.get_ProjectCfg(out IVsProjectCfg ppIVsProjectCfg) { PrintCalled(); ppIVsProjectCfg = null; return(m_innerCfg?.get_ProjectCfg(out ppIVsProjectCfg) ?? VSConstants.S_OK); }
/// <include file='doc\ProjectConfig.uex' path='docs/doc[@for="BuildableProjectConfig.get_ProjectCfg"]/*' /> public virtual int get_ProjectCfg(out IVsProjectCfg p) { p = config; return(0); }
/// <include file='doc\Project.uex' path='docs/doc[@for="ImageNames.OpenProjectCfg"]/*' /> public virtual int OpenProjectCfg(string name, out IVsProjectCfg cfg) { cfg = null; string[] configurations = this.projFile.GetConditionedPropertyValues("Configuration"); foreach(string config in configurations) { if (String.Compare(name, config, true, CultureInfo.InvariantCulture) == 0) { cfg = new ProjectConfig(this, config); break; } } return cfg == null ? NativeMethods.E_INVALIDARG : NativeMethods.S_OK; }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public override int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (String.IsNullOrEmpty(projectCfgCanonicalName)) { throw new ArgumentNullException("projectCfgCanonicalName"); } ConfigCanonicalName config = new ConfigCanonicalName(projectCfgCanonicalName); projectCfg = this.GetProjectConfiguration(config); return VSConstants.S_OK; }
public virtual int get_ProjectCfg(out IVsProjectCfg p) { p = config; return(VSConstants.S_OK); }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if(projectCfgCanonicalName == null) { throw new ArgumentNullException("projectCfgCanonicalName"); } projectCfg = null; // Be robust in release if(projectCfgCanonicalName == null) { return VSConstants.E_INVALIDARG; } Debug.Assert(this.project != null && this.project.BuildProject != null); string[] configs = this.project.BuildProject.GetConditionedPropertyValues(ProjectFileConstants.Configuration); foreach(string config in configs) { if(String.Compare(config, projectCfgCanonicalName, StringComparison.OrdinalIgnoreCase) == 0) { projectCfg = this.GetProjectConfiguration(config); if(projectCfg != null) { return VSConstants.S_OK; } else { return VSConstants.E_FAIL; } } } return VSConstants.E_INVALIDARG; }
/// <summary> /// When building a project in VS, the configuration of referenced projects cannot be determined /// by MSBuild or from within an MSBuild task. So we'll get them from the VS project system here. /// </summary> /// <param name="project">The project where the properties are being defined; also the project /// whose references are being examined.</param> internal static void DefineProjectReferenceConfigurations(XProjectNode project) { StringBuilder configList = new StringBuilder(); IVsSolutionBuildManager solutionBuildManager = XHelperMethods.GetService <IVsSolutionBuildManager, SVsSolutionBuildManager>(project.Site); List <ProjectReferenceNode> referenceNodes = new List <ProjectReferenceNode>(); project.FindNodesOfType(referenceNodes); foreach (ProjectReferenceNode referenceNode in referenceNodes) { try { IVsHierarchy hierarchy = VsShellUtilities.GetHierarchy(referenceNode.ProjectMgr.Site, referenceNode.ReferencedProjectGuid); string configuration = null; IVsProjectCfg2 projectCfg2 = null; IVsProjectCfg[] projectCfgArray = new IVsProjectCfg[1]; ThreadHelper.ThrowIfNotOnUIThread(); // this can fail for some reason... this code was copied from Wix and probably isn't stable yet. // this routine is called from InvokeMSBuild and we don't want that to fix because of // some bug here, so this code is surrounded by try/catch until we figure this out int hr = solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, projectCfgArray); ErrorHandler.ThrowOnFailure(hr); projectCfg2 = projectCfgArray[0] as IVsProjectCfg2; if (projectCfg2 != null) { hr = projectCfg2.get_DisplayName(out configuration); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } } if (configuration != null) { if (configList.Length > 0) { configList.Append(';'); } configList.Append(referenceNode.ReferencedProjectName); configList.Append('='); configList.Append(configuration); } } catch (Exception) { ; } } if (configList.Length > 0) { project.BuildProject.SetGlobalProperty("VSProjectConfigurations", configList.ToString()); } }
public int get_ProjectCfg(out IVsProjectCfg ppIVsProjectCfg) { ppIVsProjectCfg = this; return(VSConstants.S_OK); }
private void TellMSBuildCurrentSolutionConfiguration() { IVsSolutionBuildManager buildMgr = this.Site.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; IVsProjectCfg[] cfgs = new IVsProjectCfg[] { null }; buildMgr.FindActiveProjectCfg(System.IntPtr.Zero, System.IntPtr.Zero, this, cfgs); if (cfgs[0] != null) { string cfgName = ""; cfgs[0].get_CanonicalName(out cfgName); // cfgName conventionally has form "Configuration|Platform" var canonicalCfgName = new ConfigCanonicalName(cfgName); if (String.IsNullOrEmpty(canonicalCfgName.Platform)) { // cfgName is not conventional, just do something reasonable MSBuildProject.SetGlobalProperty(this.buildProject, ProjectFileConstants.Configuration, canonicalCfgName.ConfigName); } else { MSBuildProject.SetGlobalProperty(this.buildProject, ProjectFileConstants.Configuration, canonicalCfgName.ConfigName); MSBuildProject.SetGlobalProperty(this.buildProject, ProjectFileConstants.Platform, canonicalCfgName.MSBuildPlatform); } this.UpdateMSBuildState(); } }
int IVsBuildableProjectCfg.get_ProjectCfg(out IVsProjectCfg ppIVsProjectCfg) { ppIVsProjectCfg = this.ProjectConfiguration; return(NativeMethods.S_OK); }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public override int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (String.IsNullOrEmpty(projectCfgCanonicalName)) { throw new ArgumentNullException("projectCfgCanonicalName"); } string configName; string platformName; if (!ProjectConfig.TrySplitConfigurationCanonicalName(projectCfgCanonicalName, out configName, out platformName)) { projectCfg = null; return VSConstants.E_INVALIDARG; } projectCfg = this.GetProjectConfiguration(configName, platformName); return VSConstants.S_OK; }
/// <summary> /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. /// </summary> /// <param name="projectCfgCanonicalName">The canonical name of the configuration to access.</param> /// <param name="projectCfg">The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) { if (projectCfgCanonicalName == null) { throw new ArgumentNullException("projectCfgCanonicalName"); } projectCfg = null; // Be robust in release if (projectCfgCanonicalName == null) { return VSConstants.E_INVALIDARG; } Debug.Assert(this.project != null && this.project.BuildProject != null); string[] configs = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); string[] platforms = GetPropertiesConditionedOn(ProjectFileConstants.Platform); var configCanonicalName = new ConfigCanonicalName(projectCfgCanonicalName); foreach (string config in configs) { foreach (string platform in platforms) { if (configCanonicalName == new ConfigCanonicalName(config, platform)) { projectCfg = this.GetProjectConfiguration(configCanonicalName); if (projectCfg != null) { return VSConstants.S_OK; } else { return VSConstants.E_FAIL; } } } } return VSConstants.E_INVALIDARG; }