private LocalBuildInfo LocalBuildInfoFromRemoteBuildInfo()
        {
            var localBuildInfo = new LocalBuildInfo();

            localBuildInfo.ProductVersionInfo = remoteBuildInfo.ProductVersionInfo;
            foreach (RemoteFileInfo fileInfo in remoteBuildInfo.FileInfos)
            {
                localBuildInfo.AddFileInfo(new LocalFileInfo(fileInfo.FilePath,
                                                             fileInfo.UncompressedHash, fileInfo.UncompressedSize));
            }
            return(localBuildInfo);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes new local and remote version files into the build directory.
        /// </summary>
        public void WriteVersionFiles()
        {
            var localBuildInfo = new LocalBuildInfo();

            localBuildInfo.ProductVersionInfo = new ProductVersionInfo(InternalVersion, DisplayedVersion);

            var remoteBuildInfo = new RemoteBuildInfo();

            remoteBuildInfo.ProductVersionInfo = new ProductVersionInfo(InternalVersion, DisplayedVersion);

            string buildPath = Environment.CurrentDirectory +
                               Path.DirectorySeparatorChar + BuildDirectory + Path.DirectorySeparatorChar;

            foreach (FileEntry file in FileEntries)
            {
                string originalFilePath = Environment.CurrentDirectory +
                                          Path.DirectorySeparatorChar + file.FilePath;

                byte[] hash = HashHelper.ComputeHashForFile(originalFilePath);
                long   size = new FileInfo(originalFilePath).Length;
                localBuildInfo.AddFileInfo(new LocalFileInfo(file.FilePath, hash, size));

                RemoteFileInfo remoteFileInfo;

                if (file.Compressed)
                {
                    string compressedFilePath = buildPath + file.FilePath + RemoteFileInfo.COMPRESSED_FILE_EXTENSION;
                    remoteFileInfo = new RemoteFileInfo(file.FilePath, hash, size, true,
                                                        HashHelper.ComputeHashForFile(compressedFilePath),
                                                        new FileInfo(compressedFilePath).Length);
                }
                else
                {
                    remoteFileInfo = new RemoteFileInfo(file.FilePath, hash, size, false);
                }

                remoteBuildInfo.AddFileInfo(remoteFileInfo);
            }

            localBuildInfo.Write(buildPath + BuildHandler.LOCAL_BUILD_INFO_FILE);
            remoteBuildInfo.Write(buildPath + BuildHandler.REMOTE_BUILD_INFO_FILE);
        }