示例#1
0
 public DeployWizard(ManifestMetadata metadata, ProjectAssemblyInfo assemblyInfo, PackageProjectProperties ppp) : this()
 {
     _metadata          = metadata;
     _assemblyInfo      = assemblyInfo;
     _ppp               = ppp;
     _packageOldVersion = _metadata.Version;
 }
示例#2
0
        public NuGetDeployForm()
        {
            InitializeComponent();

            BindTextBoxEvents();

            _project    = Host.Instance.Dte2.GetActiveProejct();
            _dir        = _project.GetDirectory();
            _releaseDir = Path.Combine(_dir, "bin", "Release");
            //_outputDir = Path.Combine(_dir, "bin", "NuGet");
            //if (!Directory.Exists(_outputDir))
            //    Directory.CreateDirectory(_outputDir);
            _nuspecFile = Path.Combine(_dir, NuGetDomain.NuSpecFileName);
            if (!File.Exists(_nuspecFile))
            {
                MessageBox.Show($"nuspec file {_nuspecFile} not found.");
                Close();
                return;
            }

            _assemblyInfo = _project.GetProjectAssemblyInfo();
            _xmlDoc       = new XmlDocument();
            _xmlDoc.Load(_nuspecFile);
            var xml = _xmlDoc.InnerXml;

            _package       = XmlSerializerHelper.LoadObjectFromXmlString <Package>(xml);
            _nuGetConfig   = ConfigHelper.ReadNuGetConfig();
            _projectConfig = _project.ReadNuPackConfig();
            SetBoxes();
            MergePackagesConfig();
            BindDependencies();
        }
示例#3
0
        public NuGetPublishForm()
        {
            InitializeComponent();

            _project      = Host.Instance.Dte2.GetActiveProejct();
            _dir          = _project.GetDirectory();
            _assemblyInfo = _project.GetProjectAssemblyInfo();
        }
示例#4
0
文件: UnitTest1.cs 项目: zeje/nupack
        public void TestProjectAssemblyInfoUtil()
        {
            var file =
                @"X:\workspace\intime\WMS\08_Code2013\00_Infrastructure\Intime.Framework\Intime.Framework.Caching\Intime.Framework.Caching\Properties\AssemblyInfo.cs";

            using (var sr = new StreamReader(file, Encoding.Default))
            {
                var    assemblyInfo = sr.ReadToEnd();
                string fileVersion  =
                    Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyFileVersion\(""(?<content>.+)""\)").Groups["content"].Value;
                string version     = Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyVersion\(""(?<content>.+)""\)").Groups["content"].Value;
                string productName =
                    Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyProduct\(""(?<content>.+)""\)").Groups["content"].Value;
                string companyName =
                    Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyCompany\(""(?<content>.+)""\)").Groups["content"].Value;
                string title =
                    Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyTitle\(""(?<content>.+)""\)").Groups["content"].Value;
                string description =
                    Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyDescription\(""(?<content>.+)""\)").Groups["content"].Value;
                string copyright =
                    Regex.Match(assemblyInfo, @"[^/]\[assembly:\s*AssemblyCopyright\(""(?<content>.+)""\)").Groups["content"].Value;
                var info = new ProjectAssemblyInfo
                {
                    FileVersion = fileVersion,
                    Version     = version,
                    ProductName = productName,
                    Company     = companyName,
                    Title       = title,
                    Description = description,
                    Copyright   = copyright
                };
                var assemblyText = assemblyInfo; //.Replace("\r[", "\r\n[");
                var matches      = Regex.Matches(assemblyText, @"[^/]\[assembly:\s*AssemblyFileVersion\("".+""\)");
                foreach (Match match in matches)
                {
                    Console.WriteLine(match.Value);
                }
                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyFileVersion\("".+""\)",
                                             string.Format("[assembly: AssemblyFileVersion(\"{0}\")", info.FileVersion));

                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyVersion\("".+""\)",
                                             string.Format("[assembly: AssemblyVersion(\"{0}\")", info.Version));
                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyProduct\("".+""\)",
                                             string.Format("[assembly: AssemblyProduct(\"{0}\")", info.ProductName));
                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyCompany\("".*""\)",
                                             string.Format("[assembly: AssemblyCompany(\"{0}\")", info.Company));
                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyTitle\("".+""\)",
                                             string.Format("[assembly: AssemblyTitle(\"{0}\")", info.Title));
                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyDescription\("".+""\)",
                                             string.Format("[assembly: AssemblyDescription(\"{0}\")", info.Description));
                assemblyText = Regex.Replace(assemblyText, @"[^/]\[assembly:\s*AssemblyCopyright\("".+""\)",
                                             string.Format("[assembly: AssemblyCopyright(\"{0}\")", info.Copyright));
                Console.Write(assemblyText);
            }
        }
