本文整理汇总了C#中Compiler.AddExtension方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.AddExtension方法的具体用法?C# Compiler.AddExtension怎么用?C# Compiler.AddExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compiler
的用法示例。
在下文中一共展示了Compiler.AddExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// Main running method for the application.
/// </summary>
/// <param name="args">Commandline arguments to the application.</param>
/// <returns>Returns the application error code.</returns>
private int Run(string[] args)
{
try
{
// parse the command line
this.ParseCommandLine(args);
// exit if there was an error parsing the command line (otherwise the logo appears after error messages)
if (this.messageHandler.EncounteredError)
{
return this.messageHandler.LastErrorNumber;
}
if (!this.fipsCompliant)
{
try
{
System.Security.Cryptography.MD5.Create();
}
catch (TargetInvocationException)
{
this.messageHandler.Display(this, WixErrors.UseFipsArgument());
return this.messageHandler.LastErrorNumber;
}
}
if (0 == this.sourceFiles.Count)
{
this.showHelp = true;
}
else if (1 < this.sourceFiles.Count && null != this.outputFile)
{
throw new ArgumentException(CandleStrings.CannotSpecifyMoreThanOneSourceFileForSingleTargetFile, "-out");
}
if (this.showLogo)
{
AppCommon.DisplayToolHeader();
}
if (this.showHelp)
{
Console.WriteLine(CandleStrings.HelpMessage);
AppCommon.DisplayToolFooter();
return this.messageHandler.LastErrorNumber;
}
foreach (string parameter in this.invalidArgs)
{
this.messageHandler.Display(this, WixWarnings.UnsupportedCommandLineArgument(parameter));
}
this.invalidArgs = null;
// create the preprocessor and compiler
Preprocessor preprocessor = new Preprocessor();
preprocessor.Message += new MessageEventHandler(this.messageHandler.Display);
for (int i = 0; i < this.includeSearchPaths.Count; ++i)
{
preprocessor.IncludeSearchPaths.Add(this.includeSearchPaths[i]);
}
preprocessor.CurrentPlatform = this.platform;
Compiler compiler = new Compiler();
compiler.Message += new MessageEventHandler(this.messageHandler.Display);
compiler.SuppressFilesVitalByDefault = this.suppressFilesVitalByDefault;
compiler.ShowPedanticMessages = this.showPedanticMessages;
compiler.SuppressValidate = this.suppressSchema;
compiler.CurrentPlatform = this.platform;
compiler.FipsCompliant = this.fipsCompliant;
// load any extensions
foreach (string extension in this.extensionList)
{
WixExtension wixExtension = WixExtension.Load(extension);
preprocessor.AddExtension(wixExtension);
compiler.AddExtension(wixExtension);
}
// preprocess then compile each source file
Dictionary<string, List<string>> sourcesForOutput = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
foreach (string sourceFileOrig in this.sourceFiles)
{
string sourceFile = sourceFileOrig;
string targetFile = null;
if (this.allowPerSourceOutputSpecification)
{
string[] parts = sourceFileOrig.Split(Candle.sourceOutputSeparator, 2);
if (2 == parts.Length)
{
sourceFile = parts[0];
targetFile = parts[1];
}
}
//.........这里部分代码省略.........
示例2: Run
//.........这里部分代码省略.........
Console.WriteLine(" .msi - Windows installer Product Database");
Console.WriteLine(" .mst - Windows installer Transform");
Console.WriteLine(" .pcp - Windows installer Patch Creation Package");
Console.WriteLine();
Console.WriteLine("For more information see: http://wix.sourceforge.net");
return this.messageHandler.PostProcess();
}
// create the preprocessor and compiler
Preprocessor preprocessor = new Preprocessor();
preprocessor.Message += new MessageEventHandler(this.messageHandler.Display);
for (int i = 0; i < this.includeSearchPaths.Count; ++i)
{
preprocessor.IncludeSearchPaths.Add(this.includeSearchPaths[i]);
}
Compiler compiler = new Compiler(this.useSmallTables);
compiler.Message += new MessageEventHandler(this.messageHandler.Display);
compiler.PedanticLevel = this.pedanticLevel;
compiler.SuppressValidate = this.suppressSchema;
// load any extensions
foreach (string extension in this.extensionList)
{
Type extensionType = Type.GetType(extension);
if (null == extensionType)
{
throw new WixInvalidExtensionException(extension);
}
if (extensionType.IsSubclassOf(typeof(PreprocessorExtension)))
{
preprocessor.AddExtension((PreprocessorExtension)Activator.CreateInstance(extensionType));
}
if (extensionType.IsSubclassOf(typeof(CompilerExtension)))
{
CompilerExtension compilerExtensionObject = Activator.CreateInstance(extensionType) as CompilerExtension;
compiler.AddExtension(compilerExtensionObject);
}
if (!extensionType.IsSubclassOf(typeof(PreprocessorExtension)) && !extensionType.IsSubclassOf(typeof(CompilerExtension)))
{
throw new WixInvalidExtensionException(extension);
}
}
// preprocess then compile each source file
foreach (FileInfo sourceFile in this.sourceFiles)
{
currentFile = sourceFile; // point at the file we're working on in case a exception is thrown
FileInfo targetFile;
if (null != this.outputFile)
{
targetFile = this.outputFile;
}
else if (null != this.outputDirectory)
{
targetFile = new FileInfo(String.Concat(this.outputDirectory.FullName, Path.ChangeExtension(currentFile.Name, ".wixobj")));
}
else
{
targetFile = new FileInfo(Path.ChangeExtension(currentFile.Name, ".wixobj"));
}