NuGetVersion GetMinimumNuGetVersion(string versionString) { //Check.NotEmptyNotNull(versionString); VersionRange verRange; NuGetVersion ver = null; if (VersionRange.TryParse(versionString, out verRange)) { if (verRange.MinVersion != null) { UtilLogger.LogInfo(MessageImportance.Low, "Minimum version detected '{0}'", verRange.MinVersion.ToString()); ver = verRange.MinVersion; } if (verRange.MaxVersion != null) { UtilLogger.LogInfo(MessageImportance.Low, "Maximum version detected '{0}'", verRange.MaxVersion.ToString()); } } else { UtilLogger.LogWarning("Unable to parse version string '{0}'", versionString); } return(ver); }
/// <summary> /// Gets available version list of nuget packages using exact package Id /// TODO: /// If you want to filter on pre-release and stable, provide the override for the function /// the URL has two properties, package id and if it's a pre-release /// </summary> /// <param name="exactPackageId"></param> /// <returns></returns> public List <NuGetVersion> GetAvailablePackageVersion(string exactPackageId, bool includePreRelease = true) { List <string> responseVerList = null; //List<Version> availableVersionList = new List<Version>(); List <NuGetVersion> availableVersionList = new List <NuGetVersion>(); string endPointUrl = string.Format(Nuget_Operation_EnumPkgVersions, exactPackageId, includePreRelease); Task <RestClientResponse <EnumeratePkgVersionModel> > pkgVersionTask = Task.Run <RestClientResponse <EnumeratePkgVersionModel> >(async() => await this.ExecuteRequest <EnumeratePkgVersionModel>(endPointUrl, HttpMethod.Get).ConfigureAwait(false)); RestClientResponse <EnumeratePkgVersionModel> rcResponse = pkgVersionTask.GetAwaiter().GetResult(); EnumeratePkgVersionModel enumVers = rcResponse.Body; responseVerList = enumVers.data; if (responseVerList == null) { //throw new ApplicationException("Unable to retrieve available package versions. Please try again"); UtilLogger.LogWarning("Unable to retrieve available package versions for nuget pacakge '{0}'", exactPackageId); } foreach (string ver in responseVerList) { NuGetVersion nugVer = new NuGetVersion(ver); availableVersionList.Add(nugVer); } UtilLogger.LogInfo(availableVersionList, "Available versions on nuget.org for Pacakge '{0}'", exactPackageId); return(availableVersionList); }
public void AddUpdateProperty(string propertyName, string newPropertyValue) { ProjectProperty prop = LoadedProj.GetProperty(propertyName); UtilLogger.LogInfo(MessageImportance.Low, "Processing Project '{0}'", this.ProjectFilePath); if (prop == null) { UtilLogger.LogInfo(MessageImportance.Low, "'{0}' property not found. Adding/setting it's value to '{1}'", propertyName, newPropertyValue); LoadedProj.SetProperty(propertyName, newPropertyValue); LoadedProj.Save(this.ProjectFilePath); } else { string currentValue = prop.EvaluatedValue; if (string.IsNullOrWhiteSpace(currentValue)) { UtilLogger.LogInfo(MessageImportance.Low, "Setting '{0}' value to '{1}'", propertyName, newPropertyValue); LoadedProj.SetProperty(propertyName, newPropertyValue); LoadedProj.Save(this.ProjectFilePath); } else { UtilLogger.LogInfo(MessageImportance.Low, "Current value of '{0}' is '{1}'", propertyName, newPropertyValue); if (!currentValue.Equals(newPropertyValue, StringComparison.OrdinalIgnoreCase)) { UtilLogger.LogInfo(MessageImportance.Low, "Setting '{0}' value to '{1}'", propertyName, newPropertyValue); LoadedProj.SetProperty(propertyName, newPropertyValue); LoadedProj.Save(this.ProjectFilePath); } } } }
public Dictionary <string, string> GetMatchingPropertyAndValues(string propertyName, StringComparison comparisonType) { Dictionary <string, string> propValue = null; List <string> matchProps = GetMatchingProperties(propertyName, comparisonType); if (matchProps.Any <string>()) { propValue = new Dictionary <string, string>(); foreach (string pName in matchProps) { string pValue = GetPropertyValue(pName); if (string.IsNullOrWhiteSpace(pValue)) { propValue.Add(pName, string.Empty); } else { propValue.Add(pName, pValue); } } UtilLogger.LogInfo(propValue, "Matching Property names and it's associated Values"); } else { UtilLogger.LogInfo("Unable to find any properties by the name '{0}'", propertyName); } return(propValue); }
public TargetFx(string projectFilePath, string targetFxMoniker, string baselineFxMoniker, SdkProjectType projectType, bool skipBaselineTargetFxMatching) { Check.NotEmptyNotNull(projectFilePath); Check.NotEmptyNotNull(targetFxMoniker); ProjectFile = projectFilePath; FxTargetMonikerString = targetFxMoniker; ProjectType = projectType; SkipBaselineTargetFxMatching = skipBaselineTargetFxMatching; if (string.IsNullOrWhiteSpace(baselineFxMoniker)) { if (ProjectType == SdkProjectType.Test) { FxBaselineMonikerString = BASELINE_TEST_FX_MONIKER; } else { FxBaselineMonikerString = BASELINE_SDK_FX_MONIKER; } } else { FxBaselineMonikerString = baselineFxMoniker; } UtilLogger.LogInfo(MessageImportance.Low, "Processing Project '{0}'", ProjectFile); UtilLogger.LogInfo(MessageImportance.Low, "Baseline Fx List '{0}'", FxBaselineMonikerString); UtilLogger.LogInfo(MessageImportance.Low, "Target Fx List '{0}'", FxTargetMonikerString); Init(); }
bool ParseInput() { bool srcDirExists = true; bool destinationDirExists = true; if (!Directory.Exists(PsModulesSourceRootDirPath)) { srcDirExists = false; UtilLogger.LogWarning("PsModuleSourceDir '{0}' does not exist", PsModulesSourceRootDirPath); } if (!Directory.Exists(UserModulesDirPath)) { if (DetectEnv.IsRunningUnderNonWindows) { UtilLogger.LogWarning("Current not supported on Non-Windows platform"); } else { UtilLogger.LogWarning("Unable to detect user modules directory. Usually on windows platform this directory looks like {0}'", UserModulesDirPath); } destinationDirExists = false; } return(srcDirExists && destinationDirExists); }
public List <string> GetMatchingProperties(string propertyName, StringComparison comparisonType) { Check.NotEmptyNotNull(propertyName); List <string> matchingProperties = null; ICollection <ProjectProperty> propCollection = LoadedProj.Properties; if (propCollection.Any <ProjectProperty>()) { var matchProps = from p in propCollection where p.Name.Contains(propertyName, comparisonType) select p; if (matchProps != null) { matchingProperties = new List <string>(); foreach (ProjectProperty pp in matchProps) { matchingProperties.Add(pp.Name); } UtilLogger.LogInfo(matchingProperties); } } else { UtilLogger.LogInfo(MessageImportance.Low, "Unable to find any properties by the name '{0}'", propertyName); } return(matchingProperties); }
void Update() { if (Input.GetKeyDown(KeyCode.Joystick1Button16)) { UtilLogger.Log(TAG, "A"); } }
void Init() { BaselineTargetFxList = GetFxList(FxBaselineMonikerString); TargetFxList = GetFxList(FxTargetMonikerString); UtilLogger.LogInfo(MessageImportance.Low, "Target Fx list '{0}' for '{1}' ProjectType. Expected baseline Fx list '{2}'", FxTargetMonikerString, ProjectType.ToString(), FxBaselineMonikerString); EnvironmentSpecificTargetFxList = GetPlatformSpecificApplicableFxList(); NotMatchingFxList = GetNotMatchingFxList(BaselineTargetFxList, EnvironmentSpecificTargetFxList); }
public Dictionary <string, string> GetNugetPkgRefsAndVersionInfo(bool skipVersionInfo = false) { Dictionary <string, string> pkgRefVer = null; List <Tuple <string, string, string> > pkgRefTup = new List <Tuple <string, string, string> >(); ICollection <ProjectItem> pkgRefItems = LoadedProj.GetItemsIgnoringCondition(ITEMGROUP_PKGREF); //ICollection<ProjectItem> pkgRefItems = LoadedProj.GetItemsByEvaluatedInclude(ITEMGROUP_PKGREF); //ICollection<ProjectItem> allItems = LoadedProj.ItemsIgnoringCondition; //ICollection<ProjectItem> pkgRefItems = allItems.Where<ProjectItem>((item) => item.ItemType.Equals(ITEMGROUP_PKGREF)).ToList<ProjectItem>(); string piPkgRef = string.Empty; string pkgRefVerStr = string.Empty; if (pkgRefItems.Any <ProjectItem>()) { pkgRefVer = new Dictionary <string, string>(); foreach (ProjectItem pi in pkgRefItems) { piPkgRef = pi.EvaluatedInclude; if (!pkgRefVer.ContainsKey(piPkgRef)) { if (skipVersionInfo == false) { ICollection <ProjectMetadata> mdCol = pi.Metadata; foreach (ProjectMetadata pimd in mdCol) { if (pimd.Name.Equals("Version", StringComparison.OrdinalIgnoreCase)) { string verStr = pimd.EvaluatedValue; if (!string.IsNullOrWhiteSpace(verStr)) { NuGetVersion ver = GetMinimumNuGetVersion(verStr); if (ver != null) { pkgRefVerStr = ver.ToString(); pkgRefVer.Add(piPkgRef, pkgRefVerStr); } break; } } } } else { pkgRefVer.Add(piPkgRef, pkgRefVerStr); } } } } UtilLogger.LogInfo(MessageImportance.Low, pkgRefVer, "Retrieved PackageReferences and it's version"); return(pkgRefVer); }
/// <summary> /// Get list of files for a particular commit /// </summary> /// <param name="repoDirPath"></param> /// <param name="gitHubForkName"></param> /// <param name="gitHubRepoName"></param> /// <param name="refCommit"></param> /// <returns></returns> public IEnumerable <String> GetDownloadUrlForFilesUnderDirectory(String repoDirPath, String gitHubForkName, String gitHubRepoName, String refCommit) { try { return(OctoClient.Repository.Content.GetAllContentsByRef(gitHubForkName, gitHubRepoName, repoDirPath, refCommit).Result.Select(item => item.DownloadUrl)); } catch (Exception ex) { UtilLogger.LogException(ex); throw; } }
public string GetPropertyValue(string propertyName) { var propValue = LoadedProj.GetPropertyValue(propertyName); UtilLogger.LogInfo(MessageImportance.Low, "'{0}' - '{1}'", propertyName, propValue); if (propValue == null) { return(string.Empty); } else { return(propValue); } }
public string GetPropertyName(string propertyName) { ProjectProperty prop = LoadedProj.GetProperty(propertyName); UtilLogger.LogInfo(MessageImportance.Low, "Retrieved Property - '{0}'", prop?.Name); if (prop == null) { return(string.Empty); } else { return(prop.Name); } }
public bool IsRepoAuthorized(string repoUrl) { bool isAuthorized = false; try { OctoClient.Repository.Get("Azure", repoUrl).GetAwaiter().GetResult(); isAuthorized = true; } catch (Exception ex) { UtilLogger.LogInfo("An error occured while initialzing Octokit client", ex.ToString()); } return(isAuthorized); }
void Init() { BaselineTargetFxList = GetFxList(FxBaselineMonikerString); TargetFxList = GetFxList(FxTargetMonikerString); UtilLogger.LogInfo(MessageImportance.Low, "Target Fx list '{0}' for '{1}' ProjectType. Expected baseline Fx list '{2}'", FxTargetMonikerString, ProjectType.ToString(), FxBaselineMonikerString); EnvironmentSpecificTargetFxList = GetPlatformSpecificApplicableFxList(); // We only allow to have non-standard target fx projects that are part of mgmtcommon if (SkipBaselineTargetFxMatching) { if (!ProjectFile.Contains(MgmtCommonDirToken)) { NotMatchingFxList = GetNotMatchingFxList(BaselineTargetFxList, EnvironmentSpecificTargetFxList); } } }
public void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs) { // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourceDirName); if (!dir.Exists) { throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " + sourceDirName); } DirectoryInfo[] dirs = dir.GetDirectories(); // If the destination directory doesn't exist, create it. if (!Directory.Exists(destDirName)) { UtilLogger.LogInfo("Creating directory '{0}'", destDirName); Directory.CreateDirectory(destDirName); } // Get the files in the directory and copy them to the new location. FileInfo[] files = dir.GetFiles(); //List<FileInfo> filteredFiles = files foreach (FileInfo file in files) { //if (file.Name.ToLower().EndsWith("nupkg") || // file.Name.ToLower().EndsWith("nupkg") || // file.Name.ToLower().EndsWith("nupkg")) //{ //} string temppath = Path.Combine(destDirName, file.Name); UtilLogger.LogInfo("Copying: Source: '{0}', Desitination: '{1}'", file.FullName, temppath); file.CopyTo(temppath, overwrite: true); } // If copying subdirectories, copy them and their contents to new location. if (copySubDirs) { foreach (DirectoryInfo subdir in dirs) { string temppath = Path.Combine(destDirName, subdir.Name); DirectoryCopy(subdir.FullName, temppath, copySubDirs); } } }
public string GetTempDirPath(string seedDirPath = "", string GIT_DIR_POSTFIX = "") { string newDir = "FSUtil"; int tempDirCount = 0; string initialTempDirPath = string.Empty; if (!string.IsNullOrWhiteSpace(seedDirPath)) { if (Directory.Exists(seedDirPath)) { initialTempDirPath = seedDirPath; } } if (string.IsNullOrWhiteSpace(initialTempDirPath)) { initialTempDirPath = Path.GetTempPath(); initialTempDirPath = Path.Combine(initialTempDirPath, newDir); } string tempFileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName()); tempFileName = string.Concat(tempFileName, GIT_DIR_POSTFIX); string tempDir = Path.Combine(initialTempDirPath, tempFileName); while (DirFileExists(tempDir) && tempDirCount < TEMP_DIR_COUNT) { tempFileName = string.Concat(Path.GetFileNameWithoutExtension(Path.GetTempFileName()), GIT_DIR_POSTFIX); tempDir = Path.Combine(Path.GetTempFileName(), tempFileName); tempDirCount++; } if (tempDirCount >= TEMP_DIR_COUNT) { ApplicationException appEx = new ApplicationException(string.Format("Cleanup temp directory. More than '{0}' directories detected with similar naming pattern: '{1}", TEMP_DIR_COUNT.ToString(), tempDir)); UtilLogger.LogException(appEx); } if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } return(tempDir); }
List <string> GetFxList(string fxMonikerString) { List <string> fxList = new List <string>(); var fxTokens = fxMonikerString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (fxTokens.Any <string>()) { fxList = fxTokens.ToList <string>(); //UtilLogger.LogInfo("Fx Moniker string:'{0}'", fxMonikerString); } else { UtilLogger.LogWarning("No Target Framework found"); } return(fxList); }
/// <summary> /// TODO: Move to MSAL ASAP /// </summary> /// <returns></returns> AuthenticationResult GetAdalToken() { AuthenticationResult token = null; ClientCredential cc = new ClientCredential(clientId, SpnSecret); AuthenticationContext authCtx = new AuthenticationContext(TenantAuthority, true); try { Task <AuthenticationResult> authResult = Task.Run(async() => await authCtx.AcquireTokenAsync(CommonConstants.AzureAuth.KVInfo.KVAudience, cc).ConfigureAwait(false)); token = authResult.Result; UtilLogger.LogInfo(MessageImportance.Low, "Successfully acquired Access Token"); expiryOffSet = token.ExpiresOn; } catch (Exception ex) { UtilLogger.LogError(ex.ToString()); } return(token); }
public MsbuildProject(string projectFullPath) : this() { Check.FileExists(projectFullPath); ProjectFilePath = projectFullPath; ProjectFileName = Path.GetFileName(ProjectFilePath); Object lockObj = new object(); lock (lockObj) { if (ProjectCollection.GlobalProjectCollection.GetLoadedProjects(projectFullPath).Count != 0) { LoadedProj = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(projectFullPath).FirstOrDefault <Project>(); } else { LoadedProj = new Project(projectFullPath); } } UtilLogger.LogInfo(MessageImportance.Low, "Loading Project '{0}'", projectFullPath); }
public string GetTargetFxMoniker() { string tfx = GetPropertyValue("TargetFramework"); if (string.IsNullOrWhiteSpace(tfx)) { tfx = GetPropertyValue("TargetFrameworks"); } if (string.IsNullOrWhiteSpace(tfx)) { UtilLogger.LogError("Missing Targetframework moniker"); } else { UtilLogger.LogInfo(MessageImportance.Low, "Targetframewok retrieved as '{0}'", tfx); } return(tfx); }
List <string> GetNotMatchingFxList(List <string> baseLineFxList, List <string> targetFxList) { List <string> notMatchingFx = new List <string>(); IEnumerable <string> misMatch = null; IsTargetFxMatch = true; if (baseLineFxList.Count > targetFxList.Count) { misMatch = baseLineFxList.Except <string>(targetFxList, new ObjectComparer <string>((lhs, rhs) => lhs.Equals(rhs, StringComparison.OrdinalIgnoreCase))); if (misMatch.NotNullOrAny <string>()) { IsTargetFxMatch = false; notMatchingFx = misMatch.ToList <string>(); UtilLogger.LogInfo("Target Fx that do not match the baseline", notMatchingFx); } } else if (targetFxList.Count > baseLineFxList.Count) { misMatch = targetFxList.Except <string>(baseLineFxList, new ObjectComparer <string>((lhs, rhs) => lhs.Equals(rhs, StringComparison.OrdinalIgnoreCase))); if (misMatch.NotNullOrAny <string>()) { IsTargetFxMatch = false; notMatchingFx = misMatch.ToList <string>(); UtilLogger.LogInfo("Target Fx that do not match the baseline", notMatchingFx); } } else if (targetFxList.Count == targetFxList.Count) { misMatch = targetFxList.Except <string>(baseLineFxList, new ObjectComparer <string>((lhs, rhs) => lhs.Equals(rhs, StringComparison.OrdinalIgnoreCase))); if (misMatch.NotNullOrAny <string>()) { IsTargetFxMatch = false; notMatchingFx = misMatch.ToList <string>(); UtilLogger.LogInfo("Target Fx that do not match the baseline", notMatchingFx); } } return(notMatchingFx); }
public List <PropertyInfo> GetProperties(string typeNameStartWith, string propertyName) { List <PropertyInfo> propertyList = new List <PropertyInfo>(); try { var exportedNS = GetAssembly(true).ExportedTypes.Select <Type, string>((item) => item.Namespace); var distinctNS = exportedNS.Distinct <string>(); Type sdkInfoType = null; foreach (string ns in distinctNS) { string fqtype = string.Format("{0}.sdkinfo", ns); sdkInfoType = GetAssembly(false).GetType(fqtype, throwOnError: true, ignoreCase: true); if (sdkInfoType != null) { break; } } UtilLogger.LogInfo("Querying Type '{0}' for propertyName '{1}'", sdkInfoType.Name, propertyName); PropertyInfo[] memInfos = sdkInfoType.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); foreach (PropertyInfo mInfo in memInfos) { UtilLogger.LogInfo("Found:'{0}'", mInfo.Name); if (mInfo.Name.Contains(propertyName)) { UtilLogger.LogInfo("Added:'{0}' to list", mInfo.Name); propertyList.Add(mInfo); } } } catch (Exception ex) { UtilLogger.LogWarning(ex.Message); } return(propertyList); }
public Assembly GetAssembly(bool useMetadataLoadContext) { Assembly loadedAssemly = null; if (useMetadataLoadContext) { if (!string.IsNullOrWhiteSpace(AssemblyToReflectFilePath)) { loadedAssemly = MetaCtx.LoadFromAssemblyPath(AssemblyToReflectFilePath); } else { UtilLogger.LogInfo(MetaCtx.ToString()); } } else { loadedAssemly = Assembly.LoadFrom(AssemblyToReflectFilePath); } return(loadedAssemly); }
/// <summary> /// Get applicable target fx list specific to the underlying platform /// </summary> /// <returns></returns> List <string> GetPlatformSpecificApplicableFxList() { List <string> envTargetFxList = new List <string>(); if (DetectEnv.IsRunningUnderNonWindows) { UtilLogger.LogInfo(MessageImportance.Low, "Non-Windows Platform Detected"); var applicableFx = TargetFxList.Where <string>((item) => !item.StartsWith("net4", StringComparison.OrdinalIgnoreCase)); if (applicableFx.NotNullOrAny <string>()) { envTargetFxList.AddRange(applicableFx); } } else { UtilLogger.LogInfo(MessageImportance.Low, "Windows Platform Detected"); envTargetFxList.AddRange(TargetFxList); } UtilLogger.LogInfo(MessageImportance.Low, envTargetFxList, "Platform specific Fx list"); return(envTargetFxList); }
void OnTriggerExit(Collider other) { UtilLogger.Log(TAG, "OnTriggerExit()"); // info.Hide(); }
void OnTriggerEnter(Collider other) { UtilLogger.Log(TAG, "OnTriggerEnter()"); // info.Show(); }
public ReflectionService() { UtilLogger.LogInfo(MessageImportance.Low, MetaCtx.ToString()); }