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


C# Engine.BuildProjectFile方法代码示例

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


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

示例1: BuildProjects

        public bool BuildProjects(List<IProject> projects)
        {
            var engine = new Engine();

            foreach (IProject project in projects)
            {
                string fullProjectPath = Path.Combine(project.ProjectPath, project.ProjectName);

                bool success = engine.BuildProjectFile(fullProjectPath);

                if (success == false)
                    return false;
            }

            return true;
        }
开发者ID:DuncanButler,项目名称:nTestRunner,代码行数:16,代码来源:MSBuild35Engine.cs

示例2: BuildProject

        public static bool BuildProject(string projectPath)
        {
            bool success = false;
            CultureInfo ci = CultureInfo.InvariantCulture;
            Engine engine = new Engine();
            engine.BinPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System)
                + @"\..\Microsoft.NET\Framework\v4.0.30319";
            try
            {
                success = engine.BuildProjectFile(projectPath);
            }
            finally
            {
                engine.UnloadAllProjects();
            }

            return success;
        }
开发者ID:kennedykinyanjui,项目名称:Projects,代码行数:18,代码来源:ProjectBuilder.cs

示例3: BuildProject

        public bool BuildProject(string projectPath)
        {
            bool success = false;
            CultureInfo ci = CultureInfo.InvariantCulture;
            Engine engine = new Engine();
            engine.BinPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System)
                + @"\..\Microsoft.NET\Framework\v4.0.30319";
            try
            {
                success = engine.BuildProjectFile(projectPath);
            }
            catch(ArgumentException)
            {
                throw new System.IO.FileNotFoundException("The specified project to build not found!");
            }
            finally
            {
                engine.UnloadAllProjects();
            }

            return success;
        }
开发者ID:kennedykinyanjui,项目名称:Projects,代码行数:22,代码来源:ProjectBuilder.cs

示例4: 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

示例5: BuildProjectFilesInParallel2

        public void BuildProjectFilesInParallel2()
        {
            string[] fileNames = new string[10];
            string[] fileNames2 = new string[10];
            string[] fileNamesLeafs = new string[10];
            string[] childTraversals = new string[10];
            string parentTraversal = TraversalProjectFile("CTrav");
            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];
            string[] tempfilesToDelete2 = new string[fileNames.Length];
            string[] tempfilesToDelete3 = new string[fileNames.Length];
            string[] tempfilesToDelete4 = new string[fileNames.Length];
            Engine engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    string[] ProjectFiles1 = CreateGlobalPropertyProjectFileWithExtension("ABC");
                    string[] ProjectFiles2 = CreateGlobalPropertyProjectFileWithExtension("DEF");
                    string[] FileNamesLeafs = CreateGlobalPropertyProjectFileWithExtension("LEAF");
                    string[] ChildTraversals = CreateSingleProjectTraversalFileWithExtension(FileNamesLeafs[0],"CTrav");

                    fileNames[i] = ProjectFiles1[0];
                    fileNames2[i] = ProjectFiles2[0];
                    fileNamesLeafs[i] = FileNamesLeafs[0];
                    childTraversals[i] = ChildTraversals[0];
                    
                    tempfilesToDelete[i] = ProjectFiles1[1];
                    tempfilesToDelete2[i] = ProjectFiles2[1];
                    tempfilesToDelete3[i] = FileNamesLeafs[1];
                    tempfilesToDelete4[i] = ChildTraversals[1];
                    targetNamesPerProject[i] = new string[] { "Build" };
                }


                // Try building a traversal project that had other traversals
                
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                engine.BuildProjectFile(parentTraversal, new string[] { "Build" }, new BuildPropertyGroup(), null, BuildSettings.None, "3.5");
                engine.Shutdown();

                 engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                // Try building the same traversal project on the same engine one after another
                engine.BuildProjectFile(traversalProject);
                engine.BuildProjectFile(traversalProject);
                engine.Shutdown();

                // Try building the same set of project files on the same engine one after another
                engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
                engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
                engine.Shutdown();

                // Try building a set of project files, then the same set as a traversal on the same engine
                engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                engine.BuildProjectFiles(fileNames2, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
                engine.BuildProjectFile(traversalProject);
                engine.Shutdown();


                // Try building a traversal, then the same files which are in the traversal in parallel on the same engine
                engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                engine.BuildProjectFile(traversalProject);
                engine.BuildProjectFiles(fileNames2, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
                engine.Shutdown();
                /* Do the same as above using single proc */

                // Try building the same traversal project on the same engine one after another
                engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 1, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                engine.BuildProjectFile(traversalProject);
                engine.BuildProjectFile(traversalProject);
                engine.Shutdown();

                // Try building the same set of project files on the same engine one after another
                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]);
                engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
                engine.Shutdown();

                // Try building a set of project files, then the same set as a traversal on the same engine
                engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 1, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
                engine.BuildProjectFiles(fileNames2, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]);
                engine.BuildProjectFile(traversalProject);
                engine.Shutdown();

                // Try building a traversal, then the same files which are in the traversal in parallel on the same engine
                engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory);
                engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal));