示例#5
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var dte = Host.Instance.Dte2;

            _project = dte.GetActiveProejct();

            //Common.CheckTfs(_project);
            _assemblyInfo = null;
            _ppp          = null;
            if (_project.IsSdkBased())
            {
                _ppp                 = _project.GetPackageProjectProperties();
                _metadata            = _ppp.ToManifestMetadata();
                _directoryBuildProps = Host.Instance.DTE.Solution.GetDirectoryBuildProps();
                var form = new MsbuildDeployWizard(_metadata, _ppp, _directoryBuildProps);
                form.StartPosition = FormStartPosition.CenterScreen;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    form.SaveAndBuild();
                }
            }
            else
            {
                _nuspecFile = _project.GetNuSpecFilePath();
                if (!File.Exists(_nuspecFile))
                {
                    var dr = VsShellUtilities.ShowMessageBox(this.ServiceProvider,
                                                             $"Miss {NuGetDomain.NuSpecFileName} file,would you add it now?", "Warning",
                                                             OLEMSGICON.OLEMSGICON_WARNING, OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                                                             OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    if (dr != 6)
                    {
                        return;
                    }
                    new AddNuSpecCommand().Execute();
                }

                _assemblyInfo = _project.GetProjectAssemblyInfo();
                if (string.IsNullOrWhiteSpace(_assemblyInfo.FileVersion))
                {
                    _assemblyInfo.FileVersion = _assemblyInfo.Version;
                }
                _metadata = _project.GetManifestMetadata();

                var form = new DeployWizard(_metadata, _assemblyInfo, _ppp);
                form.StartPosition = FormStartPosition.CenterScreen;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    form.SaveAndBuild();
                }
            }
        }
示例#6
0
        void CheckOut(ProjectAssemblyInfo assemblyInfo, string assemblyInfoFile)
        {
            var attr     = File.GetAttributes(assemblyInfoFile);
            var isNormal = Contains(attr, FileAttributes.Normal);
            var checkout = false;

            if (SourceControl != null)
            {
                var files =
                    SourceControl.CheckOut(
                        Path.GetDirectoryName(assemblyInfo.Project.DTE.Solution.FullName),
                        assemblyInfoFile);
                checkout = files > 0;
            }
            if (checkout || isNormal)
            {
                return;
            }

            File.SetAttributes(assemblyInfoFile, FileAttributes.Normal);
        }
示例#7
0
 public void AssignByAssemblyInfo(ProjectAssemblyInfo assemblyInfo)
 {
     if (Id.IsEmptyOrPlaceHolder() && !string.IsNullOrWhiteSpace(assemblyInfo.Title))
     {
         Id = assemblyInfo.Title;
     }
     if (Title.IsEmptyOrPlaceHolder() && !string.IsNullOrWhiteSpace(assemblyInfo.Title))
     {
         Title = assemblyInfo.Title;
     }
     if (Authors.IsEmptyOrPlaceHolder() && !string.IsNullOrWhiteSpace(assemblyInfo.Company))
     {
         Authors = assemblyInfo.Company;
     }
     if (Owners.IsEmptyOrPlaceHolder() && !string.IsNullOrWhiteSpace(assemblyInfo.Company))
     {
         Owners = assemblyInfo.Company;
     }
     if (Description.IsEmptyOrPlaceHolder() && !string.IsNullOrWhiteSpace(assemblyInfo.Description))
     {
         Description = assemblyInfo.Description;
     }
 }
