当前位置: 首页>>代码示例>>C#>>正文


C# Engine.RegisterLogger方法代码示例

本文整理汇总了C#中Microsoft.Build.BuildEngine.Engine.RegisterLogger方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.RegisterLogger方法的具体用法?C# Engine.RegisterLogger怎么用?C# Engine.RegisterLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.BuildEngine.Engine的用法示例。


在下文中一共展示了Engine.RegisterLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterConsoleLogger

 protected override void RegisterConsoleLogger(Engine engine, string workingPath)
 {
     engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Minimal));
     // TODO: implement FileLogger in mono, reenable this
     var logger = new FileLogger();
     logger.Parameters = String.Format(@"logfile={0}", Path.Combine(workingPath, "compile.log"));
     logger.Verbosity = LoggerVerbosity.Minimal; // Normal, Detailed;
     engine.RegisterLogger(logger);
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:9,代码来源:MsBuildCompiler.cs

示例2: BuildRunner

 public BuildRunner(BuilderSetup setup)
 {
     this.setup = setup;
       engine = new Engine();
       if (setup.LoggerType != null)
       {
     var logger = (ILogger) Activator.CreateInstance(setup.LoggerAsType);
     engine.RegisterLogger(logger);
       }
       engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
 }
开发者ID:flq,项目名称:rfb,代码行数:11,代码来源:BuildRunner.cs

