Пример #1
0
        protected override void Execute()
        {
            if (ActiveProject == null)
            {
                return;
            }

            var project = ActiveProject.As <EnvDTE.Project>();
            var vsBuildPropertyStorage = ActiveProject.AsVsHierarchy() as IVsBuildPropertyStorage;

            if (vsBuildPropertyStorage != null)
            {
                var storage   = new BuildPropertyStorage(vsBuildPropertyStorage);
                var viewModel = new PackageMetadataViewModel(storage);

                if (!packageInstallerServices.IsBuildPackagingNuGetInstalled(project))
                {
                    // Provide default values for required fields/properties
                    viewModel.PackageId      = project.Name;
                    viewModel.PackageVersion = "1.0.0";
                    viewModel.Description    = project.Name;
                    viewModel.Authors        = "MyCompany";
                }

                var view = new PackageMetadataView()
                {
                    DataContext = viewModel
                };
                if (dialogService.ShowDialog(view) == true)
                {
                    storage.CommitChanges();

                    if (!packageInstallerServices.IsBuildPackagingNuGetInstalled(project))
                    {
                        packageInstaller.InstallBuildPackagingNuget(project);
                    }

                    buildService.Pack(ActiveProject);
                }
            }
        }