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


C# Execution.BuildResult类代码示例

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


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

示例1: AddResult

        /// <summary>
        /// Adds the specified build result to the cache
        /// </summary>
        /// <param name="result">The result to add.</param>
        public void AddResult(BuildResult result)
        {
            lock (_resultsByConfiguration)
            {
                if (_resultsByConfiguration.ContainsKey(result.ConfigurationId))
                {
                    if (Object.ReferenceEquals(_resultsByConfiguration[result.ConfigurationId], result))
                    {
                        // Merging results would be meaningless as we would be merging the object with itself.
                        return;
                    }

                    _resultsByConfiguration[result.ConfigurationId].MergeResults(result);
                }
                else
                {
                    // Note that we are not making a copy here.  This is by-design.  The TargetBuilder uses this behavior
                    // to ensure that re-entering a project will be able to see all previously built targets and avoid
                    // building them again.
                    if (!_resultsByConfiguration.TryAdd(result.ConfigurationId, result))
                    {
                        ErrorUtilities.ThrowInternalError("Failed to add result for configuration {0}", result.ConfigurationId);
                    }
                }
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:30,代码来源:ResultsCache.cs

示例2: TestSimpleBuildRequest

        public void TestSimpleBuildRequest()
        {
            BuildRequestConfiguration configuration = CreateTestProject(1);
            try
            {
                TestTargetBuilder targetBuilder = (TestTargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder);
                IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);

                configCache.AddConfiguration(configuration);

                BuildRequest request = CreateNewBuildRequest(1, new string[1] { "target1" });
                BuildRequestEntry entry = new BuildRequestEntry(request, configuration);
                BuildResult result = new BuildResult(request);
                result.AddResultsForTarget("target1", GetEmptySuccessfulTargetResult());
                targetBuilder.SetResultsToReturn(result);

                _requestBuilder.BuildRequest(GetNodeLoggingContext(), entry);
                WaitForEvent(_buildRequestCompletedEvent, "Build Request Completed");
                Assert.Equal(BuildRequestEntryState.Complete, entry.State);
                Assert.Equal(entry, _buildRequestCompleted_Entry);
                Assert.Equal(BuildResultCode.Success, _buildRequestCompleted_Entry.Result.OverallResult);
            }
            finally
            {
                DeleteTestProject(configuration);
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:27,代码来源:RequestBuilder_Tests.cs

示例3: SetUp

        public void SetUp()
        {
            LoggingServiceFactory loggingFactory = new LoggingServiceFactory(LoggerMode.Synchronous, 1);

            _loggingService = loggingFactory.CreateInstance(BuildComponentType.LoggingService) as LoggingService;

            _customLogger = new MyCustomLogger();
            _mockHost = new MockHost();
            _mockHost.LoggingService = _loggingService;

            _loggingService.RegisterLogger(_customLogger);
            _elementLocation = ElementLocation.Create("MockFile", 5, 5);

            BuildRequest buildRequest = new BuildRequest(1 /* submissionId */, 1, 1, new List<string>(), null, BuildEventContext.Invalid, null);
            BuildRequestConfiguration configuration = new BuildRequestConfiguration(1, new BuildRequestData("Nothing", new Dictionary<string, string>(), "4.0", new string[0], null), "2.0");

            configuration.Project = new ProjectInstance(ProjectRootElement.Create());

            BuildRequestEntry entry = new BuildRequestEntry(buildRequest, configuration);

            BuildResult buildResult = new BuildResult(buildRequest, false);
            buildResult.AddResultsForTarget("Build", new TargetResult(new TaskItem[] { new TaskItem("IamSuper", configuration.ProjectFullPath) }, TestUtilities.GetSkippedResult()));
            _mockRequestCallback = new MockIRequestBuilderCallback(new BuildResult[] { buildResult });
            entry.Builder = (IRequestBuilder)_mockRequestCallback;

            _taskHost = new TaskHost(_mockHost, entry, _elementLocation, null /*Dont care about the callback either unless doing a build*/);
            _taskHost.LoggingContext = new TaskLoggingContext(_loggingService, BuildEventContext.Invalid);
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:28,代码来源:TaskHost_Tests.cs

示例4: TestConstructorBad

 public void TestConstructorBad()
 {
     Assert.Throws<InternalErrorException>(() =>
     {
         BuildResult result = new BuildResult(null);
     }
    );
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:8,代码来源:BuildResult_Tests.cs

示例5: AssertAnalysisSettingDoesNotExist

        /// <summary>
        /// Checks that a SonarQubeSetting does not exist
        /// </summary>
        public static void AssertAnalysisSettingDoesNotExist(BuildResult actualResult, string settingName)
        {
            Assert.IsNotNull(actualResult.ProjectStateAfterBuild, "Test error: ProjectStateAfterBuild should not be null");

            IEnumerable<ProjectItemInstance> matches = actualResult.ProjectStateAfterBuild.GetItemsByItemTypeAndEvaluatedInclude(BuildTaskConstants.SettingItemName, settingName);

            Assert.AreEqual(0, matches.Count(), "Not expected SonarQubeSetting with include value of '{0}' to exist. Actual occurences: {1}", settingName, matches.Count());
        }
开发者ID:clintcparker,项目名称:sonar-msbuild-runner,代码行数:11,代码来源:BuildAssertions.cs

示例6: TestConfigurationId

        public void TestConfigurationId()
        {
            BuildRequest request = CreateNewBuildRequest(-1, new string[0]);
            BuildResult result = new BuildResult(request);
            Assert.AreEqual(-1, result.ConfigurationId);

            BuildRequest request2 = CreateNewBuildRequest(1, new string[0]);
            BuildResult result2 = new BuildResult(request2);
            Assert.AreEqual(1, result2.ConfigurationId);
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:10,代码来源:BuildResult_Tests.cs

示例7: TestAddAndRetrieveResults

        public void TestAddAndRetrieveResults()
        {
            ResultsCache cache = new ResultsCache();
            BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget" }, null, BuildEventContext.Invalid, null); BuildResult result = new BuildResult(request);
            result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult());
            cache.AddResult(result);

            BuildResult retrievedResult = cache.GetResultForRequest(request);

            Assert.True(AreResultsIdentical(result, retrievedResult));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:11,代码来源:ResultsCache_Tests.cs

示例8: AssertExpectedTargetOutput

        /// <summary>
        /// Checks that building the specified target produced the expected result.
        /// </summary>
        public static void AssertExpectedTargetOutput(BuildResult result, string target, BuildResultCode resultCode)
        {
            DumpTargetResult(result, target);

            TargetResult targetResult;
            if (!result.ResultsByTarget.TryGetValue(target, out targetResult))
            {
                Assert.Inconclusive(@"Could not find result for target ""{0}""", target);
            }
            Assert.AreEqual<BuildResultCode>(resultCode, result.OverallResult, "Unexpected build result");
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:14,代码来源:BuildAssertions.cs

示例9: BuildProject

		// FIXME:
		// While we are not faced to implement those features, there are some modern task execution requirements.
		//
		// This will have to be available for "out of process" nodes (see NodeAffinity).
		// NodeAffinity is set per project file at BuildManager.HostServices.
		// When NodeAffinity is set to OutOfProc, it should probably launch different build host
		// that runs separate build tasks. (.NET has MSBuildTaskHost.exe which I guess is about that.)
		//
		// Also note that the complete implementation has to support LoadInSeparateAppDomainAttribute
		// (which is most likely derived from AppDomainIsolatedBuildTask) that marks a task to run
		// in separate AppDomain.
		//
		public void BuildProject (Func<bool> checkCancel, BuildResult result, ProjectInstance project, IEnumerable<string> targetNames, IDictionary<string,string> globalProperties, IDictionary<string,string> targetOutputs, string toolsVersion)
		{
			if (toolsVersion == null)
				throw new ArgumentNullException ("toolsVersion");
			
			var parameters = submission.BuildManager.OngoingBuildParameters;
			var toolset = parameters.GetToolset (toolsVersion);
			if (toolset == null)
				throw new InvalidOperationException (string.Format ("Toolset version '{0}' was not resolved to valid toolset", toolsVersion));
			LogMessageEvent (new BuildMessageEventArgs (string.Format ("Using Toolset version {0}.", toolsVersion), null, null, MessageImportance.Low));
			var buildTaskFactory = new BuildTaskFactory (BuildTaskDatabase.GetDefaultTaskDatabase (toolset), new BuildTaskDatabase (this, submission.BuildRequest.ProjectInstance));
			BuildProject (new InternalBuildArguments () { CheckCancel = checkCancel, Result = result, Project = project, TargetNames = targetNames, GlobalProperties = globalProperties, TargetOutputs = targetOutputs, ToolsVersion = toolsVersion, BuildTaskFactory = buildTaskFactory });
		}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:BuildEngine4.cs

示例10: AssertExpectedItemGroupCount

        /// <summary>
        /// Checks that the expected number of ItemType entries exist
        /// </summary>
        public static void AssertExpectedItemGroupCount(BuildResult actualResult, string itemType, int expectedCount)
        {
            Assert.IsNotNull(actualResult.ProjectStateAfterBuild, "Test error: ProjectStateAfterBuild should not be null");

            IEnumerable<ProjectItemInstance> matches = actualResult.ProjectStateAfterBuild.GetItems(itemType);

            BuildUtilities.LogMessage("Analyzers:");
            foreach(ProjectItemInstance item in matches)
            {
                BuildUtilities.LogMessage("\t{0}", item.EvaluatedInclude);
            }

            Assert.AreEqual(expectedCount, matches.Count(), "Unexpected number of '{0}' items", itemType);
        }
开发者ID:clintcparker,项目名称:sonar-msbuild-runner,代码行数:17,代码来源:BuildAssertions.cs

示例11: TestSimpleStateProgression

        public void TestSimpleStateProgression()
        {
            // Start in Ready
            BuildRequest request = CreateNewBuildRequest(1, new string[1] { "foo" });
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
            BuildRequestEntry entry = new BuildRequestEntry(request, config);
            Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
            Assert.AreEqual(entry.Request, request);
            Assert.IsNull(entry.Result);

            // Move to active.  Should not be any results yet.
            IDictionary<int, BuildResult> results = entry.Continue();
            Assert.AreEqual(entry.State, BuildRequestEntryState.Active);
            Assert.IsNull(entry.Result);
            Assert.IsNull(results);

            // Wait for results, move to waiting.
            BuildRequest waitingRequest = CreateNewBuildRequest(2, new string[1] { "bar" });
            entry.WaitForResult(waitingRequest);
            Assert.AreEqual(entry.State, BuildRequestEntryState.Waiting);
            Assert.AreEqual(entry.Request, request);
            Assert.IsNull(entry.Result);

            // Provide the results, move to ready.
            BuildResult requiredResult = new BuildResult(waitingRequest);
            requiredResult.AddResultsForTarget("bar", TestUtilities.GetEmptySucceedingTargetResult());
            entry.ReportResult(requiredResult);
            Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
            Assert.AreEqual(entry.Request, request);
            Assert.IsNull(entry.Result);

            // Continue the build, move to active.
            results = entry.Continue();
            Assert.AreEqual(entry.State, BuildRequestEntryState.Active);
            Assert.IsNull(entry.Result);
            Assert.AreEqual(results.Count, 1);
            Assert.IsTrue(results.ContainsKey(requiredResult.NodeRequestId));
            Assert.AreEqual(results[requiredResult.NodeRequestId], requiredResult);

            // Complete the build, move to completed.
            BuildResult result = new BuildResult(request);
            result.AddResultsForTarget("foo", TestUtilities.GetEmptySucceedingTargetResult());
            entry.Complete(result);
            Assert.AreEqual(entry.State, BuildRequestEntryState.Complete);
            Assert.IsNotNull(entry.Result);
            Assert.AreEqual(entry.Result, result);
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:47,代码来源:BuildRequestEntry_Tests.cs

示例12: TestAddAndRetrieveResultsByConfiguration

        public void TestAddAndRetrieveResultsByConfiguration()
        {
            ResultsCache cache = new ResultsCache();
            BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "testTarget" }, null, BuildEventContext.Invalid, null);
            BuildResult result = new BuildResult(request);
            result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult());
            cache.AddResult(result);

            request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] { "otherTarget" }, null, BuildEventContext.Invalid, null);
            result = new BuildResult(request);
            result.AddResultsForTarget("otherTarget", TestUtilities.GetEmptySucceedingTargetResult());
            cache.AddResult(result);

            BuildResult retrievedResult = cache.GetResultsForConfiguration(1);

            Assert.True(retrievedResult.HasResultsForTarget("testTarget"));
            Assert.True(retrievedResult.HasResultsForTarget("otherTarget"));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:18,代码来源:ResultsCache_Tests.cs

示例13: InternalExecute

		internal BuildResult InternalExecute ()
		{
			BuildResult = new BuildResult () { SubmissionId = SubmissionId };
			try {
				var engine = new BuildEngine4 (this);
				string toolsVersion = request.ExplicitlySpecifiedToolsVersion ?? request.ProjectInstance.ToolsVersion ?? BuildManager.OngoingBuildParameters.DefaultToolsVersion;
				var outputs = new Dictionary<string,string> ();
				engine.BuildProject (() => is_canceled, BuildResult, request.ProjectInstance, request.TargetNames, BuildManager.OngoingBuildParameters.GlobalProperties, outputs, toolsVersion);
			} catch (Exception ex) {
				BuildResult.Exception = ex;
				BuildResult.OverallResult = BuildResultCode.Failure;
			}
			is_completed = true;
			if (callback != null)
				callback (this);
			wait_handle.Set ();
			return BuildResult;
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:18,代码来源:BuildSubmission.cs

示例14: MergeResults

		public void MergeResults (BuildResult results)
		{
			if (ConfigurationId != results.ConfigurationId)
				throw new InvalidOperationException ("Argument BuildResults have inconsistent ConfigurationId.");
			if (GlobalRequestId != results.GlobalRequestId)
				throw new InvalidOperationException ("Argument BuildResults have inconsistent GlobalRequestId.");
			if (NodeRequestId != results.NodeRequestId)
				throw new InvalidOperationException ("Argument BuildResults have inconsistent NodeRequestId.");
			if (ParentGlobalRequestId != results.ParentGlobalRequestId)
				throw new InvalidOperationException ("Argument BuildResults have inconsistent ParentGlobalRequestId.");
			if (SubmissionId != results.SubmissionId)
				throw new InvalidOperationException ("Argument BuildResults have inconsistent SubmissionId.");
			
			CircularDependency |= results.CircularDependency;
			Exception = Exception ?? results.Exception;
			foreach (var p in results.ResultsByTarget)
				ResultsByTarget.Add (p.Key, p.Value);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:18,代码来源:BuildResult.cs

示例15: DumpTargetResult

        /// <summary>
        /// Writes the build and target output to the output stream
        /// </summary>
        public static void DumpTargetResult(BuildResult result, string target)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            BuildUtilities.LogMessage("Overall build result: {0}", result.OverallResult.ToString());

            TargetResult targetResult;
            if (!result.ResultsByTarget.TryGetValue(target, out targetResult))
            {
                BuildUtilities.LogMessage(@"Could not find result for target ""{0}""", target);
            }
            else
            {
                BuildUtilities.LogMessage(@"Results for target ""{0}""", target);
                BuildUtilities.LogMessage("\tTarget exception: {0}", targetResult.Exception == null ? "{null}" : targetResult.Exception.Message);
                BuildUtilities.LogMessage("\tTarget result: {0}", targetResult.ResultCode.ToString());
            }
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:24,代码来源:BuildAssertions.cs


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