Beispiel #1
0
        private void EmbedSourceFiles(CompilerParameters parameters, string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            var embedFileList = new List <string>();
            var xmlFilePath   = DirectoryHelper.GetCurrentDirectoryFilePath("Files.xml");

            var dirInfo     = new DirectoryInfo(sourcePath);
            var sourceFiles = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);

            var fileCacher = new FilePathCacher(xmlFilePath);

            foreach (var sourceFile in sourceFiles)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
                          sourceFile.Name.ToLower() == "v32.cab" ||
                          sourceFile.Name.ToLower() == "v64.cab"))
                    {
                        continue;
                    }
                }

                if (officeClientEdition == OfficeClientEdition.Office32Bit)
                {
                    if (sourceFile.Name.ToLower().Contains(".x64."))
                    {
                        continue;
                    }
                }
                else
                {
                    if (sourceFile.Name.ToLower().Contains(".x86."))
                    {
                        continue;
                    }
                }
                if (embedFileList.Contains(sourceFile.Name, StringComparer.CurrentCultureIgnoreCase))
                {
                    sourceFile.CopyTo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name, true);
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    parameters.EmbeddedResources.Add(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    filesMarkedForDelete.Add(new FileInfo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name));
                }
                else
                {
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.FullName);
                    parameters.EmbeddedResources.Add(sourceFile.FullName);
                }
                embedFileList.Add(sourceFile.Name);
            }

            parameters.EmbeddedResources.Add(xmlFilePath);
        }
Beispiel #2
0
        private long CalcSize(CompilerParameters parameters, string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            long runningTotalFileSize = 0;
            var  xmlFilePath          = DirectoryHelper.GetCurrentDirectoryFilePath("Files.xml");

            var dirInfo     = new DirectoryInfo(sourcePath);
            var sourceFiles = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);

            var fileCacher = new FilePathCacher(xmlFilePath);

            foreach (var sourceFile in sourceFiles)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
                          sourceFile.Name.ToLower() == "v32.cab" ||
                          sourceFile.Name.ToLower() == "v64.cab"))
                    {
                        continue;
                    }
                }

                if (officeClientEdition == OfficeClientEdition.Office32Bit)
                {
                    if (sourceFile.Name.ToLower().Contains(".x64."))
                    {
                        continue;
                    }
                }
                else
                {
                    if (sourceFile.Name.ToLower().Contains(".x86."))
                    {
                        continue;
                    }
                }

                //fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.FullName);

                //parameters.EmbeddedResources.Add(sourceFile.FullName);
                FileInfo file = new FileInfo(sourceFile.FullName);
                runningTotalFileSize += file.Length;
            }

            //parameters.EmbeddedResources.Add(xmlFilePath);
            return(runningTotalFileSize);
        }
        private long CalcSize(CompilerParameters parameters, string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            long runningTotalFileSize = 0;
            var xmlFilePath = DirectoryHelper.GetCurrentDirectoryFilePath("Files.xml");

            var dirInfo = new DirectoryInfo(sourcePath);
            var sourceFiles = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);

            var fileCacher = new FilePathCacher(xmlFilePath);

            foreach (var sourceFile in sourceFiles)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
                        sourceFile.Name.ToLower() == "v32.cab" ||
                        sourceFile.Name.ToLower() == "v64.cab"))
                    {
                        continue;
                    }
                }

                if (officeClientEdition == OfficeClientEdition.Office32Bit)
                {
                    if (sourceFile.Name.ToLower().Contains(".x64."))
                    {
                        continue;
                    }
                }
                else
                {
                    if (sourceFile.Name.ToLower().Contains(".x86."))
                    {
                        continue;
                    }
                }

                //fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.FullName);

                //parameters.EmbeddedResources.Add(sourceFile.FullName);
                FileInfo file = new FileInfo(sourceFile.FullName);
                runningTotalFileSize += file.Length;
            }

            //parameters.EmbeddedResources.Add(xmlFilePath);
            return runningTotalFileSize;
        }
        private void EmbedSourceFiles(CompilerParameters parameters, string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            var embedFileList = new List<string>();
            var xmlFilePath = DirectoryHelper.GetCurrentDirectoryFilePath("Files.xml"); 

            var dirInfo = new DirectoryInfo(sourcePath);
            var sourceFiles = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);

            var fileCacher = new FilePathCacher(xmlFilePath);

            foreach (var sourceFile in sourceFiles)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
                        sourceFile.Name.ToLower() == "v32.cab" ||
                        sourceFile.Name.ToLower() == "v64.cab"))
                    {
                        continue;
                    }
                }

                if (officeClientEdition == OfficeClientEdition.Office32Bit)
                {
                    if (sourceFile.Name.ToLower().Contains(".x64."))
                    {
                        continue;
                    }
                }
                else
                {
                    if (sourceFile.Name.ToLower().Contains(".x86."))
                    {
                        continue;
                    }
                }
                if (embedFileList.Contains(sourceFile.Name, StringComparer.CurrentCultureIgnoreCase))
                 {
                    sourceFile.CopyTo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name, true);
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    parameters.EmbeddedResources.Add(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    filesMarkedForDelete.Add(new FileInfo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name));
                 }
                 else
                 {
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.FullName);
                    parameters.EmbeddedResources.Add(sourceFile.FullName);
                 }
                embedFileList.Add(sourceFile.Name);
            }

            parameters.EmbeddedResources.Add(xmlFilePath);
        }