LogWarning() public method

public LogWarning ( string file, string errorCode, string message, int line, int column ) : void
file string
errorCode string
message string
line int
column int
return void
示例#1
0
        void ParseInput()
        {
            var utilValues = Enum.GetValues(typeof(BuildUtilityTaskEnum)).Cast <BuildUtilityTaskEnum>();

            if (!string.IsNullOrWhiteSpace(UtilityName))
            {
                foreach (BuildUtilityTaskEnum member in utilValues)
                {
                    if (member.GetDescriptionAttributeValue().Equals(UtilityName, StringComparison.OrdinalIgnoreCase))
                    {
                        BuildUtility = member;
                        break;
                    }
                }
            }

            if (BuildUtility == BuildUtilityTaskEnum.NotSupported)
            {
                string helpStrFormat = "msbuild build.proj /t:Util /p:UtilityName={0}";
                foreach (BuildUtilityTaskEnum member in utilValues)
                {
                    if (member != BuildUtilityTaskEnum.NotSupported)
                    {
                        TaskLogger.LogWarning(helpStrFormat, member.ToString());
                    }
                }
                //TaskLogger.LogException<ApplicationException>("Unable to execute task without valid UtilityName");
            }
        }
        public override bool Execute()
        {
            base.Execute();
            try
            {
                Init();

                List <string> validScopes = new List <string>();

                if (GH_PRNumber > 0)
                {
                    validScopes = GetRPScopes();
                    if (validScopes.NotNullOrAny <string>())
                    {
                        ScopesFromPR  = validScopes.ToArray <string>();
                        PRScopeString = string.Join(";", ScopesFromPR);
                    }
                }
                else
                {
                    // This helps in pass thru for scenarios where this task is being invoked without
                    // any valid PR info
                    ScopesFromPR = validScopes.ToArray <string>();
                }
            }
            catch (Exception ex)
            {
                TaskLogger.LogWarning(ex.ToString());
            }

            return(TaskLogger.TaskSucceededWithNoErrorsLogged);
        }
