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


C# Execution.BuildParameters类代码示例

本文整理汇总了C#中Microsoft.Build.Execution.BuildParameters的典型用法代码示例。如果您正苦于以下问题:C# BuildParameters类的具体用法?C# BuildParameters怎么用?C# BuildParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreateBuildProject

        void CreateBuildProject()
        {
            string projectPath = Path.Combine(buildDirectory, "content.contentproj");
            string outputPath = Path.Combine(buildDirectory, "bin");

            // Create the build project.
            projectRootElement = ProjectRootElement.Create(projectPath);

            // Include the standard targets file that defines how to build XNA Framework content.
            projectRootElement.AddImport(Application.StartupPath + "\\Exporters\\FBX\\XNA\\XNA Game Studio\\" +
                                         "v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");

            buildProject = new Project(projectRootElement);

            buildProject.SetProperty("XnaPlatform", "Windows");
            buildProject.SetProperty("XnaProfile", "Reach");
            buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
            buildProject.SetProperty("Configuration", "Release");
            buildProject.SetProperty("OutputPath", outputPath);
            buildProject.SetProperty("ContentRootDirectory", ".");
            buildProject.SetProperty("ReferencePath", Application.StartupPath);

            // Register any custom importers or processors.
            foreach (string pipelineAssembly in pipelineAssemblies)
            {
                buildProject.AddItem("Reference", pipelineAssembly);
            }

            // Hook up our custom error logger.
            errorLogger = new ErrorLogger();

            buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection)
                                  {Loggers = new ILogger[] {errorLogger}};
        }
开发者ID:nicolasmassouh,项目名称:Babylon.js,代码行数:34,代码来源:ContentBuilder.cs

示例2: Main

        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("LiteDevelop MSBuild");

                var arguments = CommandLineArguments.Parse(args);

                if (!File.Exists(arguments.InputFile))
                    throw new ArgumentException("File does not exist.");

                var buildParameters = new BuildParameters();
                buildParameters.DetailedSummary = arguments.DetailedSummary;
                buildParameters.Loggers = new ILogger[] 
                { 
                    new ConsoleLogger() { Verbosity = arguments.Verbosity }
                };

                Dictionary<string, string> properties = new Dictionary<string, string>();

                var buildRequest = new BuildRequestData(arguments.InputFile, properties, null, new string[] { arguments.Target.ToString() }, null);
                
              //  Microsoft.Build.Execution.BuildManager.DefaultBuildManager.
                var results = Microsoft.Build.Execution.BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);

            }
            catch (Exception ex)
            {
                Console.WriteLine("error: line=0 column=0 file=\"LiteDevelop.MSBuild.exe\" => " + ex.Message);
                Console.WriteLine("This program should only be executed by LiteDevelop itself. If you believe this is a bug, please report the issue.");
            }
        }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:32,代码来源:Program.cs

示例3: Build

        private BuildResult Build(IEnumerable<ILogger> loggers)
        {
            // 1) Clean previous deployment.
            // 2) Do a build of the website project with the "Package" target. This will copy all
            //    the necessary website files into a directory similar to the following:
            //    MyProject/obj/Test/Package/PackageTmp

            var parameters = new BuildParameters { Loggers = loggers };
            var projectFilePath = Path.Combine(_siteRoot, _projectFileName);
            var globalProperties = new Dictionary<string, string> {
                { "Configuration", "Test" }
            };

            if (!string.IsNullOrWhiteSpace(_solutionDir))
                globalProperties.Add("SolutionDir", _solutionDir);

            if (!string.IsNullOrWhiteSpace(_projectDir))
                globalProperties.Add("ProjectDir", _projectDir);

            var requestData = new BuildRequestData(
                projectFilePath, globalProperties, null, _targets,
                null);

            return BuildManager.DefaultBuildManager.Build(parameters, requestData);
        }
开发者ID:meinsiedler,项目名称:dryrunner,代码行数:25,代码来源:TestSiteDeployer.cs

