本文整理汇总了C#中Microsoft.Build.BuildEngine.Engine.RegisterDistributedLogger方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.RegisterDistributedLogger方法的具体用法?C# Engine.RegisterDistributedLogger怎么用?C# Engine.RegisterDistributedLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.Engine
的用法示例。
在下文中一共展示了Engine.RegisterDistributedLogger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// We need to tell MSBuild where msbuild.exe is, so it can launch child nodes
string parameters = @"MSBUILDLOCATION=" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.System) + @"\..\Microsoft.NET\Framework\v3.5";
// We need to tell MSBuild whether nodes should hang around for 60 seconds after the build is done in case they are needed again
bool nodeReuse = true; // e.g.
if (!nodeReuse)
{
parameters += ";NODEREUSE=false";
}
// We need to tell MSBuild the maximum number of nodes to use. It is usually fastest to pick about the same number as you have CPU cores
int maxNodeCount = 3; // e.g.
// Create the engine with this information
Engine buildEngine = new Engine(null, ToolsetDefinitionLocations.Registry | ToolsetDefinitionLocations.ConfigurationFile, maxNodeCount, parameters);
// Create a file logger with a matching forwarding logger, e.g.
FileLogger fileLogger = new FileLogger();
fileLogger.Verbosity = LoggerVerbosity.Detailed;
Assembly engineAssembly = Assembly.GetAssembly(typeof(Engine));
string loggerAssemblyName = engineAssembly.GetName().FullName;
LoggerDescription fileLoggerForwardingLoggerDescription = new LoggerDescription("Microsoft.Build.BuildEngine.ConfigurableForwardingLogger", loggerAssemblyName, null, String.Empty, LoggerVerbosity.Detailed);
// Create a regular console logger too, e.g.
ConsoleLogger logger = new ConsoleLogger();
logger.Verbosity = LoggerVerbosity.Normal;
// Register all of these loggers
buildEngine.RegisterDistributedLogger(fileLogger, fileLoggerForwardingLoggerDescription);
buildEngine.RegisterLogger(logger);
// Do a build
buildEngine.BuildProjectFile("root.proj");
// Finish cleanly
buildEngine.Shutdown();
}
示例2: BuildProjectFilesInParallel
public void BuildProjectFilesInParallel()
{
//Gets the currently loaded assembly in which the specified class is defined
Assembly engineAssembly = Assembly.GetAssembly(typeof(Engine));
string loggerClassName = "Microsoft.Build.BuildEngine.ConfigurableForwardingLogger";
string loggerAssemblyName = engineAssembly.GetName().FullName;
LoggerDescription forwardingLoggerDescription = new LoggerDescription(loggerClassName, loggerAssemblyName, null, null, LoggerVerbosity.Normal);
string[] fileNames = new string[10];
string traversalProject = TraversalProjectFile("ABC");
string[][] targetNamesPerProject = new string[fileNames.Length][];
IDictionary[] targetOutPutsPerProject = new IDictionary[fileNames.Length];
BuildPropertyGroup[] globalPropertiesPerProject = new BuildPropertyGroup[fileNames.Length];
string[] tempfilesToDelete = new string[fileNames.Length];
Engine engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+AppDomain.CurrentDomain.BaseDirectory);
engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
try
{
for (int i = 0; i < fileNames.Length; i++)
{
string[] ProjectFiles1 = CreateGlobalPropertyProjectFileWithExtension("ABC");
fileNames[i] = ProjectFiles1[0];
tempfilesToDelete[i] = ProjectFiles1[1];
targetNamesPerProject[i] = new string[] { "Build" };
}
// Test building a traversal
engine.BuildProjectFile(traversalProject);
engine.Shutdown();
// Test building the same set of files in parallel
Console.Out.WriteLine("1:"+Process.GetCurrentProcess().MainModule.FileName);
Console.Out.WriteLine("2:" + AppDomain.CurrentDomain.BaseDirectory);
engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
engine.RegisterDistributedLogger(new ConsoleLogger(LoggerVerbosity.Normal), forwardingLoggerDescription);
engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
engine.Shutdown();
// Do the same using singleproc
engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
engine.BuildProjectFile(traversalProject);
engine.Shutdown();
engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 1, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
}
finally
{
engine.Shutdown();
for (int i = 0; i < fileNames.Length; i++)
{
File.Delete(fileNames[i]);
File.Delete(tempfilesToDelete[i]);
}
File.Delete(traversalProject);
}
}