示例#3
0
        private void CopyDirectory(string sourceDirName, string destDirName)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(sourceDirName);

            if (!directoryInfo.Exists)
            {
                TaskLogger.LogWarning(Strings.WarningLPDirectoryNotFound(sourceDirName));
                return;
            }
            DirectoryInfo[] directories = directoryInfo.GetDirectories();
            if (!Directory.Exists(destDirName))
            {
                Directory.CreateDirectory(destDirName);
            }
            FileInfo[] files = directoryInfo.GetFiles();
            foreach (FileInfo fileInfo in files)
            {
                string text = Path.Combine(destDirName, fileInfo.Name);
                if (!File.Exists(text))
                {
                    fileInfo.CopyTo(text, true);
                }
            }
            foreach (DirectoryInfo directoryInfo2 in directories)
            {
                string destDirName2 = Path.Combine(destDirName, directoryInfo2.Name);
                this.CopyDirectory(directoryInfo2.FullName, destDirName2);
            }
        }
        /// <summary>
        /// Detect valid scope based on the change list in the PR
        /// Get affected files and find scope based on directory that contains .sln file
        /// </summary>
        /// <returns></returns>
        List <string> GetRPScopes()
        {
            FileSystemUtility    fileSysUtil        = new FileSystemUtility();
            IEnumerable <string> prFileList         = null;
            List <string>        finalScopePathList = new List <string>();
            List <string>        intermediateList   = new List <string>();

            if (!string.IsNullOrWhiteSpace(GitHubRepositoryHtmlUrl))
            {
                TaskLogger.LogInfo("Trying to get Pr info using PrNumber:'{0}', GitHubUrl:'{1}'", GH_PRNumber.ToString(), GitHubRepositoryHtmlUrl);

                string repoName = string.Empty;
                //Split the url
                string[] tokens = GitHubRepositoryHtmlUrl.Split(new char[] { Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

                //Get the last token which represents the repository name
                if (tokens != null)
                {
                    repoName = tokens[tokens.Length - 1];
                }

                if (GHSvc.IsRepoAuthorized(repoName))
                {
                    prFileList = GHSvc.PR.GetPullRequestFileList(repoName, GH_PRNumber);
                }
            }
            else
            {
                TaskLogger.LogWarning("You are not authorized to access '{0}', skipping detecting RP Scope", GitHubRepositoryHtmlUrl);
            }

            if (prFileList != null)
            {
                TaskLogger.LogInfo(MessageImportance.Low, prFileList, "List of files from PR");
                Dictionary <string, string> RPDirs = FindScopeFromPullRequestFileList(prFileList);

                if (RPDirs.NotNullOrAny <KeyValuePair <string, string> >())
                {
                    intermediateList = RPDirs.Select <KeyValuePair <string, string>, string>((item) => item.Key).ToList <string>();
                }

                if (DetectEnv.IsRunningUnderNonWindows)
                {
                    foreach (string scopePath in intermediateList)
                    {
                        string newPath = scopePath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                        finalScopePathList.Add(newPath);
                    }
                }
                else
                {
                    finalScopePathList = intermediateList;
                }
            }

            return(finalScopePathList);
        }
示例#5
0
 private object ParseCmdletParameter(string line, string eventLog)
 {
     try
     {
         AdminAuditLogCmdletParameter item = AdminAuditLogCmdletParameter.Parse(line);
         this.CmdletParameters.Add(item);
     }
     catch (ArgumentException)
     {
         TaskLogger.LogWarning(Strings.WarningInvalidParameterOrModifiedPropertyInAdminAuditLog(eventLog));
     }
     return(null);
 }
        public override bool Execute()
        {
            base.Execute();
            if (WhatIf)
            {
                WhatIfAction();
            }
            else
            {
                List <string> ScopedProjects = new List <string>();

                // We will not skip broad build scope (e.g. sdk), the idea is to not to skip all the tests in a broader build scope.
                if (string.IsNullOrWhiteSpace(BuildScope))
                {
                    TaskLogger.LogWarning("BuildScope is required to skip tests.");
                }
                else if (BuildScope.Equals("sdk", StringComparison.OrdinalIgnoreCase))
                {
                    TaskLogger.LogWarning("'{0}' BuildScope is not supported", BuildScope);
                }
                else
                {
                    CategorizeSDKProjectsTask catProj = new CategorizeSDKProjectsTask(RepositoryRootDirPath, BuildScope, BuildScopes, ProjectType, ProjectCategory);
                    catProj.Execute();

                    var sdkProj  = catProj.SDK_Projects.Select <SDKMSBTaskItem, string>((item) => item.ItemSpec);
                    var testProj = catProj.Test_Projects.Select <SDKMSBTaskItem, string>((item) => item.ItemSpec);

                    if (sdkProj.NotNullOrAny <string>())
                    {
                        ScopedProjects.AddRange(sdkProj.ToList <string>());
                    }

                    if (testProj.NotNullOrAny <string>())
                    {
                        ScopedProjects.AddRange(testProj.ToList <string>());
                    }

                    UpdateProjects(ScopedProjects);
                    ScopedProjects.Clear();
                }
            }

            return(TaskLogger.TaskSucceededWithNoErrorsLogged);
        }
        void Init()
        {
            //string exceptionStringFormat = "Only numeric datatype is supported. Provided value has to be non-negative and non-zero '{0}'";


            if (GH_RepositoryId <= 0)
            {
                if (string.IsNullOrWhiteSpace(GH_RepositoryHtmlUrl))
                {
                    //throw new ArgumentException("Provide either Repository Id or Repositry Url");
                    TaskLogger.LogWarning("Repository Html Url not provided");
                }
            }

            if (GH_PRNumber < 0)
            {
                throw new ArgumentException("Provide non-zero, non-negative PR Number");
            }
        }
示例#8
0
        private void CopyLanguageDirectories(string sourcePathForLPfiles, string destinationPathForLPfiles)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(sourcePathForLPfiles);

            if (directoryInfo.Exists)
            {
                DirectoryInfo[] directories = directoryInfo.GetDirectories();
                foreach (DirectoryInfo directoryInfo2 in directories)
                {
                    try
                    {
                        CultureInfo.GetCultureInfo(directoryInfo2.Name);
                        this.CopyDirectory(directoryInfo2.FullName, destinationPathForLPfiles + directoryInfo2.Name);
                    }
                    catch (CultureNotFoundException)
                    {
                    }
                }
                return;
            }
            TaskLogger.LogWarning(Strings.WarningLPDirectoryNotFound(sourcePathForLPfiles));
        }
示例#9
0
 private object ParseModifiedProperty(string line, Dictionary <string, AdminAuditLogModifiedProperty> modifiedProperties, bool newValue, string eventLog)
 {
     try
     {
         AdminAuditLogModifiedProperty adminAuditLogModifiedProperty = AdminAuditLogModifiedProperty.Parse(line, newValue);
         if (modifiedProperties.ContainsKey(adminAuditLogModifiedProperty.Name))
         {
             if (newValue)
             {
                 if (modifiedProperties[adminAuditLogModifiedProperty.Name].NewValue != null)
                 {
                     TaskLogger.LogWarning(Strings.WarningDuplicatedPropertyModifiedEntry(adminAuditLogModifiedProperty.Name));
                 }
                 modifiedProperties[adminAuditLogModifiedProperty.Name].NewValue = adminAuditLogModifiedProperty.NewValue;
             }
             else
             {
                 if (modifiedProperties[adminAuditLogModifiedProperty.Name].OldValue != null)
                 {
                     TaskLogger.LogWarning(Strings.WarningDuplicatedPropertyOriginalEntry(adminAuditLogModifiedProperty.Name));
                 }
                 modifiedProperties[adminAuditLogModifiedProperty.Name].OldValue = adminAuditLogModifiedProperty.OldValue;
             }
         }
         else
         {
             this.ModifiedProperties.Add(adminAuditLogModifiedProperty);
             modifiedProperties[adminAuditLogModifiedProperty.Name] = adminAuditLogModifiedProperty;
         }
     }
     catch (ArgumentException)
     {
         TaskLogger.LogWarning(Strings.WarningInvalidParameterOrModifiedPropertyInAdminAuditLog(eventLog));
     }
     return(null);
 }
示例#10
0
 public void LogWarning(LocalizedString localizedString)
 {
     TaskLogger.LogWarning(localizedString);
 }
        /// <summary>
        /// Get list of scopes from PR file list
        /// </summary>
        /// <returns></returns>
        Dictionary <string, string> FindScopeFromPullRequestFileList(IEnumerable <string> prFileList)
        {
            Dictionary <string, string> scopeDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            List <string> finalScopePathList            = new List <string>();

            // Assumption:
            // GH API gives relative paths from root
            // So we assume that we will get relative paths that starts after root

            // Currently only supporting .NET SDK repos (both public and private repos)
            // Taking hard dependency on current directory structure, any change in directory strucutre will affect this functionality
            // Alternate way:
            // We can always make Rest calls to find directory location for .sln file, but this approach will hamper the funtionality due to restriction on Github API rate limit
            // On average .NET SDK PR contains 50 files (that will result in at least minimum 3 REST calls for every PR)
            // hence we are taking hard dependency on directory structure and making certain assumptions based on the repository

            //Assumption: we are interested in paths that start with sdk and we only need sdk/<rpName>/<pkgName>
            foreach (string prFilePath in prFileList)
            {
                if (prFilePath.StartsWith("sdk", StringComparison.OrdinalIgnoreCase) || prFilePath.StartsWith("src", StringComparison.OrdinalIgnoreCase))
                {
                    string[] tokens = prFilePath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                    if (tokens.NotNullOrAny <string>())
                    {
                        if (tokens.Length >= 3)
                        {
                            string relScopePath = string.Empty;
                            if (tokens[0].Equals("src", StringComparison.OrdinalIgnoreCase))
                            {
                                relScopePath = Path.Combine(tokens[1], tokens[2]);
                            }
                            else
                            {
                                relScopePath = Path.Combine(tokens[0], tokens[1], tokens[2]);
                            }

                            relScopePath = AdjustPlatformPaths(relScopePath);

                            if (!relScopePath.EndsWith("_metadata", StringComparison.OrdinalIgnoreCase))
                            {
                                if (!scopeDictionary.ContainsKey(relScopePath))
                                {
                                    scopeDictionary.Add(relScopePath, prFilePath);
                                }
                            }
                        }
                    }
                }
                else if (prFilePath.StartsWith("eng", StringComparison.OrdinalIgnoreCase))
                {
                    // Anything outside of sdk should be treated as if a common props file was changed and so
                    // the entire mgmt sdks should be built and all tests should be ran
                    TaskLogger.LogWarning("Detected common files were changed. All mgmt sdks will be built.");
                    scopeDictionary.Clear();
                    break;
                }
            }

            return(scopeDictionary);
        }
示例#12
0
        private void ParseInput()
        {
            foreach (SDKMSBTaskItem sdkProjTaskItem in SdkProjectFilePaths)
            {
                string azPropFilePath = string.Empty;
                string asmPath        = string.Empty;
                string projectName    = Path.GetFileNameWithoutExtension(sdkProjTaskItem.ItemSpec);
                string dllName        = string.Format("{0}.dll", projectName);

                //e.g. <root>\artifacts\bin\Microsoft.Azure.Management.Billing\Debug\
                string outputDirRootPath = sdkProjTaskItem.OutputPath;
                string azSdkPropDirPath  = FileSysUtil.TraverseUptoRootWithFileToken(PROPS_APITAG_FILE_NAME, Path.GetDirectoryName(sdkProjTaskItem.ItemSpec));

                if (string.IsNullOrWhiteSpace(azSdkPropDirPath))
                {
                    azSdkPropDirPath = FileSysUtil.TraverUptoRootWithFileExtension(Path.GetDirectoryName(sdkProjTaskItem.ItemSpec));
                }

                if (Directory.Exists(azSdkPropDirPath))
                {
                    azPropFilePath = Path.Combine(azSdkPropDirPath, PROPS_APITAG_FILE_NAME);
                }

                var files = FileSysUtil.FindFilePaths(outputDirRootPath, dllName);

                if (files.NotNullOrAny <string>())
                {
                    var asms = files.Where <string>((item) => item.Contains("netstandard2.0", StringComparison.OrdinalIgnoreCase));
                    //var asms = files.Where<string>((item) => item.Contains("net45", StringComparison.OrdinalIgnoreCase));

                    if (asms.NotNullOrAny <string>())
                    {
                        asmPath = asms.FirstOrDefault <string>();
                        TaskLogger.LogInfo(MessageImportance.High, "Assembly that will be used to get SdkInfo '{0}'", asmPath);
                    }
                    else
                    {
                        TaskLogger.LogWarning("Unable to find built assembly. Please build your project and try again.");
                    }
                }

                if (!File.Exists(azPropFilePath))
                {
                    AzPropFileExists = false;
                }

                if (!File.Exists(asmPath))
                {
                    AssemblyFilePathExists = false;
                    TaskLogger.LogWarning("'{0}' does not exist. Build project '{1}'", asmPath, sdkProjTaskItem.ItemSpec);
                }

                if (File.Exists(sdkProjTaskItem.ItemSpec) &&
                    //AzPropFileExists == true &&
                    AssemblyFilePathExists == true)
                {
                    dynamic newObj = new ExpandoObject();
                    //dynamic newObj = new SDKMSBTaskItem(sdkProjTaskItem);
                    newObj.AzPropFilePath   = azPropFilePath;
                    newObj.AssemblyFilePath = asmPath;
                    newObj.ProjectFilePath  = sdkProjTaskItem.ItemSpec;

                    AssemblyInfoList.Add(newObj);

                    //Tuple<string, string, string> asmTuple = new Tuple<string, string, string>(sdkProjTaskItem.ItemSpec, azPropFilePath, asmPath);
                    //AssemblyInfoList.Add(asmTuple);
                }
            }
        }
 protected override void WhatIfAction()
 {
     TaskLogger.LogWarning("WhatIf Action not implemented");
 }