//.........这里部分代码省略.........
开发者ID:nikson,项目名称:msbuild,代码行数:101,代码来源:Engine_Tests.cs

示例6: 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);
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:62,代码来源:Engine_Tests.cs

示例7: Execute


//.........这里部分代码省略.........
                pg.AddNewProperty("ErrorReport", "prompt");
                pg.AddNewProperty("NoStdLib", "true");
                pg.AddNewProperty("NoConfig", "true");
                pg.AddNewProperty("WarningLevel", "4");
                pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".Phone.xml");

                // Add reference structure
                refItemGroup = phoneProj.AddNewItemGroup();
                refItemGroup.AddNewItem("Reference", "System");
                refItemGroup.AddNewItem("Reference", "System.Xml");

                BuildItem evReference = refItemGroup.AddNewItem("Reference", @"MARC.Everest.Phone");
                evReference.SetMetadata("SpecificVersion", "false");
                evReference.SetMetadata("HintPath", "lib\\MARC.Everest.Phone.dll");

                // Add WP7 Imports
                phoneProj.AddNewImport(@"$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets", null);
                phoneProj.AddNewImport(@"$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets", null);

                // HACK: Add tools version
                string fileName = Path.Combine(hostContext.Output, ProjectFileName) + ".Phone.csproj";
                phoneProj.Save(fileName);
                XmlDocument doc = new XmlDocument();
                doc.Load(fileName);
                doc.DocumentElement.Attributes.Append(doc.CreateAttribute("ToolsVersion"));
                doc.DocumentElement.Attributes["ToolsVersion"].Value = "4.0";
                doc.Save(fileName);

                if (parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0]))
                {
                    System.Diagnostics.Trace.Write(String.Format("Compiling phone project..."), "information");

                    // Compile
                    if (phoneEngine.BuildProjectFile(fileName))
                        System.Diagnostics.Trace.WriteLine("Success!", "information");
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("Fail", "information");
                        throw new InvalidOperationException("Failed compilation, operation cannot continue");

                    }
                }
            }

            #endregion

            #region Generate Formatter Assemblies

            // Generate the formatter assemblies
            if (genFormatters.Count > 0 && parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0]))
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                Trace.WriteLine("Generating ITS Formatter Types:", "information");

                // Load the assembly
                Assembly genAsm = Assembly.LoadFile(Path.Combine(Path.Combine(Path.Combine(hostContext.Output, "bin"), "release"), ProjectFileName + ".dll"));
                foreach (string s in genFormatters)
                    GenerateFormatterAssembly(s, genAsm, InteractionRenderer.profileId ?? "formatter");
                
                // Assembly resolve
                AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            }
            else if (genFormatters.Count > 0)
                Trace.WriteLine("Can't use --rimbapi-gen-its when --rimbapi-compile is not true, skipping ITS generation", "warn");
            #endregion
开发者ID:oneminot,项目名称:everest,代码行数:66,代码来源:RimbaCsRenderer.cs

