/// <summary> /// Rather than directly creating the project, ask VS to initate the process of /// creating an aggregated project in case we are flavored. We will be called /// on the IVsAggregatableProjectFactory to do the real project creation. /// </summary> /// <param name="fileName">Project file</param> /// <param name="location">Path of the project</param> /// <param name="name">Project Name</param> /// <param name="flags">Creation flags</param> /// <param name="projectGuid">Guid of the project</param> /// <param name="project">Project that end up being created by this method</param> /// <param name="canceled">Was the project creation canceled</param> protected override void CreateProject(string fileName, string location, string name, uint flags, ref Guid projectGuid, out IntPtr project, out int canceled) { using (new DebugTimer("CreateProject")) { project = IntPtr.Zero; canceled = 0; // Get the list of GUIDs from the project/template string guidsList = this.ProjectTypeGuids(fileName); // Launch the aggregate creation process (we should be called back on our IVsAggregatableProjectFactoryCorrected implementation) IVsCreateAggregateProject aggregateProjectFactory = (IVsCreateAggregateProject)this.Site.GetService(typeof(SVsCreateAggregateProject)); int hr = aggregateProjectFactory.CreateAggregateProject(guidsList, fileName, location, name, flags, ref projectGuid, out project); if (hr == VSConstants.E_ABORT) { canceled = 1; } ErrorHandler.ThrowOnFailure(hr); this.buildProject = null; } }
/// <summary> /// Rather than directly creating the project, ask VS to initate the process of /// creating an aggregated project in case we are flavored. We will be called /// on the IVsAggregatableProjectFactory to do the real project creation. /// </summary> /// <param name="fileName">Project file</param> /// <param name="location">Path of the project</param> /// <param name="name">Project Name</param> /// <param name="flags">Creation flags</param> /// <param name="projectGuid">Guid of the project</param> /// <param name="project">Project that end up being created by this method</param> /// <param name="canceled">Was the project creation canceled</param> protected override void CreateProject(string fileName, string location, string name, uint flags, ref Guid projectGuid, out IntPtr project, out int canceled) { project = IntPtr.Zero; canceled = 0; if ((flags & ((uint)__VSCREATEPROJFLAGS2.CPF_DEFERREDSAVE)) != 0) { throw new NotSupportedException(SR.GetString(SR.NoZeroImpactProjects)); } #if FX_ATLEAST_45 if ((flags & ((uint)__VSCREATEPROJFLAGS.CPF_OPENFILE)) != 0) { if (new ProjectInspector(fileName).IsPoisoned(Site)) { // error out int ehr = unchecked ((int)0x80042003); // VS_E_INCOMPATIBLEPROJECT ErrorHandler.ThrowOnFailure(ehr); } } #endif // Get the list of GUIDs from the project/template string guidsList = this.ProjectTypeGuids(fileName); // Launch the aggregate creation process (we should be called back on our IVsAggregatableProjectFactoryCorrected implementation) IVsCreateAggregateProject aggregateProjectFactory = (IVsCreateAggregateProject)this.Site.GetService(typeof(SVsCreateAggregateProject)); int hr = aggregateProjectFactory.CreateAggregateProject(guidsList, fileName, location, name, flags, ref projectGuid, out project); if (hr == VSConstants.E_ABORT) { canceled = 1; } ErrorHandler.ThrowOnFailure(hr); this.buildProject = null; }
/// <summary> /// Rather than directly creating the project, ask VS to initate the process of /// creating an aggregated project in case we are flavored. We will be called /// on the IVsAggregatableProjectFactory to do the real project creation. /// </summary> /// <param name="fileName">Project file</param> /// <param name="location">Path of the project</param> /// <param name="name">Project Name</param> /// <param name="flags">Creation flags</param> /// <param name="projectGuid">Guid of the project</param> /// <param name="project">Project that end up being created by this method</param> /// <param name="canceled">Was the project creation canceled</param> protected override void CreateProject(string fileName, string location, string name, uint flags, ref Guid projectGuid, out IntPtr project, out int canceled) { project = IntPtr.Zero; canceled = 0; if ((flags & ((uint)__VSCREATEPROJFLAGS2.CPF_DEFERREDSAVE)) != 0) { throw new NotSupportedException(SR.GetString(SR.NoZeroImpactProjects)); } if ((flags & ((uint)__VSCREATEPROJFLAGS.CPF_OPENFILE)) != 0) { if (new ProjectInspector(fileName).IsPoisoned(Site)) { // error out int ehr = unchecked ((int)0x80042003); // VS_E_INCOMPATIBLEPROJECT ErrorHandler.ThrowOnFailure(ehr); } } // Solution properties IVsSolution solution = this.Site.GetService(typeof(SVsSolution)) as IVsSolution; Debug.Assert(solution != null, "Could not retrieve the solution service from the global service provider"); // We do not want to throw. If we cannot set the solution related constants we set them to empty string. string solutionDirectory, solutionPath, userOptionsFile; solution.GetSolutionInfo(out solutionDirectory, out solutionPath, out userOptionsFile); if (solutionDirectory == null) { solutionDirectory = String.Empty; } if (solutionPath == null) { solutionPath = String.Empty; } string solutionFileName = (solutionPath.Length == 0) ? String.Empty : Path.GetFileName(solutionPath); string solutionName = (solutionPath.Length == 0) ? String.Empty : Path.GetFileNameWithoutExtension(solutionPath); var solutionExtension = Path.GetExtension(solutionPath); // DevEnvDir property IVsShell shell = this.Site.GetService(typeof(SVsShell)) as IVsShell; Debug.Assert(shell != null, "Could not retrieve the IVsShell service from the global service provider"); object installDirAsObject; // We do not want to throw. If we cannot set the solution related constants we set them to empty string. shell.GetProperty((int)__VSSPROPID.VSSPROPID_InstallDirectory, out installDirAsObject); string installDir = ((string)installDirAsObject); if (String.IsNullOrEmpty(installDir)) { installDir = String.Empty; } else { // Ensure that we have trailing backslash as this is done for the langproj macros too. if (installDir[installDir.Length - 1] != Path.DirectorySeparatorChar) { installDir += Path.DirectorySeparatorChar; } } // Get the list of GUIDs from the project/template string guidsList = this.ProjectTypeGuids(fileName); // Launch the aggregate creation process (we should be called back on our IVsAggregatableProjectFactoryCorrected implementation) IVsCreateAggregateProject aggregateProjectFactory = (IVsCreateAggregateProject)this.Site.GetService(typeof(SVsCreateAggregateProject)); int hr = aggregateProjectFactory.CreateAggregateProject(guidsList, fileName, location, name, flags, ref projectGuid, out project); if (hr == VSConstants.E_ABORT) { canceled = 1; } ErrorHandler.ThrowOnFailure(hr); this.buildProject = null; }