public static IntermediateField Set(this IntermediateTuple tuple, int index, IntermediateFieldPathValue value) { var definition = tuple.Definition.FieldDefinitions[index]; var field = tuple.Fields[index].Set(definition, value); return(tuple.Fields[index] = field); }
private void UpdatePayloadFileInformation(WixBundlePayloadSymbol payload, IntermediateFieldPathValue sourceFile) { var fileInfo = new FileInfo(sourceFile.Path); if (null != fileInfo) { payload.FileSize = fileInfo.Length; payload.Hash = BundleHashAlgorithm.Hash(fileInfo); } else { payload.FileSize = 0; } }
private void UpdatePayloadFileInformation(WixBundlePayloadSymbol payload, IntermediateFieldPathValue sourceFile) { var fileInfo = new FileInfo(sourceFile.Path); if (null != fileInfo) { payload.FileSize = (int)fileInfo.Length; payload.Hash = BundleHashAlgorithm.Hash(fileInfo); // Try to get the certificate if the payload is a signed file and we're not suppressing signature validation. if (payload.EnableSignatureValidation) { X509Certificate2 certificate = null; try { certificate = new X509Certificate2(fileInfo.FullName); } catch (CryptographicException) // we don't care about non-signed files. { } // If there is a certificate, remember its hashed public key identifier and thumbprint. if (null != certificate) { byte[] publicKeyIdentifierHash = new byte[128]; uint publicKeyIdentifierHashSize = (uint)publicKeyIdentifierHash.Length; Native.NativeMethods.HashPublicKeyInfo(certificate.Handle, publicKeyIdentifierHash, ref publicKeyIdentifierHashSize); var sb = new StringBuilder(((int)publicKeyIdentifierHashSize + 1) * 2); for (var i = 0; i < publicKeyIdentifierHashSize; ++i) { sb.AppendFormat("{0:X2}", publicKeyIdentifierHash[i]); } payload.PublicKey = sb.ToString(); payload.Thumbprint = certificate.Thumbprint; } } } else { payload.FileSize = 0; } }
private void UpdatePayloadVersionInformation(WixBundlePayloadSymbol payload, IntermediateFieldPathValue sourceFile) { var versionInfo = FileVersionInfo.GetVersionInfo(sourceFile.Path); if (null != versionInfo) { // Use the fixed version info block for the file since the resource text may not be a dotted quad. var version = new Version(versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart, versionInfo.ProductPrivatePart); if (ProcessPayloadsCommand.EmptyVersion != version) { payload.Version = version.ToString(); } payload.Description = versionInfo.FileDescription; payload.DisplayName = versionInfo.ProductName; } }
private void ResolvePathField(FileResolver fileResolver, IntermediateSymbol symbol, IntermediateField field) { var fieldValue = field.AsPath(); var originalFieldPath = fieldValue.Path; #if TODO_PATCHING // Skip file resolution if the file is to be deleted. if (RowOperation.Delete == symbol.Operation) { continue; } #endif // If the file is embedded and if the previous value has a bind variable in the path // which gets modified by resolving the previous value again then switch to that newly // resolved path instead of using the embedded file. if (fieldValue.Embed && field.PreviousValue != null) { var resolution = this.VariableResolver.ResolveVariables(symbol.SourceLineNumbers, field.PreviousValue.AsString(), errorOnUnknown: false); if (resolution.UpdatedValue && !resolution.IsDefault) { fieldValue = new IntermediateFieldPathValue { Path = resolution.Value }; } } // If we're still using the embedded file. if (fieldValue.Embed) { // Set the path to the embedded file once where it will be extracted. var extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileToExtract(fieldValue.BaseUri, fieldValue.Path, this.IntermediateFolder); field.Set(extractPath); } else if (fieldValue.Path != null) { try { var resolvedPath = fieldValue.Path; if (!this.BuildingPatch) // Normal binding for non-Patch scenario such as link (light.exe) { #if TODO_PATCHING // keep a copy of the un-resolved data for future replay. This will be saved into wixpdb file if (null == objectField.UnresolvedData) { objectField.UnresolvedData = (string)objectField.Data; } #endif resolvedPath = fileResolver.ResolveFile(fieldValue.Path, symbol.Definition, symbol.SourceLineNumbers, BindStage.Normal); } else if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) // Normal binding for Patch Scenario (normal patch, no re-basing logic) { resolvedPath = fileResolver.ResolveFile(fieldValue.Path, symbol.Definition, symbol.SourceLineNumbers, BindStage.Normal); } #if TODO_PATCHING else // Re-base binding path scenario caused by pyro.exe -bt -bu { // by default, use the resolved Data for file lookup string filePathToResolve = (string)objectField.Data; // if -bu is used in pyro command, this condition holds true and the tool // will use pre-resolved source for new wixpdb file if (fileResolver.RebaseUpdated) { // try to use the unResolved Source if it exists. // New version of wixpdb file keeps a copy of pre-resolved Source. i.e. !(bindpath.test)\foo.dll // Old version of winpdb file does not contain this attribute and the value is null. if (null != objectField.UnresolvedData) { filePathToResolve = objectField.UnresolvedData; } } objectField.Data = fileResolver.ResolveFile(filePathToResolve, symbol.Definition.Name, symbol.SourceLineNumbers, BindStage.Updated); } #endif if (!String.Equals(originalFieldPath, resolvedPath, StringComparison.OrdinalIgnoreCase)) { field.Set(resolvedPath); } } catch (WixException e) { this.Messaging.Write(e.Error); } } }
public static IntermediateField Set(this IntermediateSymbol symbol, int index, IntermediateFieldPathValue value) { if (value?.Path == null && value?.BaseUri == null && NoFieldMetadata(symbol, index)) { return(symbol.Fields[index] = null); } var definition = symbol.Definition.FieldDefinitions[index]; var field = symbol.Fields[index].Set(definition, value); return(symbol.Fields[index] = field); }