예제 #1
0
 /// <summary>
 /// 获取 Nuget 版本
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void getNugetVersionButton_Click(object sender, EventArgs e)
 {
     Nuget.Metadata metadata = Nuget.Project.Projects[0].Metadata;
     if (metadata != null)
     {
         appendMessage(metadata.id + " " + metadata.version);
     }
 }
예제 #2
0
        /// <summary>
        /// Nuget 打包
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void nugetPackButton_Click(object sender, EventArgs e)
        {
            //https://docs.microsoft.com/zh-cn/nuget/reference/cli-reference/cli-ref-pack
            //nuget spec
            foreach (Nuget.Project project in Nuget.Project.Projects)
            {
                Nuget.Metadata metadata = project.Metadata;
                if (metadata != null)
                {
                    deleteDirectory(project.Path + @"bin");
                    deleteDirectory(project.Path + @"obj");
                    deleteDirectory(project.Path + @".vs");

                    FileInfo packFile = new FileInfo(project.PackageFile);
                    if (packFile.Exists)
                    {
                        packFile.Delete();
                    }

                    string arguments = "pack " + project.File + " -Build -Version " + metadata.version + @" -Properties Configuration=Release";
                    string error, output = waitProcessDirectory(AutoCSer.Web.Config.Pub.NugetFile, out error, arguments);
                    if (new FileInfo(packFile.FullName).Exists)
                    {
                        arguments = "push " + packFile.FullName + " " + AutoCSer.Web.Config.Pub.NugetKey + " -Source https://api.nuget.org/v3/index.json";
                        output    = waitProcessDirectory(AutoCSer.Web.Config.Pub.NugetFile, out error, arguments);
                        if (isPushNuget(output))
                        {
                            appendMessage(packFile.FullName + " push 成功");
                        }
                        else
                        {
                            appendMessage(packFile.FullName + @" push 失败
" + AutoCSer.Web.Config.Pub.NugetFile + " " + arguments + @"
" + output + @"
" + error);
                        }
                    }
                    else
                    {
                        appendMessage(metadata.id + @" Nuget 打包失败
" + output + @"
" + error);
                    }
                }
                else
                {
                    appendMessage("配置文件 " + project.MetadataFile + " 读取失败");
                }
            }
        }
예제 #3
0
 /// <summary>
 /// 重算 Nuget 版本
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void setNugetVersionButton_Click(object sender, EventArgs e)
 {
     Nuget.Metadata metadata = Nuget.Project.Projects[0].Metadata;
     if (metadata != null)
     {
         int    index      = metadata.version.LastIndexOf('.') + 1;
         string newVersion = metadata.version.Substring(0, index) + (int.Parse(metadata.version.Substring(index)) + 1).toString();
         foreach (Nuget.Project project in Nuget.Project.Projects)
         {
             File.WriteAllText(project.MetadataFile, Nuget.Metadata.VersionRegex.Replace(File.ReadAllText(project.MetadataFile, Encoding.UTF8), @"<version>" + newVersion + @"</version>"), Encoding.UTF8);
             metadata = project.Metadata;
             appendMessage(metadata.id + " 更新版本 " + metadata.version);
         }
     }
 }