示例4: Build

        public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark)
        {
            lock (buildLock)
            {
                var projectFileName = Path.Combine(generateResult.DirectoryPath, ClassicGenerator.MainClassName + ".csproj");
                var exeFilePath = Path.Combine(generateResult.DirectoryPath, ClassicGenerator.MainClassName + ".exe");
                var consoleLogger = new MsBuildConsoleLogger(logger);
                var globalProperties = new Dictionary<string, string>();
                var buildRequest = new BuildRequestData(projectFileName, globalProperties, null, new[] { "Build" }, null);
                var buildParameters = new BuildParameters(new ProjectCollection()) { DetailedSummary = false, Loggers = new Microsoft.Build.Framework.ILogger[] { consoleLogger } };
                var buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);

                if (buildResult.OverallResult != BuildResultCode.Success && !File.Exists(exeFilePath))
                {
                    logger.WriteLineInfo("BuildManager.DefaultBuildManager can't build this project. =(");
                    logger.WriteLineInfo("Let's try to build it via BuildBenchmark.bat!");
                    var buildProcess = new Process
                    {
                        StartInfo =
                        {
                            FileName = Path.Combine(generateResult.DirectoryPath, "BuildBenchmark.bat"),
                            WorkingDirectory = generateResult.DirectoryPath,
                            UseShellExecute = false,
                            RedirectStandardOutput = false,
                        }
                    };
                    buildProcess.Start();
                    buildProcess.WaitForExit();
                    if (File.Exists(exeFilePath))
                        return new BuildResult(generateResult, true, null, exeFilePath);
                }

                return new BuildResult(generateResult, buildResult.OverallResult == BuildResultCode.Success, buildResult.Exception, exeFilePath);
            }
        }
开发者ID:omariom,项目名称:BenchmarkDotNet,代码行数:35,代码来源:ClassicBuilder.cs

示例5: PropertiesDefault

		public void PropertiesDefault ()
		{
			var bp = new BuildParameters ();
			Assert.IsTrue (bp.EnableNodeReuse, "#1");
			Assert.IsTrue (bp.EnvironmentProperties.Count > 0, "#2");
			Assert.AreEqual (CultureInfo.CurrentCulture, bp.Culture, "#3");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:7,代码来源:BuildParametersTest.cs

示例6: Execute

        public void Execute(WebsiteContext context)
        {
            Logger.Log("Building the solution...");

            var solutionFilePath = Directory.GetFiles(context.CurrentDirectory).FirstOrDefault(x => x.EndsWith(".sln"));
            var properties = new Dictionary<string, string> {
                {"Configuration", "Debug"}
            };

            var buildParameters = new BuildParameters();
            var buildLoggger = new InMemoryBuildLogger();
            buildParameters.Loggers = new[] {buildLoggger};
            var buildRequest = new BuildRequestData(solutionFilePath, properties, null, new[] { "Build" }, null);
            var buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);

            if (buildResult.OverallResult == BuildResultCode.Failure) {
                Logger.Error("Failed to build the solution!");
                Logger.Space();

                foreach (var buildError in buildLoggger.BuildErrors) {
                    Logger.Error(buildError);
                }
                Logger.Space();
            }
            else
                Logger.Success("Solution successfully built.");
        }
开发者ID:NansenViktor,项目名称:wia,代码行数:27,代码来源:BuildTask.cs

示例7: Main

        private static void Main()
        {
            try
            {
                // Run this in debug otherwise the files in CreateInstallers will be locked. :)
                const string projectFileName = @"..\..\..\wix-custom-ba-issue.sln";
                var pc = new ProjectCollection();
                var globalProperty = new Dictionary<string, string> {{"Configuration", "Release"}};

                var buildRequestData = new BuildRequestData(projectFileName, globalProperty, null, new[] {"Rebuild"},
                    null);

                var buildParameters = new BuildParameters(pc)
                {
                    DetailedSummary = true,
                    Loggers = new List<ILogger> {new ConsoleLogger()}
                };

                foreach (var version in new List<string> {"0.0.6.0", "1.0.0.0"})
                    BuildExamples(version, buildParameters, buildRequestData);
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed!", e);
                Console.WriteLine(e.ToString());
            }
        }
开发者ID:squirmy,项目名称:wix-custom-ba-issue,代码行数:27,代码来源:Program.cs

