public bool IsValid(IDiagnosticLogger?logger, bool?isDevelopmentBuild = null) { if (!UploadSymbols) { logger?.LogDebug("sentry-cli: Automated symbols upload has been disabled."); return(false); } if ((isDevelopmentBuild ?? EditorUserBuildSettings.development) && !UploadDevelopmentSymbols) { logger?.LogDebug("sentry-cli: Automated symbols upload for development builds has been disabled."); return(false); } var validated = true; if (string.IsNullOrWhiteSpace(Auth)) { MissingFieldWarning(logger, "Auth name"); validated = false; } if (string.IsNullOrWhiteSpace(Organization)) { MissingFieldWarning(logger, "Organization"); validated = false; } if (string.IsNullOrWhiteSpace(Project)) { MissingFieldWarning(logger, "Project"); validated = false; } if (!validated) { logger?.LogWarning("sentry-cli validation failed. Symbols will not be uploaded." + "\nYou can disable this warning by disabling the automated symbols upload under " + EditorMenuPath); } return(validated); }
public void AddBuildPhaseSymbolUpload(IDiagnosticLogger?logger) { if (MainTargetContainsSymbolUploadBuildPhase()) { logger?.LogDebug("Build phase '{0}' already added.", SymbolUploadPhaseName); return; } _pbxProjectType.GetMethod("AddShellScriptBuildPhase", new[] { typeof(string), typeof(string), typeof(string), typeof(string) }) .Invoke(_project, new object[] { _mainTargetGuid, SymbolUploadPhaseName, "/bin/sh", _uploadScript }); }
internal static void CopyFile(string sourcePath, string targetPath, IDiagnosticLogger?logger) { if (File.Exists(targetPath)) { logger?.LogDebug("'{0}' has already been copied to '{1}'", Path.GetFileName(targetPath), targetPath); return; } if (File.Exists(sourcePath)) { logger?.LogDebug("Copying from: '{0}' to '{1}'", sourcePath, targetPath); Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(targetPath))); FileUtil.CopyFileOrDirectory(sourcePath, targetPath); } if (!File.Exists(targetPath)) { throw new FileNotFoundException($"Failed to copy '{sourcePath}' to '{targetPath}'"); } }
internal static void AddExecutableToXcodeProject(string projectPath, IDiagnosticLogger? logger) { var executableSource = GetSentryCliPath(SentryCliMacOS); var executableDestination = Path.Combine(projectPath, SentryCliMacOS); if (!Directory.Exists(projectPath)) { throw new DirectoryNotFoundException($"Xcode project directory not found at {executableDestination}"); } if (File.Exists(executableDestination)) { logger?.LogDebug("sentry-cli executable already found at {0}", executableDestination); return; } File.Copy(executableSource, executableDestination); SetExecutePermission(executableDestination); }
internal void RemovePreviousConfigurations() { var nodesToRemove = new List <XmlNode>(); foreach (XmlNode node in _applicationElement.ChildNodes) { if (node.Name.Equals("meta-data")) { foreach (XmlAttribute attr in node.Attributes) { if (attr.Prefix.Equals(AndroidNsPrefix) && attr.LocalName.Equals("name") && attr.Value.StartsWith(_prefix)) { _logger?.LogDebug("Removing AndroidManifest meta-data '{0}'", attr.Value); nodesToRemove.Add(node); break; } } } } foreach (XmlNode node in nodesToRemove) { _ = node.ParentNode.RemoveChild(node); } }
private static void UploadDebugSymbols(IDiagnosticLogger logger, string projectDir, string executableName) { var cliOptions = SentryCliOptions.LoadCliOptions(); if (!cliOptions.IsValid(logger)) { return; } logger.LogInfo("Uploading debugging information using sentry-cli in {0}", projectDir); var paths = ""; Func <string, bool> addPath = (string name) => { var fullPath = Path.Combine(projectDir, name); if (Directory.Exists(fullPath) || File.Exists(fullPath)) { paths += $" \"{name}\""; logger.LogDebug($"Adding '{name}' to the debug-info upload"); return(true); } else { logger.LogWarning($"Coudn't find '{name}' - debug symbol upload will be incomplete"); return(false); } }; addPath(executableName); addPath("GameAssembly.dll"); addPath("UnityPlayer.dll"); addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame"); addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/Plugins/x86_64/sentry.dll"); // Note: using Path.GetFullPath as suggested by https://docs.unity3d.com/Manual/upm-assets.html addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb")); // Configure the process using the StartInfo properties. var process = new Process { StartInfo = new ProcessStartInfo { FileName = SentryCli.SetupSentryCli(), WorkingDirectory = projectDir, Arguments = "upload-dif " + paths, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; process.StartInfo.EnvironmentVariables["SENTRY_ORG"] = cliOptions.Organization; process.StartInfo.EnvironmentVariables["SENTRY_PROJECT"] = cliOptions.Project; process.StartInfo.EnvironmentVariables["SENTRY_AUTH_TOKEN"] = cliOptions.Auth; process.OutputDataReceived += (sender, args) => logger.LogDebug($"sentry-cli: {args.Data.ToString()}"); process.ErrorDataReceived += (sender, args) => logger.LogError($"sentry-cli: {args.Data.ToString()}"); process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); }