Esempio n. 1
0
        /// <summary>
        /// Harvest a payload.
        /// </summary>
        /// <param name="path">The path of the payload.</param>
        /// <returns>A harvested payload.</returns>
        public Wix.RemotePayload HarvestRemotePayload(string path)
        {
            if (null == path)
            {
                throw new ArgumentNullException("path");
            }

            if (!File.Exists(path))
            {
                throw new WixException(HarvesterErrors.FileNotFound(path));
            }

            Wix.RemotePayload remotePayload = new Wix.RemotePayload();

            FileInfo fileInfo = new FileInfo(path);

            remotePayload.Size = (int)fileInfo.Length;
            remotePayload.Hash = this.GetFileHash(path);

            FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(path);

            if (null != versionInfo)
            {
                // Use the fixed version info block for the file since the resource text may not be a dotted quad.
                Version version = new Version(versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart, versionInfo.ProductPrivatePart);

                remotePayload.Version     = version.ToString();
                remotePayload.Description = versionInfo.FileDescription;
                remotePayload.ProductName = versionInfo.ProductName;
            }

            return(remotePayload);
        }
Esempio n. 2
0
        /// <summary>
        /// Harvest a payload.
        /// </summary>
        /// <param name="argument">The path of the payload.</param>
        /// <returns>A harvested payload.</returns>
        public override Wix.Fragment[] Harvest(string argument)
        {
            if (null == argument)
            {
                throw new ArgumentNullException("argument");
            }

            string fullPath = Path.GetFullPath(argument);

            Wix.RemotePayload remotePayload = this.HarvestRemotePayload(fullPath);

            Wix.Fragment fragment = new Wix.Fragment();
            fragment.AddChild(remotePayload);

            return(new Wix.Fragment[] { fragment });
        }