示例8: BuildExamples

        private static void BuildExamples(string versionString, BuildParameters buildParameters,
            BuildRequestData buildRequestData)
        {
            const string versionFileName = @"..\..\..\.config\VersionInfo.txt";
            File.WriteAllText(versionFileName, versionString);

            var buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequestData);

            if (buildResult.OverallResult == BuildResultCode.Success)
            {
                var output =
                    buildResult.ResultsByTarget["Rebuild"].Items.First(x => x.ItemSpec.Contains("Bootstrapper"))
                        .ItemSpec;

                var temp = Path.GetTempPath();
                var productName = Path.GetFileNameWithoutExtension(output);
                var fileName = Path.GetFileName(output);

                if (productName != null)
                {
                    var directory = Path.Combine(temp, productName, versionString);

                    if (Directory.Exists(directory))
                        Directory.Delete(directory, true);

                    Directory.CreateDirectory(directory);

                    if (fileName != null)
                        File.Copy(output, Path.Combine(directory, fileName));
                }
            }
        }
开发者ID:squirmy,项目名称:wix-custom-ba-issue,代码行数:32,代码来源:Program.cs

示例9: Build

        public static string[] Build(string solutionFile)
        {
            Console.Error.Write("// Building '{0}'... ", Path.GetFileName(solutionFile));

            var pc = new ProjectCollection();
            var parms = new BuildParameters(pc);
            var globalProperties = new Dictionary<string, string>();
            var request = new BuildRequestData(solutionFile, globalProperties, null, new string[] { "Build" }, null);

            parms.Loggers = new[] {
                new ConsoleLogger(LoggerVerbosity.Quiet)
            };

            var result = BuildManager.DefaultBuildManager.Build(parms, request);
            var resultFiles = new HashSet<string>();

            Console.Error.WriteLine("done.");

            foreach (var kvp in result.ResultsByTarget) {
                var targetResult = kvp.Value;

                if (targetResult.Exception != null)
                    Console.Error.WriteLine("// Compilation failed for target '{0}':\r\n{1}", kvp.Key, targetResult.Exception.Message);
                else {
                    foreach (var filename in targetResult.Items)
                        resultFiles.Add(filename.ItemSpec);
                }
            }

            return resultFiles.ToArray();
        }
开发者ID:nowonu,项目名称:JSIL,代码行数:31,代码来源:SolutionBuilder.cs

示例10: BuildAsync

    internal static async Task<BuildResult> BuildAsync(this BuildManager buildManager, ITestOutputHelper logger, ProjectCollection projectCollection, ProjectRootElement project, string target, IDictionary<string, string> globalProperties = null, LoggerVerbosity logVerbosity = LoggerVerbosity.Detailed, ILogger[] additionalLoggers = null)
    {
        Requires.NotNull(buildManager, nameof(buildManager));
        Requires.NotNull(projectCollection, nameof(projectCollection));
        Requires.NotNull(project, nameof(project));

        globalProperties = globalProperties ?? new Dictionary<string, string>();
        var projectInstance = new ProjectInstance(project, globalProperties, null, projectCollection);
        var brd = new BuildRequestData(projectInstance, new[] { target }, null, BuildRequestDataFlags.ProvideProjectStateAfterBuild);

        var parameters = new BuildParameters(projectCollection);

        var loggers = new List<ILogger>();
        loggers.Add(new ConsoleLogger(logVerbosity, s => logger.WriteLine(s.TrimEnd('\r', '\n')), null, null));
        loggers.AddRange(additionalLoggers);
        parameters.Loggers = loggers.ToArray();

        buildManager.BeginBuild(parameters);

        var result = await buildManager.BuildAsync(brd);

        buildManager.EndBuild();

        return result;
    }
开发者ID:azeno,项目名称:Nerdbank.GitVersioning,代码行数:25,代码来源:MSBuildExtensions.cs

示例11: MockHost

        /// <summary>
        /// Constructor
        /// </summary>
        public MockHost(BuildParameters buildParameters)
        {
            _buildParameters = buildParameters;

            _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false);

            _configCache = new ConfigCache();
            ((IBuildComponent)_configCache).InitializeComponent(this);

            // We are a logging service
            _loggingService = this;

            _legacyThreadingData = new LegacyThreadingData();

            _requestEngine = new BuildRequestEngine();
            ((IBuildComponent)_requestEngine).InitializeComponent(this);

            _resultsCache = new ResultsCache();
            ((IBuildComponent)_resultsCache).InitializeComponent(this);

            _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder();
            ((IBuildComponent)_requestBuilder).InitializeComponent(this);

            _targetBuilder = new TestTargetBuilder();
            ((IBuildComponent)_targetBuilder).InitializeComponent(this);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:29,代码来源:MockHost.cs