示例3: MSBuildEngineWorker

		internal MSBuildEngineWorker(MSBuildEngine parentEngine, MSBuildEngine.BuildRun buildRun)
		{
			this.parentEngine = parentEngine;
			this.buildRun = buildRun;
			engine = buildRun.CreateEngine();
			
			logger = new SharpDevelopLogger(this);
			engine.RegisterLogger(logger);
			foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) {
				engine.RegisterLogger(loggerProvider.CreateLogger(this));
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:12,代码来源:MSBuildEngineWorker.cs

示例4: Build

        public static bool Build(Project pProj, OutputWindowPane pPane, string pTarget, NameValueCollection pParams)
        {
            Microsoft.Build.BuildEngine.Engine buildEngine = new Microsoft.Build.BuildEngine.Engine();
              BuildExecutor executor = new BuildExecutor(pPane);

              RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework", false);
              if (key == null) {
            throw new Exception("Failed to determine .NET Framework install root - no .NETFramework key");
              }
              string installRoot = key.GetValue("InstallRoot") as string;
              if (installRoot == null) {
            throw new Exception("Failed to determine .NET Framework install root - no InstallRoot value");
              }
              key.Close();

              buildEngine.BinPath = Path.Combine(installRoot, string.Format("v{0}.{1}.{2}", Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build));
              buildEngine.RegisterLogger(executor);

              executor.Verbosity = LoggerVerbosity.Normal;

              BuildPropertyGroup properties = new BuildPropertyGroup();
              foreach (string propKey in pParams.Keys) {
            string val = pParams[propKey];

            properties.SetProperty(propKey, val, true);
              }

              return buildEngine.BuildProjectFile(pProj.FileName, new string[]{pTarget}, properties);
        }
开发者ID:paulj,项目名称:webgac,代码行数:29,代码来源:BuildExecutor.cs

示例5: XnaContentProject

        public XnaContentProject(Task task, string msBuildPath, string xnaInstallPath)
        {
            m_engine = new Engine(msBuildPath);
            m_engine.RegisterLogger(new XnaContentLogger(task));
            m_project = new Project(m_engine);

            m_project.AddNewUsingTaskFromAssemblyName("BuildContent", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");
            m_project.AddNewUsingTaskFromAssemblyName("BuildXact", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");

            // Add our Content Pipeline Assemblies
            m_pipelineGroup = m_project.AddNewItemGroup();
            m_contentGroup = m_project.AddNewItemGroup();

            m_contentTarget = m_project.Targets.AddNewTarget("_BuildXNAContentLists");

            // Add our Build target
            m_xnaTarget = m_project.Targets.AddNewTarget("Build");
            m_xnaTarget.DependsOnTargets = "_BuildXNAContentLists";

            // Add Default Pipeline Assemblies.
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll");
        }
开发者ID:orj,项目名称:xnananttasks,代码行数:25,代码来源:XnaContentProject.cs

示例6: ProjectBuilder

		public ProjectBuilder (string file, string binDir)
		{
			this.file = file;
			engine = new Engine (binDir);
			engine.GlobalProperties.SetProperty ("BuildingInsideVisualStudio", "true");
			
			consoleLogger = new ConsoleLogger (LoggerVerbosity.Normal, LogWriteLine, null, null);
			engine.RegisterLogger (consoleLogger);
			
			Refresh ();
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:11,代码来源:ProjectBuilder.cs

示例7: InvalidToolPath

        public void InvalidToolPath()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine e = new Engine();
            MockLogger mockLogger = new MockLogger();
            e.RegisterLogger(mockLogger);
            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "invalid||path"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry) t.GetTaskRegistry(null);

            Console.WriteLine(mockLogger.FullLog);
            Assert.AreEqual(1, mockLogger.WarningCount, "Expected a warning for invalid character in toolpath"); 
        }
开发者ID:nikson,项目名称:msbuild,代码行数:13,代码来源:ToolsVersion_Tests.cs

示例8: Test1

		public void Test1 ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ResXFile Include=""Item1"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item2"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item3"">
						<Culture>en</Culture>
					</ResXFile>
					<ResXFile Include=""Item4"">
						<Culture>gb</Culture>
					</ResXFile>
					<ResXFile Include=""Item5"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item6"">
						<Culture>it</Culture>
					</ResXFile>
				</ItemGroup>

				<Target Name=""ShowMessage"">
					<Message
						Text = ""Culture: %(ResXFile.Culture) -- ResXFile: @(ResXFile)"" />
				</Target>
			  </Project>";

			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();

			TestMessageLogger testLogger = new TestMessageLogger ();
			engine.RegisterLogger (testLogger);

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("ShowMessage"), "A1: Build failed");

			CheckMessage (testLogger, "fr", "Item1;Item2;Item5", "A2");
			CheckMessage (testLogger, "en", "Item3", "A3");
			CheckMessage (testLogger, "gb", "Item4", "A4");
			CheckMessage (testLogger, "it", "Item6", "A5");

			CheckEngineEventCounts (testLogger, 1, 1, 4, 4);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:46,代码来源:TaskBatchingTest.cs

示例9: ProjectBuilder

		public ProjectBuilder (string file, string binDir)
		{
			this.file = file;
			RunSTA (delegate
			{
				engine = new Engine (binDir);
				engine.GlobalProperties.SetProperty ("BuildingInsideVisualStudio", "true");
				
				//we don't have host compilers in MD, and this is set to true by some of the MS targets
				//which causes it to always run the CoreCompile task if BuildingInsideVisualStudio is also
				//true, because the VS in-process compiler would take care of the deps tracking
				engine.GlobalProperties.SetProperty ("UseHostCompilerIfAvailable", "false");

				consoleLogger = new MDConsoleLogger (LoggerVerbosity.Normal, LogWriteLine, null, null);
				engine.RegisterLogger (consoleLogger);
			});
			
			Refresh ();
		}
开发者ID:nieve,项目名称:monodevelop,代码行数:19,代码来源:ProjectBuilder.cs

示例10: WarningLoggedIfNoDefaultTasksFound

        public void WarningLoggedIfNoDefaultTasksFound()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine e = new Engine();
            MockLogger mockLogger = new MockLogger();
            e.RegisterLogger(mockLogger);

            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "c:\\directory1\\directory2\\doesntexist"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry) t.GetTaskRegistry(null);

            string[] unexpectedRegisteredTasks = { "a1", "a2", "a3", "a4", "b1", "c1", "d1", "e1", "f1", "g1", "g2", "g3", "11", "12", "13", "21" };

            Assert.AreEqual(1, mockLogger.WarningCount, "Expected 1 warning logged!");
            foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
            {
                Hashtable registeredTasks;
                Assert.IsFalse(taskRegistry.FindRegisteredTasks(unexpectedRegisteredTask, true, out registeredTasks),
                               String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:21,代码来源:ToolsVersion_Tests.cs

示例11: 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();
        }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:39,代码来源:Program.cs

示例12: TestItemsWithWildcards

		public void TestItemsWithWildcards ()
		{
			Engine engine = new Engine (Consts.BinPath);
			Project proj = engine.CreateNewProject ();
			MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
				new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
			engine.RegisterLogger (logger);

			// Setup

			string basedir = PathCombine ("Test", "resources", "dir");
			string aaa = PathCombine ("a", "aa", "aaa");
			string bb = Path.Combine ("b", "bb");

			string[] dirs = { aaa, bb, "c" };
			string [] files = {
								PathCombine (basedir, aaa, "foo.dll"),
								PathCombine (basedir, bb, "bar.dll"),
								PathCombine (basedir, bb, "sample.txt"),
								Path.Combine (basedir, "xyz.dll")
							  };

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<ItemsRel Include='dir\**\*.dll' Exclude='*\x*.dll' />
						<ItemsRelExpanded Include=""@(ItemsRel->'%(FullPath)')"" />
						<ItemsAbs Include='$(MSBuildProjectDirectory)\dir\**\*.dll'/>
					</ItemGroup>

					<Target Name='Main'>
						<Message Text=""ItemsRel: %(ItemsRel.FullPath) RecDir: %(ItemsRel.RecursiveDir)""/>
						<Message Text=""ItemsRelExpanded: %(ItemsRelExpanded.Identity)""/>
						<Message Text='ItemsAbs: %(ItemsAbs.Identity) RecDir: %(ItemsAbs.RecursiveDir)'/>
					</Target>
				</Project>";

			try {
				CreateDirectoriesAndFiles (basedir, dirs, files);
				string projectdir = Path.Combine ("Test", "resources");
				File.WriteAllText (Path.Combine (projectdir, "wild1.proj"), documentString);
				proj.Load (Path.Combine (projectdir, "wild1.proj"));
				if (!proj.Build ("Main")) {
					logger.DumpMessages ();
					Assert.Fail ("Build failed");
				}
				string full_base_dir = Path.GetFullPath (basedir);

				logger.CheckLoggedAny (@"ItemsRel: "+ PathCombine (full_base_dir, aaa, "foo.dll") +
							" RecDir: " + aaa + Path.DirectorySeparatorChar, MessageImportance.Normal, "A1");

				logger.CheckLoggedAny (@"ItemsRel: " + PathCombine (full_base_dir, bb, "bar.dll") +
							" RecDir: " + bb + Path.DirectorySeparatorChar, MessageImportance.Normal, "A2");

				logger.CheckLoggedAny (@"ItemsRelExpanded: " + PathCombine (full_base_dir, aaa, "foo.dll"), MessageImportance.Normal, "A3");
				logger.CheckLoggedAny (@"ItemsRelExpanded: " + PathCombine (full_base_dir, bb, "bar.dll"), MessageImportance.Normal, "A4");

				logger.CheckLoggedAny (@"ItemsAbs: " + PathCombine (full_base_dir, aaa, "foo.dll") +
							@" RecDir: " + aaa + Path.DirectorySeparatorChar, MessageImportance.Normal, "A5");
				logger.CheckLoggedAny (@"ItemsAbs: " + PathCombine (full_base_dir, bb, "bar.dll") +
							@" RecDir: " + bb + Path.DirectorySeparatorChar, MessageImportance.Normal, "A6");
				logger.CheckLoggedAny (@"ItemsAbs: " + PathCombine (full_base_dir, "xyz.dll") +
							@" RecDir: ", MessageImportance.Normal, "A7");

				Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
			} catch (AssertionException) {
				logger.DumpMessages ();
				throw;
			} finally {
				Directory.Delete (basedir, true);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:72,代码来源:Items.cs

示例13: TestItemsInTarget3c

		//Test with string
		public void TestItemsInTarget3c ()
		{
			Engine engine = new Engine (Consts.BinPath);
			Project proj = engine.CreateNewProject ();
			MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
				new MonoTests.Microsoft.Build.Tasks.TestMessageLogger();
			engine.RegisterLogger(logger);

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
					<PropertyGroup>
						<A>A</A>
						<B>A;B</B>
						<C>A;;</C>
						<D>$(C);Foo</D>
					</PropertyGroup>
					<ItemGroup>
						<A Include='A;B;;;C' />
					</ItemGroup>";

			documentString += CreateTargetFragment ("BatchingTestTask", "SingleString", "SingleStringOutput", "I",
					new string [] {
						"$(A)$(A)",
						"$(B)$(B)",
						"$(C)",
						"$(C)$(C)",
						"$(C) $(C)",
						"@(A);$(C)",
						"@(A);A;B;C",
						"@(A) $(C) @(A)",
					}) + "</Project>";

			proj.LoadXml (documentString);
			if (!proj.Build("1")) {
				logger.DumpMessages();
				Assert.Fail("Build failed");
			}

			BuildProperty bp = proj.EvaluatedProperties ["D"];
			Assert.AreEqual ("$(C);Foo", bp.Value, "B0");
			Assert.AreEqual ("A;;;Foo", bp.FinalValue, "B1");

			bp = proj.EvaluatedProperties ["C"];
			Assert.AreEqual ("A;;", bp.Value, "B3");
			Assert.AreEqual ("A;;", bp.FinalValue, "B4");

			CheckItems (proj, "I0", "A0", "AA");
			CheckItems (proj, "I1", "A1", "A;BA;B");
			CheckItems (proj, "I2", "A2", "A;;");
			CheckItems (proj, "I3", "A3", "A;;A;;");
			CheckItems (proj, "I4", "A4", "A;; A;;");
			CheckItems (proj, "I5", "A5", "A;B;C;A;;");
			CheckItems (proj, "I6", "A6", "A;B;C;A;B;C");
			CheckItems (proj, "I7", "A7", "A;B;C A;; A;B;C");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:57,代码来源:Items.cs

示例14: CreateAndCheckProject

		void CreateAndCheckProject (string[] guids, string[] project_ref_guids, string[] messages, bool build_result, string prefix)
		{
			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();
			TestMessageLogger testLogger = new TestMessageLogger ();
			engine.RegisterLogger (testLogger);

			string projectString = CreateProject (guids, project_ref_guids);
			project.LoadXml (projectString);

			try {
				Assert.AreEqual (build_result, project.Build (), "Build " + (build_result ? "failed" : "should've failed"));
				if (!build_result || messages == null)
					// build failed as expected, don't check outputs
					return;
				for (int i = 0; i < messages.Length; i++)
					testLogger.CheckLoggedMessageHead (messages [i], prefix + i.ToString ());
				Assert.AreEqual (0, testLogger.NormalMessageCount);
			} catch (AssertionException) {
				Console.WriteLine (projectString);
				testLogger.DumpMessages ();
				throw;
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:24,代码来源:AssignProjectConfigurationTest.cs

示例15: TestEmptyPropertyValue

		public void TestEmptyPropertyValue ()
		{
			Engine engine;
			Project project;

			string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<PropertyGroup>
						<A>1</A>
					</PropertyGroup>
					<Target Name='1'>
						<Message Text='Before: $(A)'/>
						<CreateProperty Value=''>
							<Output
								TaskParameter='Value'
								PropertyName='A'
							/>
						</CreateProperty>
						<Message Text='After: $(A)'/>
					</Target>
				</Project>
			";

			engine = new Engine (Consts.BinPath);

			TestMessageLogger testLogger = new TestMessageLogger ();
			engine.RegisterLogger (testLogger);

			project = engine.CreateNewProject ();
			project.LoadXml (documentString);
			if (!project.Build ("1")) {
				testLogger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			testLogger.CheckLoggedMessageHead ("Before: 1", "A1");
			testLogger.CheckLoggedMessageHead ("After: ", "A2");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected messages found");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:39,代码来源:CreatePropertyTest.cs


注:本文中的Microsoft.Build.BuildEngine.Engine.RegisterLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。