Пример #1
0
        /// <summary>
        /// 移动到目录文件
        /// </summary>
        /// <param name="grpcDllPath"></param>
        public static string ToResultDic(string shortFileName, string grpcDllPath, string nameSpace, out string errorMsg)
        {
            errorMsg = string.Empty;
            try
            {
                #region 移动Dll
                var resultDic = GrpcGlobal.GenResultDic(shortFileName);
                Utility.MakeDir(Path.Combine(resultDic, netstandardFold));
                Utility.MakeDir(Path.Combine(resultDic, netcoreappFold));
                Utility.MakeDir(Path.Combine(resultDic, net5Fold));

                var netstandardFile = new FileInfo(grpcDllPath);
                var netcoreappFile  = new FileInfo(grpcDllPath.Replace("netstandard2.1", netcoreappFold));
                var net5File        = new FileInfo(grpcDllPath.Replace("netstandard2.1", net5Fold));

                File.Copy(netstandardFile.FullName, Path.Combine(resultDic, netstandardFold, nameSpace + ".dll"));
                File.Copy(netcoreappFile.FullName, Path.Combine(resultDic, netcoreappFold, nameSpace + ".dll"));
                File.Copy(net5File.FullName, Path.Combine(resultDic, net5Fold, nameSpace + ".dll"));
                #endregion

                #region 移动Xml
                var netstandardXmlFile = new FileInfo(grpcDllPath.Replace(".dll", ".xml"));
                var netcoreappXmlFile  = new FileInfo(grpcDllPath.Replace("netstandard2.1", netcoreappFold).Replace(".dll", ".xml"));
                var net5XmlFile        = new FileInfo(grpcDllPath.Replace("netstandard2.1", net5Fold).Replace(".dll", ".xml"));

                File.Copy(netstandardXmlFile.FullName, Path.Combine(resultDic, netstandardFold, nameSpace + ".xml"));
                File.Copy(netcoreappXmlFile.FullName, Path.Combine(resultDic, netcoreappFold, nameSpace + ".xml"));
                File.Copy(net5XmlFile.FullName, Path.Combine(resultDic, net5Fold, nameSpace + ".xml"));
                #endregion

                #region 移动Config
                var genFold = GrpcGlobal.GenFolder;

                var coreConfigFold = Path.Combine(genFold, "coreconfigs");
                var coreConfigs    = Directory.GetFiles(coreConfigFold);

                var newNetStandardFold = Path.Combine(resultDic, netstandardFold, dllconfigFold);
                var newNetCoreAppFold  = Path.Combine(resultDic, netcoreappFold, dllconfigFold);
                var newNet5Fold        = Path.Combine(resultDic, net5Fold, dllconfigFold);
                Utility.MakeDir(newNetStandardFold);
                Utility.MakeDir(newNetCoreAppFold);
                Utility.MakeDir(newNet5Fold);

                foreach (var coreConfig in coreConfigs)
                {
                    var file = new FileInfo(coreConfig);
                    File.Copy(coreConfig, Path.Combine(newNetStandardFold, file.Name));
                    File.Copy(coreConfig, Path.Combine(newNetCoreAppFold, file.Name));
                    File.Copy(coreConfig, Path.Combine(newNet5Fold, file.Name));
                }
                #endregion

                return(resultDic);
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }
            return(string.Empty);
        }
Пример #2
0
        /// <summary>
        /// 移动到目录文件
        /// </summary>
        /// <param name="grpcDllPath"></param>
        public static string ToResultDic(string shortFileName, string grpcDllPath, string nameSpace, out string errorMsg)
        {
            errorMsg = string.Empty;
            try
            {
                #region 移动Dll
                var resultDic = GrpcGlobal.GenResultDic(shortFileName);

                Utility.MakeDir(Path.Combine(resultDic, net45Fold));
                Utility.MakeDir(Path.Combine(resultDic, net46Fold));
                //Utility.MakeDic(Path.Combine(resultDic, net47Fold));
                Utility.MakeDir(Path.Combine(resultDic, netcoreFold));

                var net45File = new FileInfo(grpcDllPath.Replace("net46", net45Fold));
                var net46File = new FileInfo(grpcDllPath);
                //var net47File = new FileInfo(grpcDllPath.Replace("net46", "net47"));
                var netcore20 = new FileInfo(grpcDllPath.Replace("net46", netcoreFold));

                File.Copy(net45File.FullName, Path.Combine(resultDic, net45Fold, nameSpace + ".dll"));
                File.Copy(net46File.FullName, Path.Combine(resultDic, net46Fold, nameSpace + ".dll"));
                //File.Copy(net47File.FullName, Path.Combine(resultDic, net47Fold, nameSpace + ".dll"));
                File.Copy(netcore20.FullName, Path.Combine(resultDic, netcoreFold, nameSpace + ".dll"));
                #endregion


                #region 移动Xml
                var net45XmlFile = new FileInfo(grpcDllPath.Replace("net46", net45Fold).Replace(".dll", ".xml"));
                var net46XmlFile = new FileInfo(grpcDllPath.Replace(".dll", ".xml"));
                //var net47XmlFile = new FileInfo(grpcDllPath.Replace("net46", "net47").Replace(".dll", ".xml"));
                var netcore20Xml = new FileInfo(grpcDllPath.Replace("net46", netcoreFold).Replace(".dll", ".xml"));

                File.Copy(net45XmlFile.FullName, Path.Combine(resultDic, net45Fold, nameSpace + ".xml"));
                File.Copy(net46XmlFile.FullName, Path.Combine(resultDic, net46Fold, nameSpace + ".xml"));
                //File.Copy(net47XmlFile.FullName, Path.Combine(resultDic, net47Fold, nameSpace + ".dll"));
                File.Copy(netcore20Xml.FullName, Path.Combine(resultDic, netcoreFold, nameSpace + ".xml"));
                #endregion

                #region 移动Config
                var genFold = GrpcGlobal.GenFolder;

                var fmConfigFold = Path.Combine(genFold, "fmconfigs");
                var fmConfigs    = Directory.GetFiles(fmConfigFold);


                var newNet45ConfigFold = Path.Combine(resultDic, net45Fold, dllconfigFold);
                Utility.MakeDir(newNet45ConfigFold);

                var newNet46ConfigFold = Path.Combine(resultDic, net46Fold, dllconfigFold);
                Utility.MakeDir(newNet46ConfigFold);

                //var newNet47ConfigFold = Path.Combine(resultDic, net47Fold, dllconfigFold);
                //Utility.MakeDic(newNet47ConfigFold);

                foreach (var fmConfig in fmConfigs)
                {
                    var file = new FileInfo(fmConfig);
                    File.Copy(fmConfig, Path.Combine(newNet45ConfigFold, file.Name));
                    File.Copy(fmConfig, Path.Combine(newNet46ConfigFold, file.Name));
                    //File.Copy(fmConfig, Path.Combine(newNet47ConfigFold, file.Name));
                }

                var coreConfigFold = Path.Combine(genFold, "coreconfigs");
                var coreConfigs    = Directory.GetFiles(coreConfigFold);

                var newCoreConfigFold = Path.Combine(resultDic, netcoreFold, dllconfigFold);
                Utility.MakeDir(newCoreConfigFold);

                foreach (var coreConfig in coreConfigs)
                {
                    var file = new FileInfo(coreConfig);
                    File.Copy(coreConfig, Path.Combine(newCoreConfigFold, file.Name));
                }
                #endregion

                return(resultDic);
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }
            return(string.Empty);
        }