本文整理汇总了C#中Microsoft.Tools.WindowsInstallerXml.Output.EnsureTable方法的典型用法代码示例。如果您正苦于以下问题:C# Output.EnsureTable方法的具体用法?C# Output.EnsureTable怎么用?C# Output.EnsureTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Tools.WindowsInstallerXml.Output
的用法示例。
在下文中一共展示了Output.EnsureTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteBuildInfoTable
/// <summary>
/// Populates the WixBuildInfo table in an output.
/// </summary>
/// <param name="output">The output.</param>
/// <param name="databaseFile">The output file if OutputFile not set.</param>
private void WriteBuildInfoTable(Output output, string outputFile)
{
Table buildInfoTable = output.EnsureTable(this.core.TableDefinitions["WixBuildInfo"]);
Row buildInfoRow = buildInfoTable.CreateRow(null);
Assembly executingAssembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(executingAssembly.Location);
buildInfoRow[0] = fileVersion.FileVersion;
buildInfoRow[1] = this.OutputFile ?? outputFile;
if (!String.IsNullOrEmpty(this.wixprojectFile))
{
buildInfoRow[2] = this.wixprojectFile;
}
if (!String.IsNullOrEmpty(this.pdbFile))
{
buildInfoRow[3] = this.pdbFile;
}
}
示例2: PopulateChainInfoTables
private void PopulateChainInfoTables(Output bundle, WixBundleRow bundleInfo, List<ChainPackageInfo> chainPackages)
{
bool hasPerMachineNonPermanentPackages = false;
foreach (ChainPackageInfo package in chainPackages)
{
// Update package scope from bundle scope if default.
if (YesNoDefaultType.Default == package.PerMachine)
{
package.PerMachine = bundleInfo.PerMachine ? YesNoDefaultType.Yes : YesNoDefaultType.No;
}
// Keep track if any per-machine non-permanent packages exist.
if (YesNoDefaultType.Yes == package.PerMachine && 0 < package.Provides.Count && !package.Permanent)
{
hasPerMachineNonPermanentPackages = true;
}
switch (package.ChainPackageType)
{
case Compiler.ChainPackageType.Msi:
Table chainMsiPackageTable = bundle.EnsureTable(this.core.TableDefinitions["ChainMsiPackage"]);
ChainMsiPackageRow row = (ChainMsiPackageRow)chainMsiPackageTable.CreateRow(null);
row.ChainPackage = package.Id;
row.ProductCode = package.ProductCode;
row.ProductLanguage = Convert.ToInt32(package.Language, CultureInfo.InvariantCulture);
row.ProductName = package.DisplayName;
row.ProductVersion = package.Version;
if (!String.IsNullOrEmpty(package.UpgradeCode))
{
row.UpgradeCode = package.UpgradeCode;
}
break;
default:
break;
}
}
// We will only register packages in the same scope as the bundle.
// Warn if any packages with providers are in a different scope
// and not permanent (permanents typically don't need a ref-count).
if (!bundleInfo.PerMachine && hasPerMachineNonPermanentPackages)
{
this.core.OnMessage(WixWarnings.NoPerMachineDependencies());
}
}
示例3: UpdateFileRow
private void UpdateFileRow(Output output, IDictionary<string, string> infoCache, string modularizationGuid, Hashtable fileRowIndex, FileRow fileRow, bool overwriteHash)
{
FileInfo fileInfo = null;
if (!this.suppressFileHashAndInfo || (!this.suppressAssemblies && FileAssemblyType.NotAnAssembly != fileRow.AssemblyType))
{
try
{
fileInfo = new FileInfo(fileRow.Source);
}
catch (ArgumentException)
{
this.core.OnMessage(WixErrors.InvalidFileName(fileRow.SourceLineNumbers, fileRow.Source));
return;
}
catch (PathTooLongException)
{
this.core.OnMessage(WixErrors.InvalidFileName(fileRow.SourceLineNumbers, fileRow.Source));
return;
}
catch (NotSupportedException)
{
this.core.OnMessage(WixErrors.InvalidFileName(fileRow.SourceLineNumbers, fileRow.Source));
return;
}
}
if (!this.suppressFileHashAndInfo)
{
if (fileInfo.Exists)
{
string version;
string language;
using (FileStream fileStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
{
if (Int32.MaxValue < fileStream.Length)
{
throw new WixException(WixErrors.FileTooLarge(fileRow.SourceLineNumbers, fileRow.Source));
}
fileRow.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture);
}
try
{
Installer.GetFileVersion(fileInfo.FullName, out version, out language);
}
catch (Win32Exception e)
{
if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND
{
throw new WixException(WixErrors.FileNotFound(fileRow.SourceLineNumbers, fileInfo.FullName));
}
else
{
throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, e.Message));
}
}
// If there is no version, it is assumed there is no language because it won't matter in the versioning of the install.
if (0 == version.Length) // unversioned files have their hashes added to the MsiFileHash table
{
if (null != fileRow.Version)
{
// Check if this is a companion file. If its not, it is a default version.
if (!fileRowIndex.ContainsKey(fileRow.Version))
{
this.core.OnMessage(WixWarnings.DefaultVersionUsedForUnversionedFile(fileRow.SourceLineNumbers, fileRow.Version, fileRow.File));
}
}
else
{
if (null != fileRow.Language)
{
this.core.OnMessage(WixWarnings.DefaultLanguageUsedForUnversionedFile(fileRow.SourceLineNumbers, fileRow.Language, fileRow.File));
}
int[] hash;
try
{
Installer.GetFileHash(fileInfo.FullName, 0, out hash);
}
catch (Win32Exception e)
{
if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND
{
throw new WixException(WixErrors.FileNotFound(fileRow.SourceLineNumbers, fileInfo.FullName));
}
else
{
throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, fileInfo.FullName, e.Message));
}
}
if (null == fileRow.HashRow)
{
Table msiFileHashTable = output.EnsureTable(this.core.TableDefinitions["MsiFileHash"]);
fileRow.HashRow = msiFileHashTable.CreateRow(fileRow.SourceLineNumbers);
}
//.........这里部分代码省略.........
示例4: ResolveMspPackage
/// <summary>
/// Initializes package state from the MSP contents.
/// </summary>
/// <param name="core">BinderCore for messages.</param>
private void ResolveMspPackage(BinderCore core, Output bundle)
{
string sourcePath = this.PackagePayload.FullFileName;
try
{
// Read data out of the msp database...
using (Microsoft.Deployment.WindowsInstaller.SummaryInfo sumInfo = new Microsoft.Deployment.WindowsInstaller.SummaryInfo(sourcePath, false))
{
this.PatchCode = sumInfo.RevisionNumber.Substring(0, 38);
}
using (Microsoft.Deployment.WindowsInstaller.Database db = new Microsoft.Deployment.WindowsInstaller.Database(sourcePath))
{
if (String.IsNullOrEmpty(this.DisplayName))
{
this.DisplayName = ChainPackageInfo.GetPatchMetadataProperty(db, "DisplayName");
}
if (String.IsNullOrEmpty(this.Description))
{
this.Description = ChainPackageInfo.GetPatchMetadataProperty(db, "Description");
}
this.Manufacturer = ChainPackageInfo.GetPatchMetadataProperty(db, "ManufacturerName");
}
this.PatchXml = Microsoft.Deployment.WindowsInstaller.Installer.ExtractPatchXmlData(sourcePath);
XmlDocument doc = new XmlDocument();
doc.LoadXml(this.PatchXml);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("p", "http://www.microsoft.com/msi/patch_applicability.xsd");
foreach (XmlNode node in doc.SelectNodes("/p:MsiPatch/p:TargetProduct", nsmgr))
{
// If this patch targes a product code, this is the best case.
XmlNode targetCode = node.SelectSingleNode("p:TargetProductCode", nsmgr);
WixBundlePatchTargetCodeAttributes attributes = WixBundlePatchTargetCodeAttributes.None;
if (null != targetCode)
{
attributes = WixBundlePatchTargetCodeAttributes.TargetsProductCode;
}
else // maybe targets and upgrade code?
{
targetCode = node.SelectSingleNode("p:UpgradeCode", nsmgr);
if (null != targetCode)
{
attributes = WixBundlePatchTargetCodeAttributes.TargetsUpgradeCode;
}
else // this patch targets a unknown number of products
{
this.TargetUnspecified = true;
}
}
Table table = bundle.EnsureTable(core.TableDefinitions["WixBundlePatchTargetCode"]);
WixBundlePatchTargetCodeRow row = (WixBundlePatchTargetCodeRow)table.CreateRow(this.PackagePayload.SourceLineNumbers, false);
row.MspPackageId = this.PackagePayload.Id;
row.TargetCode = targetCode.InnerText;
row.Attributes = attributes;
if (this.TargetCodes.TryAdd(row))
{
table.Rows.Add(row);
}
}
}
catch (Microsoft.Deployment.WindowsInstaller.InstallerException e)
{
core.OnMessage(WixErrors.UnableToReadPackageInformation(this.PackagePayload.SourceLineNumbers, sourcePath, e.Message));
return;
}
if (String.IsNullOrEmpty(this.CacheId))
{
this.CacheId = this.PatchCode;
}
}
示例5: GenerateBAManifestPayloadTables
private void GenerateBAManifestPayloadTables(Output bundle, List<ChainPackageInfo> chainPackages, Dictionary<string, PayloadInfoRow> payloads)
{
Table wixPayloadPropertiesTable = bundle.EnsureTable(this.core.TableDefinitions["WixPayloadProperties"]);
foreach (ChainPackageInfo package in chainPackages)
{
PayloadInfoRow packagePayload = payloads[package.Payload];
Row payloadRow = wixPayloadPropertiesTable.CreateRow(packagePayload.SourceLineNumbers);
payloadRow[0] = packagePayload.Id;
payloadRow[1] = package.Id;
payloadRow[2] = packagePayload.Container;
payloadRow[3] = packagePayload.Name;
payloadRow[4] = packagePayload.FileSize.ToString();
payloadRow[5] = packagePayload.DownloadUrl;
payloadRow[6] = packagePayload.LayoutOnly ? "yes" : "no";
foreach (PayloadInfoRow childPayload in package.Payloads)
{
payloadRow = wixPayloadPropertiesTable.CreateRow(childPayload.SourceLineNumbers);
payloadRow[0] = childPayload.Id;
payloadRow[1] = package.Id;
payloadRow[2] = childPayload.Container;
payloadRow[3] = childPayload.Name;
payloadRow[4] = childPayload.FileSize.ToString();
payloadRow[5] = childPayload.DownloadUrl;
payloadRow[6] = childPayload.LayoutOnly ? "yes" : "no";
}
}
foreach (PayloadInfoRow payload in payloads.Values)
{
if (payload.LayoutOnly)
{
Row row = wixPayloadPropertiesTable.CreateRow(payload.SourceLineNumbers);
row[0] = payload.Id;
row[1] = null;
row[2] = payload.Container;
row[3] = payload.Name;
row[4] = payload.FileSize.ToString();
row[5] = payload.DownloadUrl;
row[6] = payload.LayoutOnly ? "yes" : "no";
}
}
}
示例6: ProcessComplexReferences
/// <summary>
/// Process the complex references.
/// </summary>
/// <param name="output">Active output to add sections to.</param>
/// <param name="sections">Sections that are referenced during the link process.</param>
/// <param name="referencedSymbols">Collection of all symbols referenced during linking.</param>
/// <param name="componentsToFeatures">Component to feature complex references.</param>
/// <param name="featuresToFeatures">Feature to feature complex references.</param>
/// <param name="modulesToFeatures">Module to feature complex references.</param>
private void ProcessComplexReferences(
Output output,
SectionCollection sections,
StringCollection referencedSymbols,
ConnectToFeatureCollection componentsToFeatures,
ConnectToFeatureCollection featuresToFeatures,
ConnectToFeatureCollection modulesToFeatures)
{
Hashtable componentsToModules = new Hashtable();
foreach (Section section in sections)
{
Table wixComplexReferenceTable = section.Tables["WixComplexReference"];
if (null != wixComplexReferenceTable)
{
foreach (WixComplexReferenceRow wixComplexReferenceRow in wixComplexReferenceTable.Rows)
{
ConnectToFeature connection;
switch (wixComplexReferenceRow.ParentType)
{
case ComplexReferenceParentType.Feature:
switch (wixComplexReferenceRow.ChildType)
{
case ComplexReferenceChildType.Component:
connection = componentsToFeatures[wixComplexReferenceRow.ChildId];
if (null == connection)
{
componentsToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.ChildId, wixComplexReferenceRow.ParentId, wixComplexReferenceRow.IsPrimary));
}
else if (wixComplexReferenceRow.IsPrimary)
{
if (connection.IsExplicitPrimaryFeature)
{
this.OnMessage(WixErrors.MultiplePrimaryReferences(section.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.ChildId, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.ParentId, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : this.activeOutput.EntrySection.Id)));
continue;
}
else
{
connection.ConnectFeatures.Add(connection.PrimaryFeature); // move the guessed primary feature to the list of connects
connection.PrimaryFeature = wixComplexReferenceRow.ParentId; // set the new primary feature
connection.IsExplicitPrimaryFeature = true; // and make sure we remember that we set it so we can fail if we try to set it again
}
}
else
{
connection.ConnectFeatures.Add(wixComplexReferenceRow.ParentId);
}
// add a row to the FeatureComponents table
Table featureComponentsTable = output.EnsureTable(this.tableDefinitions["FeatureComponents"]);
Row row = featureComponentsTable.CreateRow(null);
if (this.sectionIdOnRows)
{
row.SectionId = section.Id;
}
row[0] = wixComplexReferenceRow.ParentId;
row[1] = wixComplexReferenceRow.ChildId;
// index the component for finding orphaned records
string symbolName = String.Concat("Component:", wixComplexReferenceRow.ChildId);
if (!referencedSymbols.Contains(symbolName))
{
referencedSymbols.Add(symbolName);
}
break;
case ComplexReferenceChildType.Feature:
connection = featuresToFeatures[wixComplexReferenceRow.ChildId];
if (null != connection)
{
this.OnMessage(WixErrors.MultiplePrimaryReferences(section.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.ChildId, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.ParentId, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : this.activeOutput.EntrySection.Id)));
continue;
}
featuresToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.ChildId, wixComplexReferenceRow.ParentId, wixComplexReferenceRow.IsPrimary));
break;
case ComplexReferenceChildType.Module:
connection = modulesToFeatures[wixComplexReferenceRow.ChildId];
if (null == connection)
{
modulesToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.ChildId, wixComplexReferenceRow.ParentId, wixComplexReferenceRow.IsPrimary));
}
else if (wixComplexReferenceRow.IsPrimary)
{
if (connection.IsExplicitPrimaryFeature)
{
this.OnMessage(WixErrors.MultiplePrimaryReferences(section.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.ChildId, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.ParentId, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : this.activeOutput.EntrySection.Id)));
continue;
//.........这里部分代码省略.........
示例7: ProcessPatchXml
private void ProcessPatchXml(string sourcePath, Output bundle)
{
string patchXml = Microsoft.Deployment.WindowsInstaller.Installer.ExtractPatchXmlData(sourcePath);
XmlDocument doc = new XmlDocument();
doc.LoadXml(patchXml);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("p", "http://www.microsoft.com/msi/patch_applicability.xsd");
// Determine target ProductCodes and/or UpgradeCodes.
foreach (XmlNode node in doc.SelectNodes("/p:MsiPatch/p:TargetProduct", nsmgr))
{
// If this patch targets a product code, this is the best case.
XmlNode targetCode = node.SelectSingleNode("p:TargetProductCode", nsmgr);
WixBundlePatchTargetCodeAttributes attributes = WixBundlePatchTargetCodeAttributes.None;
if (ChainPackageInfo.TargetsCode(targetCode))
{
attributes = WixBundlePatchTargetCodeAttributes.TargetsProductCode;
}
else // maybe targets an upgrade code?
{
targetCode = node.SelectSingleNode("p:UpgradeCode", nsmgr);
if (ChainPackageInfo.TargetsCode(targetCode))
{
attributes = WixBundlePatchTargetCodeAttributes.TargetsUpgradeCode;
}
else // this patch targets an unknown number of products
{
this.TargetUnspecified = true;
}
}
Table table = bundle.EnsureTable(this.core.TableDefinitions["WixBundlePatchTargetCode"]);
WixBundlePatchTargetCodeRow row = (WixBundlePatchTargetCodeRow)table.CreateRow(this.PackagePayload.SourceLineNumbers, false);
row.MspPackageId = this.PackagePayload.Id;
row.TargetCode = targetCode.InnerText;
row.Attributes = attributes;
if (this.TargetCodes.TryAdd(row))
{
table.Rows.Add(row);
}
}
// Suppress patch sequence data for improved performance.
if (this.core.GetProperty<bool>(Binder.PARAM_SPSD_NAME))
{
XmlNode root = doc.DocumentElement;
foreach (XmlNode node in root.SelectNodes("p:SequenceData", nsmgr))
{
root.RemoveChild(node);
}
}
// Save the XML as compact as possible.
using (StringWriter writer = new StringWriter())
{
XmlWriterSettings settings = new XmlWriterSettings()
{
Encoding = ChainPackageInfo.XmlOutputEncoding,
Indent = false,
NewLineChars = string.Empty,
NewLineHandling = NewLineHandling.Replace,
};
using (XmlWriter xmlWriter = XmlWriter.Create(writer, settings))
{
doc.WriteTo(xmlWriter);
}
this.PatchXml = writer.ToString();
}
}
示例8: CopyTransformData
/// <summary>
/// Copy file data between transform substorages and the patch output object
/// </summary>
/// <param name="output">The output to bind.</param>
/// <param name="allFileRows">True if copying from transform to patch, false the other way.</param>
/// <returns>true if binding completed successfully; false otherwise</returns>
private bool CopyTransformData(Output output, FileRowCollection allFileRows)
{
bool copyToPatch = (allFileRows != null);
bool copyFromPatch = !copyToPatch;
if (OutputType.Patch != output.Type)
{
return true;
}
Hashtable patchMediaRows = new Hashtable();
Hashtable patchMediaFileRows = new Hashtable();
Table patchFileTable = output.EnsureTable(this.core.TableDefinitions["File"]);
if (copyFromPatch)
{
// index patch files by diskId+fileId
foreach (FileRow patchFileRow in patchFileTable.Rows)
{
int diskId = patchFileRow.DiskId;
if (!patchMediaFileRows.Contains(diskId))
{
patchMediaFileRows[diskId] = new FileRowCollection();
}
FileRowCollection mediaFileRows = (FileRowCollection)patchMediaFileRows[diskId];
mediaFileRows.Add(patchFileRow);
}
Table patchMediaTable = output.EnsureTable(this.core.TableDefinitions["Media"]);
foreach (MediaRow patchMediaRow in patchMediaTable.Rows)
{
patchMediaRows[patchMediaRow.DiskId] = patchMediaRow;
}
}
// index paired transforms
Hashtable pairedTransforms = new Hashtable();
foreach (SubStorage substorage in output.SubStorages)
{
if ("#" == substorage.Name.Substring(0, 1))
{
pairedTransforms[substorage.Name.Substring(1)] = substorage.Data;
}
}
try
{
// copy File bind data into substorages
foreach (SubStorage substorage in output.SubStorages)
{
if ("#" == substorage.Name.Substring(0, 1))
{
// no changes necessary for paired transforms
continue;
}
Output mainTransform = (Output)substorage.Data;
Table mainWixFileTable = mainTransform.Tables["WixFile"];
Table mainMsiFileHashTable = mainTransform.Tables["MsiFileHash"];
int numWixFileRows = (null != mainWixFileTable) ? mainWixFileTable.Rows.Count : 0;
int numMsiFileHashRows = (null != mainMsiFileHashTable) ? mainMsiFileHashTable.Rows.Count : 0;
this.FileManager.ActiveSubStorage = substorage;
Hashtable wixFiles = new Hashtable(numWixFileRows);
Hashtable mainMsiFileHashIndex = new Hashtable(numMsiFileHashRows);
Table mainFileTable = mainTransform.Tables["File"];
Output pairedTransform = (Output)pairedTransforms[substorage.Name];
if (null != mainWixFileTable)
{
// Index the WixFile table for later use.
foreach (WixFileRow row in mainWixFileTable.Rows)
{
wixFiles.Add(row.Fields[0].Data.ToString(), row);
}
}
// copy Media.LastSequence and index the MsiFileHash table if it exists.
if (copyFromPatch)
{
Table pairedMediaTable = pairedTransform.Tables["Media"];
foreach (MediaRow pairedMediaRow in pairedMediaTable.Rows)
{
MediaRow patchMediaRow = (MediaRow)patchMediaRows[pairedMediaRow.DiskId];
pairedMediaRow.Fields[1] = patchMediaRow.Fields[1];
}
if (null != mainMsiFileHashTable)
{
// Index the MsiFileHash table for later use.
foreach (Row row in mainMsiFileHashTable.Rows)
{
mainMsiFileHashIndex.Add(row[0], row);
}
}
//.........这里部分代码省略.........
示例9: CreateCabinetWorkItem
/// <summary>
/// Creates a work item to create a cabinet.
/// </summary>
/// <param name="output">Output for the current database.</param>
/// <param name="cabinetDir">Directory to create cabinet in.</param>
/// <param name="mediaRow">MediaRow containing information about the cabinet.</param>
/// <param name="fileRows">Collection of files in this cabinet.</param>
/// <param name="fileTransfers">Array of files to be transfered.</param>
/// <returns>created CabinetWorkItem object</returns>
private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaRow mediaRow, FileRowCollection fileRows, ArrayList fileTransfers)
{
CabinetWorkItem cabinetWorkItem = null;
string tempCabinetFile = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet);
// check for an empty cabinet
if (0 == fileRows.Count)
{
string cabinetName = mediaRow.Cabinet;
// remove the leading '#' from the embedded cabinet name to make the warning easier to understand
if (cabinetName.StartsWith("#", StringComparison.Ordinal))
{
cabinetName = cabinetName.Substring(1);
}
// If building a patch, remind them to run -p for torch.
if (OutputType.Patch == output.Type)
{
this.core.OnMessage(WixWarnings.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true));
}
else
{
this.core.OnMessage(WixWarnings.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName));
}
}
CabinetBuildOption cabinetBuildOption = this.FileManager.ResolveCabinet(fileRows, ref tempCabinetFile);
// create a cabinet work item if it's not being skipped
if (CabinetBuildOption.BuildAndCopy == cabinetBuildOption || CabinetBuildOption.BuildAndMove == cabinetBuildOption)
{
int maxThreshold = 0; // default to the threshold for best smartcabbing (makes smallest cabinet).
Cab.CompressionLevel compressionLevel = this.defaultCompressionLevel;
if (mediaRow.HasExplicitCompressionLevel)
{
compressionLevel = mediaRow.CompressionLevel;
}
cabinetWorkItem = new CabinetWorkItem(fileRows, tempCabinetFile, maxThreshold, compressionLevel, this.FileManager);
}
else // reuse the cabinet from the cabinet cache.
{
this.core.OnMessage(WixVerboses.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, tempCabinetFile));
try
{
// Ensure the cached cabinet timestamp is current to prevent perpetual incremental builds. The
// problematic scenario goes like this. Imagine two cabinets in the cache. Update a file that
// goes into one of the cabinets. One cabinet will get rebuilt, the other will be copied from
// the cache. Now the file (an input) has a newer timestamp than the reused cabient (an output)
// causing the project to look like it perpetually needs a rebuild until all of the reused
// cabinets get newer timestamps.
File.SetLastWriteTime(tempCabinetFile, DateTime.Now);
}
catch (Exception e)
{
this.core.OnMessage(WixWarnings.CannotUpdateCabCache(mediaRow.SourceLineNumbers, tempCabinetFile, e.Message));
}
}
if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal))
{
Table streamsTable = output.EnsureTable(this.core.TableDefinitions["_Streams"]);
Row streamRow = streamsTable.CreateRow(null);
streamRow[0] = mediaRow.Cabinet.Substring(1);
streamRow[1] = tempCabinetFile;
}
else
{
string destinationPath = Path.Combine(cabinetDir, mediaRow.Cabinet);
FileTransfer transfer;
if (FileTransfer.TryCreate(tempCabinetFile, destinationPath, CabinetBuildOption.BuildAndMove == cabinetBuildOption, "Cabinet", mediaRow.SourceLineNumbers, out transfer))
{
transfer.Built = true;
fileTransfers.Add(transfer);
}
}
return cabinetWorkItem;
}
示例10: BindDatabase
//.........这里部分代码省略.........
autoMediaAssigner.AssignFiles(fileRows);
// update file version, hash, assembly, etc.. information
this.core.OnMessage(WixVerboses.UpdatingFileInformation());
Hashtable indexedFileRows = this.UpdateFileInformation(output, fileRows, autoMediaAssigner.MediaRows, variableCache, modularizationGuid);
// set generated component guids
this.SetComponentGuids(output);
// With the Component Guids set now we can create instance transforms.
this.CreateInstanceTransforms(output);
this.ValidateComponentGuids(output);
this.UpdateControlText(output);
if (0 < delayedFields.Count)
{
this.ResolveDelayedFields(output, delayedFields, variableCache, modularizationGuid);
}
// stop processing if an error previously occurred
if (this.core.EncounteredError)
{
return false;
}
// Extended binder extensions can be called now that fields are resolved.
foreach (BinderExtension extension in this.extensions)
{
BinderExtensionEx extensionEx = extension as BinderExtensionEx;
if (null != extensionEx)
{
output.EnsureTable(this.core.TableDefinitions["WixBindUpdatedFiles"]);
extensionEx.DatabaseAfterResolvedFields(output);
}
}
Table updatedFiles = output.Tables["WixBindUpdatedFiles"];
if (null != updatedFiles)
{
foreach (Row updatedFile in updatedFiles.Rows)
{
FileRow updatedFileRow = (FileRow)indexedFileRows[updatedFile[0]];
this.UpdateFileRow(output, null, modularizationGuid, indexedFileRows, updatedFileRow, true);
}
}
// stop processing if an error previously occurred
if (this.core.EncounteredError)
{
return false;
}
// create cabinet files and process uncompressed files
string layoutDirectory = Path.GetDirectoryName(databaseFile);
FileRowCollection uncompressedFileRows = null;
if (!this.suppressLayout || OutputType.Module == output.Type)
{
this.core.OnMessage(WixVerboses.CreatingCabinetFiles());
uncompressedFileRows = this.CreateCabinetFiles(output, fileRows, this.fileTransfers, autoMediaAssigner.MediaRows, layoutDirectory, compressed, autoMediaAssigner);
}
if (OutputType.Patch == output.Type)
{
// copy output data back into the transforms
示例11: BindTransform
/// <summary>
/// Binds a transform.
/// </summary>
/// <param name="transform">The transform to bind.</param>
/// <param name="transformFile">The transform to create.</param>
/// <returns>true if binding completed successfully; false otherwise</returns>
private bool BindTransform(Output transform, string transformFile)
{
foreach (BinderExtension extension in this.extensions)
{
extension.TransformInitialize(transform);
}
int transformFlags = 0;
Output targetOutput = new Output(null);
Output updatedOutput = new Output(null);
// TODO: handle added columns
// to generate a localized transform, both the target and updated
// databases need to have the same code page. the only reason to
// set different code pages is to support localized primary key
// columns, but that would only support deleting rows. if this
// becomes necessary, define a PreviousCodepage property on the
// Output class and persist this throughout transform generation.
targetOutput.Codepage = transform.Codepage;
updatedOutput.Codepage = transform.Codepage;
// remove certain Property rows which will be populated from summary information values
string targetUpgradeCode = null;
string updatedUpgradeCode = null;
Table propertyTable = transform.Tables["Property"];
if (null != propertyTable)
{
for (int i = propertyTable.Rows.Count - 1; i >= 0; i--)
{
Row row = propertyTable.Rows[i];
if ("ProductCode" == (string)row[0] || "ProductLanguage" == (string)row[0] || "ProductVersion" == (string)row[0] || "UpgradeCode" == (string)row[0])
{
propertyTable.Rows.RemoveAt(i);
if ("UpgradeCode" == (string)row[0])
{
updatedUpgradeCode = (string)row[1];
}
}
}
}
Table targetSummaryInfo = targetOutput.EnsureTable(this.core.TableDefinitions["_SummaryInformation"]);
Table updatedSummaryInfo = updatedOutput.EnsureTable(this.core.TableDefinitions["_SummaryInformation"]);
Table targetPropertyTable = targetOutput.EnsureTable(this.core.TableDefinitions["Property"]);
Table updatedPropertyTable = updatedOutput.EnsureTable(this.core.TableDefinitions["Property"]);
string targetProductCode = null;
// process special summary information values
foreach (Row row in transform.Tables["_SummaryInformation"].Rows)
{
if ((int)SummaryInformation.Transform.CodePage == (int)row[0])
{
// convert from a web name if provided
string codePage = (string)row.Fields[1].Data;
if (null == codePage)
{
codePage = "0";
}
else
{
codePage = Common.GetValidCodePage(codePage).ToString(CultureInfo.InvariantCulture);
}
string previousCodePage = (string)row.Fields[1].PreviousData;
if (null == previousCodePage)
{
previousCodePage = "0";
}
else
{
previousCodePage = Common.GetValidCodePage(previousCodePage).ToString(CultureInfo.InvariantCulture);
}
Row targetCodePageRow = targetSummaryInfo.CreateRow(null);
targetCodePageRow[0] = 1; // PID_CODEPAGE
targetCodePageRow[1] = previousCodePage;
Row updatedCodePageRow = updatedSummaryInfo.CreateRow(null);
updatedCodePageRow[0] = 1; // PID_CODEPAGE
updatedCodePageRow[1] = codePage;
}
else if ((int)SummaryInformation.Transform.TargetPlatformAndLanguage == (int)row[0] ||
(int)SummaryInformation.Transform.UpdatedPlatformAndLanguage == (int)row[0])
{
// the target language
string[] propertyData = ((string)row[1]).Split(';');
string lang = 2 == propertyData.Length ? propertyData[1] : "0";
//.........这里部分代码省略.........
示例12: BindBundle
//.........这里部分代码省略.........
// localize fields, resolve wix variables, and resolve file paths
this.ResolveFields(bundle.Tables, cabinets, delayedFields);
// if there are any fields to resolve later, create the cache to populate during bind
IDictionary<string, string> variableCache = null;
if (0 < delayedFields.Count)
{
variableCache = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
}
if (this.core.EncounteredError)
{
return false;
}
Table relatedBundleTable = bundle.Tables["RelatedBundle"];
List<RelatedBundleInfo> allRelatedBundles = new List<RelatedBundleInfo>();
if (null != relatedBundleTable && 0 < relatedBundleTable.Rows.Count)
{
Dictionary<string, bool> deduplicatedRelatedBundles = new Dictionary<string, bool>();
foreach (Row row in relatedBundleTable.Rows)
{
string id = (string)row[0];
if (!deduplicatedRelatedBundles.ContainsKey(id))
{
deduplicatedRelatedBundles[id] = true;
allRelatedBundles.Add(new RelatedBundleInfo(row));
}
}
}
// Ensure that the bundle has our well-known persisted values.
Table variableTable = bundle.EnsureTable(this.core.TableDefinitions["Variable"]);
VariableRow bundleNameWellKnownVariable = (VariableRow)variableTable.CreateRow(null);
bundleNameWellKnownVariable.Id = Binder.BURN_BUNDLE_NAME;
bundleNameWellKnownVariable.Hidden = false;
bundleNameWellKnownVariable.Persisted = true;
VariableRow bundleOriginalSourceWellKnownVariable = (VariableRow)variableTable.CreateRow(null);
bundleOriginalSourceWellKnownVariable.Id = Binder.BURN_BUNDLE_ORIGINAL_SOURCE;
bundleOriginalSourceWellKnownVariable.Hidden = false;
bundleOriginalSourceWellKnownVariable.Persisted = true;
VariableRow bundleOriginalSourceFolderWellKnownVariable = (VariableRow)variableTable.CreateRow(null);
bundleOriginalSourceFolderWellKnownVariable.Id = Binder.BURN_BUNDLE_ORIGINAL_SOURCE_FOLDER;
bundleOriginalSourceFolderWellKnownVariable.Hidden = false;
bundleOriginalSourceFolderWellKnownVariable.Persisted = true;
VariableRow bundleLastUsedSourceWellKnownVariable = (VariableRow)variableTable.CreateRow(null);
bundleLastUsedSourceWellKnownVariable.Id = Binder.BURN_BUNDLE_LAST_USED_SOURCE;
bundleLastUsedSourceWellKnownVariable.Hidden = false;
bundleLastUsedSourceWellKnownVariable.Persisted = true;
// To make lookups easier, we load the variable table bottom-up, so
// that we can index by ID.
List<VariableInfo> allVariables = new List<VariableInfo>(variableTable.Rows.Count);
foreach (VariableRow variableRow in variableTable.Rows)
{
allVariables.Add(new VariableInfo(variableRow));
}
// TODO: Although the WixSearch tables are defined in the Util extension,
// the Bundle Binder has to know all about them. We hope to revisit all
// of this in the 4.0 timeframe.
Dictionary<string, WixSearchInfo> allSearches = new Dictionary<string, WixSearchInfo>();
示例13: AutomaticallySlipstreamPatches
private void AutomaticallySlipstreamPatches(Output bundle, ICollection<ChainPackageInfo> packages)
{
List<ChainPackageInfo> msiPackages = new List<ChainPackageInfo>();
Dictionary<string, List<WixBundlePatchTargetCodeRow>> targetsProductCode = new Dictionary<string, List<WixBundlePatchTargetCodeRow>>();
Dictionary<string, List<WixBundlePatchTargetCodeRow>> targetsUpgradeCode = new Dictionary<string, List<WixBundlePatchTargetCodeRow>>();
foreach (ChainPackageInfo package in packages)
{
if (Compiler.ChainPackageType.Msi == package.ChainPackageType)
{
// Keep track of all MSI packages.
msiPackages.Add(package);
}
else if (Compiler.ChainPackageType.Msp == package.ChainPackageType && package.Slipstream)
{
// Index target ProductCodes and UpgradeCodes for slipstreamed MSPs.
foreach (WixBundlePatchTargetCodeRow row in package.TargetCodes)
{
if (row.TargetsProductCode)
{
List<WixBundlePatchTargetCodeRow> rows;
if (!targetsProductCode.TryGetValue(row.TargetCode, out rows))
{
rows = new List<WixBundlePatchTargetCodeRow>();
targetsProductCode.Add(row.TargetCode, rows);
}
rows.Add(row);
}
else if (row.TargetsUpgradeCode)
{
List<WixBundlePatchTargetCodeRow> rows;
if (!targetsUpgradeCode.TryGetValue(row.TargetCode, out rows))
{
rows = new List<WixBundlePatchTargetCodeRow>();
targetsUpgradeCode.Add(row.TargetCode, rows);
}
}
}
}
}
Table slipstreamMspTable = bundle.EnsureTable(this.core.TableDefinitions["SlipstreamMsp"]);
RowDictionary<Row> slipstreamMspRows = new RowDictionary<Row>(slipstreamMspTable);
// Loop through the MSI and slipstream patches targeting it.
foreach (ChainPackageInfo msi in msiPackages)
{
List<WixBundlePatchTargetCodeRow> rows;
if (targetsProductCode.TryGetValue(msi.ProductCode, out rows))
{
foreach (WixBundlePatchTargetCodeRow row in rows)
{
Row slipstreamMspRow = slipstreamMspTable.CreateRow(row.SourceLineNumbers, false);
slipstreamMspRow[0] = msi.Id;
slipstreamMspRow[1] = row.MspPackageId;
if (slipstreamMspRows.TryAdd(slipstreamMspRow))
{
slipstreamMspTable.Rows.Add(slipstreamMspRow);
}
}
rows = null;
}
if (!String.IsNullOrEmpty(msi.UpgradeCode) && targetsUpgradeCode.TryGetValue(msi.UpgradeCode, out rows))
{
foreach (WixBundlePatchTargetCodeRow row in rows)
{
Row slipstreamMspRow = slipstreamMspTable.CreateRow(row.SourceLineNumbers, false);
slipstreamMspRow[0] = msi.Id;
slipstreamMspRow[1] = row.MspPackageId;
if (slipstreamMspRows.TryAdd(slipstreamMspRow))
{
slipstreamMspTable.Rows.Add(slipstreamMspRow);
}
}
rows = null;
}
}
}
示例14: AddPatchFilesActionToSequenceTable
/// <summary>
/// Adds the PatchFiles action to the sequence table if it does not already exist.
/// </summary>
/// <param name="table">The sequence table to check or modify.</param>
/// <param name="mainTransform">The primary authoring transform.</param>
/// <param name="pairedTransform">The secondary patch transform.</param>
/// <param name="mainFileRow">The file row that contains information about the patched file.</param>
private void AddPatchFilesActionToSequenceTable(SequenceTable table, Output mainTransform, Output pairedTransform, Row mainFileRow)
{
// Find/add PatchFiles action (also determine sequence for it).
// Search mainTransform first, then pairedTransform (pairedTransform overrides).
bool hasPatchFilesAction = false;
int seqInstallFiles = 0;
int seqDuplicateFiles = 0;
string tableName = table.ToString();
TestSequenceTableForPatchFilesAction(
mainTransform.Tables[tableName],
ref hasPatchFilesAction,
ref seqInstallFiles,
ref seqDuplicateFiles);
TestSequenceTableForPatchFilesAction(
pairedTransform.Tables[tableName],
ref hasPatchFilesAction,
ref seqInstallFiles,
ref seqDuplicateFiles);
if (!hasPatchFilesAction)
{
Table iesTable = pairedTransform.EnsureTable(this.core.TableDefinitions[tableName]);
if (0 == iesTable.Rows.Count)
{
iesTable.Operation = TableOperation.Add;
}
Row patchAction = iesTable.CreateRow(null);
WixActionRow wixPatchAction = Installer.GetStandardActions()[table, "PatchFiles"];
int sequence = wixPatchAction.Sequence;
// Test for default sequence value's appropriateness
if (seqInstallFiles >= sequence || (0 != seqDuplicateFiles && seqDuplicateFiles <= sequence))
{
if (0 != seqDuplicateFiles)
{
if (seqDuplicateFiles < seqInstallFiles)
{
throw new WixException(WixErrors.InsertInvalidSequenceActionOrder(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action));
}
else
{
sequence = (seqDuplicateFiles + seqInstallFiles) / 2;
if (seqInstallFiles == sequence || seqDuplicateFiles == sequence)
{
throw new WixException(WixErrors.InsertSequenceNoSpace(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action));
}
}
}
else
{
sequence = seqInstallFiles + 1;
}
}
patchAction[0] = wixPatchAction.Action;
patchAction[1] = wixPatchAction.Condition;
patchAction[2] = sequence;
patchAction.Operation = RowOperation.Add;
}
}
示例15: GenerateDatabase
/// <summary>
/// Creates the MSI/MSM/PCP database.
/// </summary>
/// <param name="output">Output to create database for.</param>
/// <param name="databaseFile">The database file to create.</param>
/// <param name="keepAddedColumns">Whether to keep columns added in a transform.</param>
/// <param name="useSubdirectory">Whether to use a subdirectory based on the <paramref name="databaseFile"/> file name for intermediate files.</param>
internal void GenerateDatabase(Output output, string databaseFile, bool keepAddedColumns, bool useSubdirectory)
{
// add the _Validation rows
if (!this.suppressAddingValidationRows)
{
Table validationTable = output.EnsureTable(this.core.TableDefinitions["_Validation"]);
foreach (Table table in output.Tables)
{
if (!table.Definition.IsUnreal)
{
// add the validation rows for this table
table.Definition.AddValidationRows(validationTable);
}
}
}
// set the base directory
string baseDirectory = this.TempFilesLocation;
if (useSubdirectory)
{
string filename = Path.GetFileNameWithoutExtension(databaseFile);
baseDirectory = Path.Combine(baseDirectory, filename);
// make sure the directory exists
Directory.CreateDirectory(baseDirectory);
}
try
{
OpenDatabase type = OpenDatabase.CreateDirect;
// set special flag for patch files
if (OutputType.Patch == output.Type)
{
type |= OpenDatabase.OpenPatchFile;
}
// try to create the database
using (Database db = new Database(databaseFile, type))
{
// localize the codepage if a value was specified by the localizer
if (null != this.Localizer && -1 != this.Localizer.Codepage)
{
output.Codepage = this.Localizer.Codepage;
}
// if we're not using the default codepage, import a new one into our
// database before we add any tables (or the tables would be added
// with the wrong codepage)
if (0 != output.Codepage)
{
this.SetDatabaseCodepage(db, output);
}
// insert substorages (like transforms inside a patch)
if (0 < output.SubStorages.Count)
{
using (View storagesView = new View(db, "SELECT `Name`, `Data` FROM `_Storages`"))
{
foreach (SubStorage subStorage in output.SubStorages)
{
string transformFile = Path.Combine(this.TempFilesLocation, String.Concat(subStorage.Name, ".mst"));
// bind the transform
if (this.BindTransform(subStorage.Data, transformFile))
{
// add the storage
using (Record record = new Record(2))
{
record.SetString(1, subStorage.Name);
record.SetStream(2, transformFile);
storagesView.Modify(ModifyView.Assign, record);
}
}
}
}
// some empty transforms may have been excluded
// we need to remove these from the final patch summary information
if (OutputType.Patch == output.Type && this.AllowEmptyTransforms)
{
Table patchSummaryInfo = output.EnsureTable(this.core.TableDefinitions["_SummaryInformation"]);
for (int i = patchSummaryInfo.Rows.Count - 1; i >= 0; i--)
{
Row row = patchSummaryInfo.Rows[i];
if ((int)SummaryInformation.Patch.ProductCodes == (int)row[0])
{
if (nonEmptyProductCodes.Count > 0)
{
string[] productCodes = new string[nonEmptyProductCodes.Count];
nonEmptyProductCodes.CopyTo(productCodes, 0);
row[1] = String.Join(";", productCodes);
//.........这里部分代码省略.........