private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var data = NugetServerHelper.Get();

            tbAddress.Text = data.Address;
            tbKey.Text     = data.Key;
        }
Beispiel #2
0
        private void CbPublish_Checked(object sender, RoutedEventArgs e)
        {
            var nuget = NugetServerHelper.Get();

            if (string.IsNullOrEmpty(nuget?.Address))
            {
                ShowNugetServerDialog();
            }
        }
Beispiel #3
0
        /// <summary>
        ///生成nuget包
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="serviceModel"></param>
        /// <param name="errorMsg"></param>
        /// <param name="resultDic"></param>
        /// <returns></returns>
        public static bool ExcuteClientNuget(string filePath, ServiceModel serviceModel, out string errorMsg, out string resultDic)
        {
            errorMsg  = string.Empty;
            resultDic = string.Empty;

            if (!ExecuteClientDll(filePath, serviceModel, out errorMsg, out resultDic))
            {
                return(false);
            }

            var fileName = new FileInfo(filePath).Name;
            // 生成nuget文件
            var projDicPath   = ThriftGlobal.GetProjDir(fileName);
            var thriftDllPath = Path.Combine(projDicPath, "bin", "thriftProj.dll");
            var nuspecXml     = GenUtilityAsync.GenNuspecXml(thriftDllPath, serviceModel.NugetId);

            if (string.IsNullOrEmpty(nuspecXml))
            {
                errorMsg = "nuspec file gen error!!!";
                return(false);
            }

            var nuspecFilePath = Path.Combine(resultDic, "Package.nuspec");

            Utility.WriteNewFile(nuspecFilePath, nuspecXml);

            // 生成nuget包
            var error = string.Empty;

            Utility.RunCmd(Utility.NugetExePath, "pack " + nuspecFilePath + " -OutputDirectory " + resultDic, out error);

            // 直接发布
            if (serviceModel.Publish)
            {
                //var nugetServer = "http://10.0.60.89:8081";
                //if (ThriftGlobal.GenAsyncVersion == EnumGenAsyncVersion.Old)
                //    nugetServer = "http://10.0.60.89:8080";

                var nugetServer = NugetServerHelper.Get();
                var nugetPks    = new DirectoryInfo(resultDic).GetFiles("*.nupkg");
                if (nugetPks.Length <= 0)
                {
                    errorMsg = "nupkg not gen";
                    return(false);
                }

                Utility.RunCmd(Utility.NugetExePath, "push " + nugetPks[0].FullName + " -s " + nugetServer.Address + " " + nugetServer.Key, out error);
            }

            return(true);
        }
Beispiel #4
0
        private void ShowNugetServerDialog()
        {
            var window = new ServiceNugetServer()
            {
                Owner = this
            };

            window.Closed += (sender, e) =>
            {
                var nuget = NugetServerHelper.Get();
                if (string.IsNullOrEmpty(nuget?.Address))
                {
                    cbPublish.IsChecked = false;
                }
            };
            window.ShowDialog();
        }
Beispiel #5
0
        private void btnSure_Click(object sender, RoutedEventArgs e)
        {
            var address = tbAddress.Text.Trim();
            var key     = tbKey.Text.Trim();

            if (string.IsNullOrEmpty(address))
            {
                tbAddress.Focus();
                MessageBox.Show("请输入服务器地址");
                return;
            }

            var data = new NugetServerModel()
            {
                Address = address,
                Key     = key
            };

            NugetServerHelper.Save(data);
            Close();
        }
Beispiel #6
0
        /// <summary>
        ///生成nuget包
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="serviceModel"></param>
        /// <param name="errorMsg"></param>
        /// <param name="resultDic"></param>
        /// <returns></returns>
        public static bool ExcuteNuget(string filePath, ServiceModel serviceModel, string tempKey, out string csNamespace, out string errorMsg, out string resultDic)
        {
            csNamespace = string.Empty;
            errorMsg    = string.Empty;
            resultDic   = string.Empty;

            if (!ExecuteDll(filePath, tempKey, out csNamespace, out errorMsg, out resultDic))
            {
                return(false);
            }

            var nuspecXml      = GenUtilityOrigin.GenNuspecXml(resultDic, serviceModel, csNamespace);
            var nuspecFilePath = Path.Combine(resultDic, "Package.nuspec");

            Utility.WriteNewFile(nuspecFilePath, nuspecXml);

            // 生成nuget包msbu
            var error = string.Empty;

            Utility.RunCmd(Utility.NugetExePath, "pack " + nuspecFilePath + " -OutputDirectory " + resultDic, out error);

            // 直接发布
            if (serviceModel.Publish)
            {
                var nugetServer = NugetServerHelper.Get();
                var nugetPks    = new DirectoryInfo(resultDic).GetFiles("*.nupkg");
                if (nugetPks.Length <= 0)
                {
                    errorMsg = "nupkg not gen";
                    return(false);
                }
                Utility.RunCmd(Utility.NugetExePath, "push " + nugetPks[0].FullName + " -s " + nugetServer.Address + " " + nugetServer.Key, out error);
            }

            return(true);
        }