Example #1
0
        public void AddReference(IProjectNode referencedProject)
        {
            if (referencedProject.Supports(KnownCapabilities.SharedAssetsProject))
            {
                var sharedProjectReferencesHelper = hierarchyNode.Value
                                                    .GetServiceProvider()
                                                    .GetService <SVsSharedProjectReferencesHelper, IVsSharedProjectReferencesHelper>();

                sharedProjectReferencesHelper.ChangeSharedProjectReferences(
                    node.AsVsHierarchy(),
                    0,
                    null,
                    1,
                    new object[] { referencedProject.AsVsHierarchy() });

                sharedProjectReferencesHelper.ChangeSharedMSBuildFileImports(
                    node.AsVsHierarchy(),
                    new[] { referencedProject.PhysicalPath },
                    new[] { Path.ChangeExtension(referencedProject.PhysicalPath, ".projitems") },
                    "Shared"
                    );
            }
            else
            {
                var automationReferencedProject = referencedProject.AsVsHierarchyItem().GetExtenderObject() as Project;
                if (automationReferencedProject == null)
                {
                    throw new NotSupportedException(Strings.ProjectNode.AddProjectReferenceNotSupported(referencedProject.Name));
                }

                var langProject = node.AsVsLangProject();
                if (langProject == null)
                {
                    throw new NotSupportedException(Strings.ProjectNode.AddProjectReferenceNotSupported(node.Name));
                }

                langProject.References.AddProject(automationReferencedProject);

                var reference = langProject
                                .References
                                .OfType <Reference>()
                                .Where(x => x.Name == referencedProject.Name)
                                .FirstOrDefault();

                if (reference == null)
                {
                    throw new InvalidOperationException(
                              Strings.ProjectNode.AddProjectReferenceFailed(referencedProject.Name, node.Name));
                }
            }
        }
        public static void OpenNuSpecPropertyPage(this IProjectNode project)
        {
            var hierarchy = project.AsVsHierarchy();

            Guid projectDesignerEditorGuid;

            ErrorHandler.ThrowOnFailure(
                hierarchy.GetGuidProperty(
                    VSConstants.VSITEMID_ROOT,
                    (int)__VSHPROPID2.VSHPROPID_ProjectDesignerEditor,
                    out projectDesignerEditorGuid));

            var vsProject = hierarchy as IVsProject2;

            IVsWindowFrame frame;

            ErrorHandler.ThrowOnFailure(
                vsProject.ReopenItem(
                    VSConstants.VSITEMID_ROOT,
                    ref projectDesignerEditorGuid,
                    null,
                    Guid.Empty,
                    new IntPtr(-1),
                    out frame));

            object docView;

            ErrorHandler.ThrowOnFailure(
                frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out docView));

            var multiViewDocView = docView as IVsMultiViewDocumentView;

            ErrorHandler.ThrowOnFailure(
                multiViewDocView.ActivateLogicalView(new Guid(Guids.NuSpecPropertyPageGuid)));
        }
Example #3
0
        public void Pack(IProjectNode project)
        {
            var hierarchy = project.AsVsHierarchy();

            if (hierarchy != null)
            {
                var targetPackOnBuildFile = Path.Combine(
                    Path.GetDirectoryName(project.PhysicalPath), PackOnBuildFilename);

                // Write the .packonbuild empty file which is used by the targets
                // to override the PackOnBuild property and generate the .nupkg
                if (!File.Exists(targetPackOnBuildFile))
                {
                    File.WriteAllText(targetPackOnBuildFile, string.Empty);
                }

                cleanupFilesOnBuildDone.Add(targetPackOnBuildFile);

                buildManager.StartSimpleUpdateProjectConfiguration(hierarchy, null, null,
                                                                   (uint)(VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_FORCE_UPDATE | VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD), 0, 0);
            }
        }