Search Unity

Disable generation of BackUpThisFolder_ButDontShipItWithYourGame

Discussion in 'Testing & Automation' started by QFSW, Dec 28, 2019.

  1. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    I understand that this folder can be useful, so I'm not asking to remove it entirely
    But can we have an option to disable it? Or at least don't put it in the build folder?

    I have an automated build pipeline and it's very annoying to have it as I obviously dont want it included in my release builds

    I tried making a script to delete the folder before uploading, but sometimes I get exceptions thrown of a sharing violation (unity still holding locks on the file?)

    It's been such a pain that I've decided to stop using IL2CPP and go back to mono for now

    Any thoughts on my proposal, or advice on how to deal with it for the mean time?
     
    bdovaz likes this.
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    What folder is this? Never seen it before.
     
  3. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    When making a standalone IL2CPP build
    upload_2019-12-28_19-3-59.png
     
  4. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Any thoughts on this?
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The goal of it was to be annoying enough that you'd notice and add a custom action to back it up in your release pipeline. Looks like that plan failed :(. Thing is, if you delete it and now your game crashes in the wild, the crash dumps will be utterly useless. And you can't recreate these files after they've been deleted.

    Unity should not be holding any locks on it. Are you sure it's Unity who has it locked? Would love a bug report if this is reproducible.
     
    QFSW likes this.
  6. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Unable to reproduce now, perhaps it was indeed something else holding the locks or maybe it was an already resolved bug, here's my repro script
    Code (CSharp):
    1. using System.IO;
    2. using UnityEditor;
    3. using UnityEngine;
    4.  
    5. public static class Repro
    6. {
    7.     [MenuItem("Repro/Build")]
    8.     public static void Build()
    9.     {
    10.         BuildTarget target = BuildTarget.StandaloneWindows64;
    11.         BuildTargetGroup group = BuildTargetGroup.Standalone;
    12.         string path = $"{Path.GetDirectoryName(Application.dataPath)}/Build";
    13.         string name = "Build";
    14.  
    15.         BuildPlayerOptions buildData = new BuildPlayerOptions
    16.         {
    17.             target = target,
    18.             targetGroup = group,
    19.  
    20.             locationPathName = $"{path}/{name}.exe",
    21.             scenes = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes),
    22.             options = BuildOptions.None,
    23.         };
    24.  
    25.         PlayerSettings.SetScriptingBackend(group, ScriptingImplementation.IL2CPP);
    26.         PlayerSettings.SetIl2CppCompilerConfiguration(group, Il2CppCompilerConfiguration.Debug);
    27.         BuildPipeline.BuildPlayer(buildData);
    28.  
    29.         Directory.Delete($"{path}/{name}_BackUpThisFolder_ButDontShipItWithYourGame", true);
    30.     }
    31. }
    32.  
     
    dimmduh1 likes this.
  7. Miltan_

    Miltan_

    Joined:
    Sep 7, 2013
    Posts:
    7
    How do I prevent those folders from generating with every build?
    It increases build time dramatically.
    I simply don't need them.
    It didn't exist in v2020 nor in 2021.3 is annoying
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    They don't increase build time at all. That's what the build is made out of. We just don't delete them afterwards.
     
    Talsidor likes this.
  9. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I made a helper script for this which does the following once a build has ran:

    1. If building for IOS, removes the Xcode build target platform 'My Mac' which would otherwise try to automatically run your IOS app on your Mac when using Build & Run from Unity on Xcode build target
    2. If using the Burst package, the Burst Debug folder will be deleted on a successful build
    3. If building for il2cpp, the il2cpp Debug folder will be deleted on a successful build

    Code (CSharp):
    1. using System;
    2. using System.IO;
    3. using UnityEditor;
    4. using UnityEditor.Callbacks;
    5. #if UNITY_IOS
    6. using UnityEditor.iOS.Xcode;
    7. #endif
    8. using UnityEngine;
    9. using UnityEngine.Assertions;
    10.  
    11. public class CleanupPostProcessorBuild
    12. {
    13.  
    14.     [PostProcessBuild(2000)]
    15.     public static void OnPostProcessBuild(BuildTarget target, string path)
    16.     {
    17. #if UNITY_IOS
    18.         Debug.Log("iOSBuildPostProcess is now postprocessing iOS Project");
    19.  
    20.         var projectPath = PBXProject.GetPBXProjectPath(path);
    21.  
    22.         var project = new PBXProject();
    23.         project.ReadFromFile(projectPath);
    24.  
    25.         var targetGuid = project.GetUnityMainTargetGuid();
    26.  
    27.         project.SetBuildProperty(targetGuid, "SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD", "NO");
    28.  
    29.         try
    30.         {
    31.             var projectInString = File.ReadAllText(projectPath);
    32.             projectInString = projectInString.Replace("SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;",
    33.                 $"SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;");
    34.             File.WriteAllText(projectPath, projectInString);
    35.         }
    36.         catch (Exception e)
    37.         {
    38.             Debug.LogException(e);
    39.         }
    40.  
    41.         project.WriteToFile(projectPath);
    42. #endif
    43.         string outputPath = path;
    44.  
    45.         try
    46.         {
    47.             string applicationName = Path.GetFileNameWithoutExtension(outputPath);
    48.             string outputFolder = Path.GetDirectoryName(outputPath);
    49.             Assert.IsNotNull(outputFolder);
    50.  
    51.             outputFolder = Path.GetFullPath(outputFolder);
    52.  
    53.             //Delete Burst Debug Folder
    54.             string burstDebugInformationDirectoryPath = Path.Combine(outputFolder, $"{applicationName}_BurstDebugInformation_DoNotShip");
    55.  
    56.             if (Directory.Exists(burstDebugInformationDirectoryPath))
    57.             {
    58.                 Debug.Log($" > Deleting Burst debug information folder at path '{burstDebugInformationDirectoryPath}'...");
    59.  
    60.                 Directory.Delete(burstDebugInformationDirectoryPath, true);
    61.             }
    62.  
    63.             //Delete il2cpp Debug Folder
    64.             string il2cppDebugInformationDirectoryPath = Path.Combine(outputFolder, $"{applicationName}_BackUpThisFolder_ButDontShipItWithYourGame");
    65.  
    66.             if (Directory.Exists(il2cppDebugInformationDirectoryPath))
    67.             {
    68.                 Debug.Log($" > Deleting Burst debug information folder at path '{il2cppDebugInformationDirectoryPath}'...");
    69.  
    70.                 Directory.Delete(il2cppDebugInformationDirectoryPath, true);
    71.             }
    72.         }
    73.         catch (Exception e)
    74.         {
    75.             Debug.LogWarning($"An unexpected exception occurred while performing build cleanup: {e}");
    76.         }
    77.     }
    78.  
    79. }
     
    waken, Karamelka322, Ex6tra and 2 others like this.