/// <summary> /// Check whether the deployment configuration of the binary works correctly /// with the mount configuration of the gamelet. /// </summary> /// <param name="targetPath">Path to the generated binary.</param> /// <param name="deployOnLaunchSetting">Project's "Deploy On Launch" value.</param> /// <param name="gamelet">Gamelet to connect to.</param> /// <returns>True if no issues found or the user decided to proceed.</returns> bool ValidateMountConfiguration(string targetPath, DeployOnLaunchSetting deployOnLaunchSetting, Gamelet gamelet) { MountConfiguration configuration = _mountChecker.GetConfiguration(gamelet, _actionRecorder); string targetPathNormalized = GetNormalizedFullPath(targetPath); Trace.WriteLine($"TargetPath is set to {targetPathNormalized}"); // If the /srv/game/assets folder is detached from /mnt/developer then // binaries generated by VS won't be used during the run/debug process. // Notify the user and let them decide whether this is expected behaviour or not. if (_mountChecker.IsGameAssetsDetachedFromDeveloperFolder(configuration)) { // 'Yes' - continue; 'No' - interrupt (gamelet validation fails). return(_dialogUtil.ShowYesNo( ErrorStrings.MountConfigurationWarning(YetiConstants.GameAssetsMountingPoint, YetiConstants.DeveloperMountingPoint), _mountConfigurationDialogCaption)); } if (_mountChecker.IsAssetStreamingActivated(configuration)) { var sshChannels = new SshTunnels(); IEnumerable <string> commandLines = sshChannels.GetSshCommandLines(); string[] mountPoints = sshChannels.ExtractMountingPoints(commandLines).ToArray(); if (mountPoints.Length == 0) { // If asset streaming is set up on the gamelet but there is no ssh tunnels // between the workstation and the gamelet then the connection was // probably lost (or asset streaming is set to a different machine, and // then it's ok). // 'Yes' - continue; 'No' - interrupt (gamelet validation fails). return(_dialogUtil.ShowYesNo(ErrorStrings.AssetStreamingBrokenWarning(), _mountConfigurationDialogCaption)); } if (deployOnLaunchSetting != DeployOnLaunchSetting.FALSE) { foreach (string mountPoint in mountPoints) { string mountPointNormalized = GetNormalizedFullPath(mountPoint); if (targetPathNormalized.StartsWith($@"{mountPointNormalized}\")) { // The mount point folder matches the output folder for the binaries; // VS will try to upload the binaries to the gamelet and this might lead // to an exception during 'scp' call. Instead, asset streaming should // take care of uploading the generated data to the gamelet. 'Yes' - // continue; 'No' - interrupt (gamelet validation fails). string current = GgpDeployOnLaunchToDisplayName(deployOnLaunchSetting); string expected = GgpDeployOnLaunchToDisplayName(DeployOnLaunchSetting.FALSE); return(_dialogUtil.ShowYesNo( ErrorStrings.AssetStreamingDeployWarning(mountPointNormalized, current, expected), _mountConfigurationDialogCaption)); } } } } return(true); string GetNormalizedFullPath(string path) { if (string.IsNullOrWhiteSpace(path)) { return(path); } string normalizedPath = FileUtil.GetNormalizedPath(path); if (File.Exists(normalizedPath) && FileUtil.IsPathSymlink(normalizedPath)) { string symlinkTarget = NativeMethods.GetTargetPathName(path); return(FileUtil.GetNormalizedPath(symlinkTarget)); } return(normalizedPath); } }