문제

우리는 팀이 새로운 기능을 추가하는 동시에 큰 무리의 갈색 필드 코드를 정리하려고 시도하고 있습니다. 우리는 컴파일러 / 코드 분석이나 기타 경고에서 변경되고 새로운 코드가 청소되었지만 현재 솔루션을 정리하여 시작하는 데 너무 많은 사람들이 있습니다.

TFS 2010을 사용하고 있습니다.

다음은 제안되었습니다 :

  • 빌드의 경고 목록을 해당 체크인으로 변경된 코드 줄과 비교하는 빌드 활동을 작성 / 선택하십시오.
  • 경고가 줄 번호를 제공하고 행 번호가 변경된 경우 빌드가 실패합니다.

    나는 이것이 모든 새로운 경고를 찾지 못하고 코드의 다른 부분에서 소개 된 것들을 찾지 못할 것입니다. 그러나 적어도 무언가입니다.

    제안 된 다른 옵션 :

    • 이 빌드 목록에 대해 이전의 알려진 좋은 빌드의 경고 목록을 비교하십시오. 새 경고가있는 경우 (파일 이름 수준 트랙)이있는 경우 빌드를 실패합니다.

      밖의 알려진 조치는 상기 기능을 제공 할 수 있습니까?

      코드 커버리지 보고서에 따라 행동 할 수있는 유사한 조치는 무엇입니까?

도움이 되었습니까?

해결책

이 다음 활동은 현재 빌드가 마지막 빌드와 false가 상승한 경우 New 경고 및 / 또는 코드에서의 위치가있는 현재는 명확하게 우수 할 것입니다. 그러나 이것은 이것이 흥미로운 창을 생각할 수 있습니다 :

using System;
using System.Activities;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;

namespace CheckWarnings
{
    [BuildActivity(HostEnvironmentOption.Agent)]
    public sealed class CheckWarnings : CodeActivity<bool>
    {
        [RequiredArgument]
        public InArgument<IBuildDetail> CurrentBuild { get; set; }  //buildDetail
        public InArgument<string> Configuration { get; set; }       //platformConfiguration.Configuration
        public InArgument<string> Platform { get; set; }            //platformConfiguration.Platform


        protected override bool Execute(CodeActivityContext context)
        {
            IBuildDetail currentBuildDetail = context.GetValue(CurrentBuild);
            string currentConfiguration = context.GetValue(Configuration);
            string currentPlatform = context.GetValue(Platform);

            Uri lastKnownGoodBuildUri = currentBuildDetail.BuildDefinition.LastGoodBuildUri;
            IBuildDetail lastKnownGoodBuild = currentBuildDetail.BuildServer.GetBuild(lastKnownGoodBuildUri);

            int numOfCurrentWarnings = GetNumberOfWarnings(currentBuildDetail, currentConfiguration, currentPlatform);
            context.TrackBuildMessage("Current compile presents " + numOfCurrentWarnings + " warnings.", BuildMessageImportance.Normal);

            int numOfLastGoodBuildWarnings = GetNumberOfWarnings(lastKnownGoodBuild, currentConfiguration,
                                                                 currentPlatform);
            context.TrackBuildMessage("Equivalent last good build compile presents " + numOfLastGoodBuildWarnings + " warnings.", BuildMessageImportance.Normal);

            if (numOfLastGoodBuildWarnings < numOfCurrentWarnings)
            {
                return true;
            }
            return false;
        }

        private static int GetNumberOfWarnings(IBuildDetail buildDetail, string configuration, string platform)
        {
            var buildInformationNodes =
                buildDetail.Information.GetNodesByType("ConfigurationSummary");

            foreach (var buildInformationNode in buildInformationNodes)
            {
                string localPlatform, numOfWarnings;
                string localConfiguration = localPlatform = numOfWarnings = "";
                foreach (var field in buildInformationNode.Fields)
                {

                    if (field.Key == "Flavor")
                    {
                        localConfiguration = field.Value;
                    }
                    if (field.Key == "Platform")
                    {
                        localPlatform = field.Value;
                    }
                    if (field.Key == "TotalCompilationWarnings")
                    {
                        numOfWarnings = field.Value;
                    }
                }
                if(localConfiguration == configuration && localPlatform == platform)
                {
                    return Convert.ToInt32((numOfWarnings));
                }
            }
            return 0;
        }
    }
}
.

이 액티비티는 예외 처리를 제공하지 않으며 빌드 정의가 둘 이상의 솔루션을 구축 할 경우를 대비하여 추가로 정제해야합니다.true 활동 직후 직접 배치해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top