示例#8
0
        public CommonAssemblyInfoForm(IEnumerable <Project> allProjects, Project startProject)
        {
            InitializeComponent();
            Icon = Resource.logo;

            List <Project> projects = allProjects.ToList();

            _projectInfos = new List <ProjectAssemblyInfo>();
            foreach (var project in projects)
            {
                var info = project.GetProjectAssemblyInfo();
                info.Project = project;
                _projectInfos.Add(info);
            }

            toolStripStatusLabel.Text = string.Format("{0} projects", projects.Count);

            Project             refProject   = startProject ?? projects[0];
            ProjectAssemblyInfo assemblyInfo = refProject.GetProjectAssemblyInfo();

            txtProduct.Text   = assemblyInfo.Product;
            txtCompany.Text   = assemblyInfo.Company;
            txtCopyright.Text = assemblyInfo.Copyright;
        }
示例#9
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var dte = Host.Instance.Dte2;

            _project = dte.GetActiveProejct();
            Common.CheckTfs(_project);

            _dir        = _project.GetDirectory();
            _nuspecFile = Path.Combine(_dir, NuGetDomain.NuSpecFileName);
            if (!File.Exists(_nuspecFile))
            {
                var dr = VsShellUtilities.ShowMessageBox(this.ServiceProvider, $"Miss {NuGetDomain.NuSpecFileName} file,would you add it now?", "Warning",
                                                         OLEMSGICON.OLEMSGICON_WARNING, OLEMSGBUTTON.OLEMSGBUTTON_YESNO, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                if (dr != 6)
                {
                    return;
                }
                new AddNuSpecCommand().Execute();
            }

            _assemblyInfo = _project.GetProjectAssemblyInfo();
            _xmlDoc       = new XmlDocument();
            _xmlDoc.Load(_nuspecFile);
            var xml = _xmlDoc.InnerXml;

            _nupack = XmlSerializerHelper.LoadObjectFromXmlString <NuGet.Package>(xml);

            var packageFields  = new List <string>();
            var assemblyFields = new List <string>();

            if (_nupack.Metadata.Id.IsEmptyOrPlaceHolder() && string.IsNullOrWhiteSpace(_assemblyInfo.Title))
            {
                packageFields.Add("id");
                assemblyFields.Add("AssemblyTitle");
            }
            if (_nupack.Metadata.Authors.IsEmptyOrPlaceHolder() && string.IsNullOrWhiteSpace(_assemblyInfo.Company))
            {
                packageFields.Add("authors");
                assemblyFields.Add("AssemblyCompany");
            }
            if (_nupack.Metadata.Description.IsEmptyOrPlaceHolder() && string.IsNullOrWhiteSpace(_assemblyInfo.Description))
            {
                packageFields.Add("description");
                assemblyFields.Add("AssemblyDescription");
            }


            if (assemblyFields.Count > 0)
            {
                var assemblyInfoFile = _project.GetAssemblyInfoFileName();

                if (File.Exists(assemblyInfoFile))
                {
                    VsShellUtilities.ShowMessageBox(this.ServiceProvider,
                                                    $"{string.Join("/", assemblyFields)} required,please edit {Path.GetFileName(assemblyInfoFile)} at first.", "Warning",
                                                    OLEMSGICON.OLEMSGICON_WARNING, OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

                    dte.ItemOperations.OpenFile(assemblyInfoFile);
                }
                else
                {
                    VsShellUtilities.ShowMessageBox(this.ServiceProvider,
                                                    $"{string.Join("/", packageFields)} required,please edit package.nuspec at first.", "Warning",
                                                    OLEMSGICON.OLEMSGICON_WARNING, OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

                    dte.ItemOperations.OpenFile(_nuspecFile);
                }
                return;
            }

            MergePackagesConfig();

            var form = new DeployWizard(_assemblyInfo, _nupack, _xmlDoc);

            if (form.ShowDialog() == DialogResult.OK)
            {
                form.SaveAndBuild();
            }
        }
示例#10
0
 public DeployWizard(ProjectAssemblyInfo assemblyInfo, Package package, XmlDocument doc) : this()
 {
     _assemblyInfo = assemblyInfo;
     _package      = package;
     _xmlDoc       = doc;
 }