示例8: Execute

		public void Execute ()
		{
			bool result = false;
			bool show_stacktrace = false;
			
			try {
				parameters.ParseArguments (args);
				show_stacktrace = (parameters.LoggerVerbosity == LoggerVerbosity.Detailed ||
					parameters.LoggerVerbosity == LoggerVerbosity.Diagnostic);
				
				if (!parameters.NoLogo)
					ErrorUtilities.ShowVersion (false);
				
				engine  = Engine.GlobalEngine;
				if (!String.IsNullOrEmpty (parameters.ToolsVersion)) {
					if (engine.Toolsets [parameters.ToolsVersion] == null)
						ErrorUtilities.ReportError (0, new UnknownToolsVersionException (parameters.ToolsVersion).Message);

					engine.DefaultToolsVersion = parameters.ToolsVersion;
				}
				
				engine.GlobalProperties = this.parameters.Properties;
				
				if (!parameters.NoConsoleLogger) {
					printer = new ConsoleReportPrinter ();
					ConsoleLogger cl = new ConsoleLogger (parameters.LoggerVerbosity,
							printer.Print, printer.SetForeground, printer.ResetColor);

					cl.Parameters = parameters.ConsoleLoggerParameters;
					cl.Verbosity = parameters.LoggerVerbosity; 
					engine.RegisterLogger (cl);
				}

				if (parameters.FileLoggerParameters != null) {
					for (int i = 0; i < parameters.FileLoggerParameters.Length; i ++) {
						string fl_params = parameters.FileLoggerParameters [i];
						if (fl_params == null)
							continue;

						var fl = new FileLogger ();
						if (fl_params.Length == 0 && i > 0)
							fl.Parameters = String.Format ("LogFile=msbuild{0}.log", i);
						else
							fl.Parameters = fl_params;
						engine.RegisterLogger (fl);
					}
				}
				
				foreach (LoggerInfo li in parameters.Loggers) {
					Assembly assembly;
					if (li.InfoType == LoadInfoType.AssemblyFilename)
						assembly = Assembly.LoadFrom (li.Filename);
					else
						assembly = Assembly.Load (li.AssemblyName);
					ILogger logger = (ILogger)Activator.CreateInstance (assembly.GetType (li.ClassName));
					logger.Parameters = li.Parameters;
					engine.RegisterLogger (logger); 
				}
				
				project = engine.CreateNewProject ();
				
				if (parameters.Validate) {
					if (parameters.ValidationSchema == null)
						project.SchemaFile = defaultSchema;
					else
						project.SchemaFile = parameters.ValidationSchema;
				}

				string projectFile = parameters.ProjectFile;
				if (!File.Exists (projectFile)) {
					ErrorUtilities.ReportError (0, String.Format ("Project file '{0}' not found.", projectFile));
					return;
				}

				result = engine.BuildProjectFile (projectFile, parameters.Targets, null, null, BuildSettings.None, parameters.ToolsVersion);
			}
			
			catch (InvalidProjectFileException ipfe) {
				ErrorUtilities.ReportError (0, show_stacktrace ? ipfe.ToString () : ipfe.Message);
			}

			catch (InternalLoggerException ile) {
				ErrorUtilities.ReportError (0, show_stacktrace ? ile.ToString () : ile.Message);
			}

			catch (CommandLineException cle) {
				ErrorUtilities.ReportError(cle.ErrorCode, show_stacktrace ? cle.ToString() : cle.Message);
			}
			finally {
				if (engine != null)
					engine.UnregisterAllLoggers ();

				Environment.Exit (result ? 0 : 1);
			}

		}
开发者ID:nobled,项目名称:mono,代码行数:96,代码来源:Main.cs

示例9: BuildProjectFileEmptyString

 public void BuildProjectFileEmptyString()
 {
     Engine e = new Engine();
     e.BuildProjectFile(String.Empty);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:5,代码来源:Engine_Tests.cs

示例10: 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

示例11: MsDeploy

        /// <summary>
        /// MSDeploy web role project file.
        /// </summary>
        /// <param name="csprojPath">Full path to web role .csproj file</param>
        /// <param name="msDeployDir">Temporary packageTmp folder</param>
        /// <returns>MsDeploy success status</returns>
        public static bool MsDeploy(string csprojPath, string msDeployDir)
        {
            Console.WriteLine(" Verifying csproj path...");
            try
            {
                var csprojFileInfo = new FileInfo(csprojPath);
                if (!csprojFileInfo.Exists || !csprojFileInfo.Name.EndsWith(".csproj"))
                {
                    Console.WriteLine(" csproj file could not be found at: " + csprojPath);
                    return false;
                }

                Console.WriteLine(" csproj found.");
                Console.WriteLine(" Building project...");

                var engine = new Engine();
                var csprojParentDir = csprojFileInfo.Directory;
                var logger = new FileLogger { Parameters = "logfile=" + csprojParentDir + @"\publish.log" };
                engine.RegisterLogger(logger);

                var buildPropGroup = new BuildPropertyGroup();
                buildPropGroup.SetProperty("OutDir", msDeployDir);
                var deployOnBuildSuccess = engine.BuildProjectFile(csprojPath, new[] { "Rebuild" }, buildPropGroup);

                if (deployOnBuildSuccess)
                    Console.WriteLine(" Successfully MsDeploy project.");
                else
                    Console.WriteLine(" Build failed. Check " + csprojParentDir + @"\publish.log for details.");

                engine.UnloadAllProjects();
                engine.UnregisterAllLoggers();

                return deployOnBuildSuccess;
            }
            catch (Exception ex)
            {
                Console.WriteLine(" " + ex.GetType() + ": " + ex.Message);
                return false;
            }
        }
开发者ID:pophils,项目名称:MessageBoard,代码行数:46,代码来源:PackageProject.cs

示例12: TestLoadProjectDifferentGP

        public void TestLoadProjectDifferentGP()
        {
            MockLogger logger = new MockLogger();
            string path = ObjectModelHelpers.CreateTempFileOnDisk(@"
                <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    <Target Name=`Build`>
                        <Warning Text=`This is a scary warning message.` Code=`MSB9999` HelpKeyword=`MSBuild.keyword`/>
                        <Error Text=`A horrible error has occurred. Be very afraid.` Code=`MSB1111` HelpKeyword=`MSBuild.otherkeyword`/>
                    </Target>
                </Project>
                ");

            Engine engine = new Engine();

            Project project = engine.CreateNewProject();

            project.Load(path);

            project.GlobalProperties.SetProperty("a", "b");
            engine.BuildProjectFile(path);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:21,代码来源:Project_Tests.cs


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