示例12: Build

		public BuildResult Build (BuildParameters parameters, BuildRequestData requestData)
		{
			BeginBuild (parameters);
			var ret = BuildRequest (requestData);
			EndBuild ();
			return ret;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:BuildManager.cs

示例13: ExecuteAsync

        /// <summary>
        /// Builds a project.
        /// </summary>
        /// <param name="projectPath">The absolute path to the project.</param>
        /// <param name="targetsToBuild">The targets to build. If not specified, the project's default target will be invoked.</param>
        /// <param name="properties">The optional global properties to pass to the project. May come from the <see cref="MSBuild.Properties"/> static class.</param>
        /// <returns>A task whose result is the result of the build.</returns>
        public static async Task<BuildResultAndLogs> ExecuteAsync(string projectPath, string[] targetsToBuild = null, IDictionary<string, string> properties = null, ITestOutputHelper testLogger = null)
        {
            targetsToBuild = targetsToBuild ?? new string[0];

            var logger = new EventLogger();
            var logLines = new List<string>();
            var parameters = new BuildParameters
            {
                Loggers = new List<ILogger>
                {
                    new ConsoleLogger(LoggerVerbosity.Detailed, logLines.Add, null, null),
                    new ConsoleLogger(LoggerVerbosity.Minimal, v => testLogger?.WriteLine(v.TrimEnd()), null, null),
                    logger,
                },
            };

            BuildResult result;
            using (var buildManager = new BuildManager())
            {
                buildManager.BeginBuild(parameters);
                try
                {
                    var requestData = new BuildRequestData(projectPath, properties ?? Properties.Default, null, targetsToBuild, null);
                    var submission = buildManager.PendBuildRequest(requestData);
                    result = await submission.ExecuteAsync();
                }
                finally
                {
                    buildManager.EndBuild();
                }
            }

            return new BuildResultAndLogs(result, logger.LogEvents, logLines);
        }
开发者ID:NN---,项目名称:nuproj,代码行数:41,代码来源:MSBuild.cs

示例14: Build

    public static BuildResult Build(string projectOrSolution, string targets, Dictionary<string, string> properties = null, ILogger logger = null)
    {
        if (!Path.IsPathRooted(projectOrSolution))
            projectOrSolution = Path.Combine(ModuleInitializer.BaseDirectory, projectOrSolution);

        if (!File.Exists(projectOrSolution))
            throw new FileNotFoundException($"Project or solution to build {projectOrSolution} was not found.", projectOrSolution);

        // Without this, builds end up running in process and colliding with each other,
        // especially around the current directory used to resolve relative paths in projects.
        Environment.SetEnvironmentVariable("MSBUILDNOINPROCNODE", "1");
        using (var manager = new BuildManager(Guid.NewGuid().ToString()))
        {
            properties = properties ?? new Dictionary<string, string>();

            // If file is not a solution, build up a fake solution configuration so P2P references just work
            if (Path.GetExtension(projectOrSolution) != ".sln")
                AddSolutionConfiguration(projectOrSolution, properties);

            var request = new BuildRequestData(projectOrSolution, properties, "14.0", targets.Split(','), null);
            var parameters = new BuildParameters
            {
                GlobalProperties = properties,
            };

            if (logger != null)
                parameters.Loggers = new[] { logger };

            return manager.Build(parameters, request);
        }
    }
开发者ID:xamarin,项目名称:NuGetizer3000,代码行数:31,代码来源:Builder.cs

示例15: Compile

        bool Compile(params string[] targets)
        {
            using (var t = new ChangingOutput("Compiling target(s) {0} . . .", string.Join(", ", targets)))
            {
                t.FinishLine();

                var logger = new ConsoleLogger(LoggerVerbosity.Quiet);

                logger.SkipProjectStartedText = true;

                var props = new Dictionary<string, string>
                {
                    {"Configuration", _release ? "Release" : "Debug"},
                };

                var request = new BuildRequestData(_slnPath, props, null, targets, null);
                var p = new BuildParameters()
                {
                    Loggers = new[] {logger},
                    GlobalProperties = props
                };

                var result = BuildManager.DefaultBuildManager.Build(p, request);

                t.PrintResult(result.OverallResult == BuildResultCode.Success);

                return result.OverallResult == BuildResultCode.Success;
            }
        }
开发者ID:Xcelled,项目名称:aura-frontend,代码行数:29,代码来源:AuraCompiler.cs


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