Search Unity

Windows build outputs pdb files

Discussion in 'Windows' started by Culzean, Jun 4, 2015.

  1. Culzean

    Culzean

    Joined:
    Jan 25, 2014
    Posts:
    48
    I haven't seen these files before, but since upgrading to Unity 5 it now outputs these files for Windows builds. I understand these are for debugging development builds. However my project is till out putting these files and I have set it to release mode. Is it ok to delete these files? any ideas why my project is out putting these files?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    I'm not sure how you didn't notice them before - I'm pretty sure it always did it.

    I wouldn't delete these files. You don't have to upload them to the windows store, but they will be useful if you get any crash dumps from the Windows Store and you wish to investigate.
     
  3. Culzean

    Culzean

    Joined:
    Jan 25, 2014
    Posts:
    48
    Thanks, will keep them with backed up alongside the builds. Erm looking at a pc build created with Unity 4 there is no sign of these files separate, that's for stand alone pc release.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    Ah, Windows Standalone. Since you didn't specify that in the original post, I thought you were publishing for Windows Store, as that's what this forum is primarily for.

    Either way, I believe we started shipping PDBs with Unity 5 for windows standalones too to ease debugging/profiling with external tools. We always shipped those PDBs for Windows Store applications.
     
  5. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    212
    Is there a way to stop these from being built? On OSX and Unity 5.2.3 (Development mode and script debugging are both unchecked)
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    I don't think so - may I ask why would you want them not to be built?
     
  7. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    212
    Making patches and builds for players. Doing differences on zips in folders. Now will have to script removing them so they are not included in the player downloads. This makes the patches and downloads larger for all.
     
  8. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    390
    Could someone use a .PDB file to find a function or variable inside the .exe such as "IsRegistered" or "ThisWasPaidFor" and they muck around to try to unlock a game or replace/override a function?
     
  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,069
    You don't need a pdb file for that, because in Unity users are programming with managed language, so you can decompile managed assembly without having symbols.

    In the case above pdb files are provided for Unity engine executable, which doesn't contain user code inside.
     
  10. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    411
    "may I ask why would you want them not to be built?" Because they are silly and annoying.

    Also, since we pay thousands of dollars a year to Unity for a license, the general plan for Unity is (1) do what we say (2) do what we say

    Generally, software that works is better. Unity should adopt this approach. If we turn off silly debugging features, we want them turned off.

    Hopefully this silly clutter will be turned off, unless asked for in builds, ASAP
     
    impurekind likes this.
  11. gstier

    gstier

    Joined:
    Nov 18, 2013
    Posts:
    4
    That's a terrible answer to some very legitimate questions. The people here are just trying to manage their applications, which includes managing build processes and application size. If you really can't imagine a scenario in which this is a bad thing, then here are a couple for you:

    First, there is a 'Development Build' setting. The presence of such a setting implies that debug info will or will not be built based on this setting. By building the debug information all the time, you are essentially ignoring that build setting. So should we log a bug for that? If this is not a bug, then what purpose does it serve?

    Second, I (like many others) have an automated build process that builds my application, zips it up, then moves it to the appropriate testing environment. My application is 40mb without these pdb files, and 170mb in size with them! That's over 4 times larger! Over 75% of my zipped application is from debug information that I specifically asked to not have included when I unchecked the 'Development Build' option.
     
    Fattie and rstorm000 like this.
  12. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,069
    Guys, pdb files are provided for your convenience, when you zip or make an installer, simply add an option to ignore them and that's it, it's not that hard.
     
  13. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    215
    This is a really strange thing. Why is there no option to NOT build these debug files? It may be "for our convenience", but right now they only add to my inconvenience.
     
    Tethys, _monoflow and Cascho01 like this.
  14. Jespertheend2

    Jespertheend2

    Joined:
    Jan 14, 2015
    Posts:
    23
    I don't know what's wrong with everyone here, either you are already using a build script for a better workflow and removing the files using a script is easy to make. Or you aren't using a build script in which case you will have to zip the files manually anyway. I really don't see why everyone is so annoyed by a couple of files.

    wow rude
     
    LaireonGames and Tomer-Barkan like this.
  15. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    215
    My main problem is the lack of communication from Unity Tech. I already had the case where a developer distributed some zipped demo with these *.pdb files because they either didn't know a) that Unity (suddenly) creates them or b) that they are not needed for distribution. Either way, Unity should have had a clear message somewhere, that builds have now files you might not need, especially not for release.

    In any case it's really strange when Unity copies (in my case) unnecessary files onto my harddrive every time even though I don't need them. Is it so hard for Unity to add a checkbox to the GUI?
     
    Tomer-Barkan likes this.
  16. Axel-F

    Axel-F

    Joined:
    Mar 20, 2009
    Posts:
    196
    If you really never ever want to debug Windows stand alone builds put this script into your Assets/Editor folder, name it PostProcessBuild.cs and these annoying PDB files will be history:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.Callbacks;
    4. using System.IO;
    5.  
    6. public class PostProcessBuild
    7. {
    8.     [PostProcessBuildAttribute(1)]
    9.     public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    10.     {
    11.         if (target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64)
    12.         {
    13.             // remove these annoying PDB files as we don't want to debug stand alone builds!
    14.             string pureBuildPath = Path.GetDirectoryName(pathToBuiltProject);
    15.             foreach (string file in Directory.GetFiles(pureBuildPath, "*.pdb"))
    16.             {
    17.                 Debug.Log(file + " deleted!");
    18.                 File.Delete(file);
    19.             }
    20.         }
    21.     }
    22. }
     
    Tethys likes this.
  17. JtheSpaceC

    JtheSpaceC

    Joined:
    Oct 5, 2014
    Posts:
    14
    Thanks for the script. It works perfectly!

    As for Unity, providing them for convenience is only good if they're actually desired. You must realise that many of your users are amateurs and hobbyists, moreso than with any other game engine. Their needs differ, and that's not even to say that every developer would want those files for every build anyway.

    Giving the user the option to include them is clearly a better option.

    In just my case, I want to share a 15MB scene with a friend, but those two extra files alone come to over 140MB, making attaching the files to email impossible, and hogging Dropbox space/bandwidth to share. If I didn't know that I could safely delete them (only a minor IN-convenience) then I'd be subjecting myself to major inconvenience when trying to share. Can you really not see a situation where this is undesirable?
     
    Tethys and rstorm000 like this.
  18. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    349
    Hi Unity... is this guy in PR or customer service? Because he shouldn't be...
    What in the world? Is that some kind of joke reply?
     
    glenrhodes, Tethys and JtheSpaceC like this.
  19. glenrhodes

    glenrhodes

    Joined:
    Oct 25, 2013
    Posts:
    55
    I think it comes from the average dev not knowing or realizing that the pdb files are unnecessary for the final distribution. Until reading this thread, I figured that pdb files were a requirement for the final package to run... even though the "db" in "pdb" likely stood for "debug"...
     
  20. idiot333

    idiot333

    Joined:
    Jan 26, 2015
    Posts:
    31
    Just delete those pdb files. they are just for Debugging or something. It wont create problems anywhere.
     
  21. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    215
    Perhaps you should have read the thread, idiot333
     
  22. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,069
    Hi,

    we'll add an option "Copy PDB files" with default value - false, this will be exposed in Build Settings window, this way you'll be able to control either you want pdb files or not. Hopefully this will make all parties happy.

    Sorry for the inconvenience.
     
  23. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,533
    Now that this has been added, is there any way to access it via scripting like the other build settings?
    thanks
     
  24. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,069
    The explicit property was not yet added. But you can do this, assuming you're using 5.4.
    Code (csharp):
    1.  
    2. UnityEditor.EditorUserBuildSettings.SetPlatformSettings("Standalone", "CopyPDBFiles", enabled);
    3.  
     
  25. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,533
    Ah, thank you for that :)
    Do you know if an explicit property will be added?
     
  26. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,069
    Yes, it will be added.
     
    Working_Robot likes this.
  27. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,533
  28. bigd

    bigd

    Joined:
    Feb 14, 2014
    Posts:
    34
    Awesome. Came here looking for this same topic. Good see we'll be given an option in the future. These are currently 150 MB files that are created each time I build.
     
  29. Pawl

    Pawl

    Joined:
    Jun 23, 2013
    Posts:
    110
    +1 Came here to say thanks for giving the option to disable the pdbs!
     
  30. Korbinian

    Korbinian

    Joined:
    Jun 27, 2013
    Posts:
    8
    FTR, to enable copying of PDBs in a build script, the string to pass as value is "true", so
    Code (CSharp):
    1. EditorUserBuildSettings.SetPlatformSettings("Standalone", "CopyPDBFiles", "true");
     
  31. fenghou

    fenghou

    Joined:
    Feb 5, 2019
    Posts:
    21
    It does not work with Unity 2018.4.12f1, so I have to use the code from Axel-F.
    Has the setting interface changed?

    (I know unity has a GUI option "Copy PDB Files" , but I have to build the project through command line.)
     
    Last edited: Dec 17, 2019
  32. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    Try this:

    Code (csharp):
    1. #if UNITY_STANDALONE_WIN
    2. UnityEditor.WindowsStandalone.UserBuildSettings.copyPDBFiles = true;
    3. #endif
     
  33. fenghou

    fenghou

    Joined:
    Feb 5, 2019
    Posts:
    21
    It does not work, even if I change the value to false. But the interface is right, thank you. I will try it again.
     
  34. fenghou

    fenghou

    Joined:
    Feb 5, 2019
    Posts:
    21
    I still can't get it to work. Please help...

    The command line is:
    Code (CSharp):
    1. /c/Program\ Files/Unity/Editor/Unity.exe \
    2.   -quit \
    3.   -batchmode \
    4.   -buildTarget "StandaloneWindows64" \
    5.   -executeMethod BuildCommand.PerformBuild \
    6.   ...
    7.  
    The build codes are:
    Code (CSharp):
    1.     public static void PerformBuild()
    2.     {
    3.         Console.WriteLine(":: Performing build");
    4.         var buildTarget = GetBuildTarget();
    5.         var buildPath = GetBuildPath();
    6.         var buildName = Application.productName;
    7.         var fixedBuildPath = GetFixedBuildPath(buildTarget, buildPath, buildName);
    8.  
    9.         UnityEditor.WindowsStandalone.UserBuildSettings.copyPDBFiles = false;
    10.  
    11.         ModifyScenes();
    12.  
    13.         BuildPipeline.BuildPlayer(GetScenes(), fixedBuildPath, buildTarget, GetBuildOptions());
    14.         Console.WriteLine(":: Done with build");
    15.     }
     
  35. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    Could you describe what doesn't work?
     
  36. fenghou

    fenghou

    Joined:
    Feb 5, 2019
    Posts:
    21
    After the game is built, the .pdb files are still in the target directory.
     
  37. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    Can you list which PDB files get copied in your case?
     
  38. fenghou

    fenghou

    Joined:
    Feb 5, 2019
    Posts:
    21
    There are 4 pdb files in the "Managed" directory:

    Assembly-CSharp.pdb
    Unity.TextMeshPro.pdb
    spine-unity.pdb
    Unity.Analytics.DataPrivacy.pdb

    And no pdb files found in other directories.
     
  39. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    7,016
    So, Copy PDB Files doesn't control that. I believe that is controlled by development build checkbox. These files used to be ".mdb" in the past, but Unity's C# compiler adopted the portable PDB format.

    Copy PDB files only control native Windows .pdb files for native DLLs. These PDBs are different than the PDBs for C# code. I agree that the setting name is confusing...
     
  40. fenghou

    fenghou

    Joined:
    Feb 5, 2019
    Posts:
    21
    OK, thank you for your explanation. I have to use Axel-F's code.
     
  41. dec-dev0

    dec-dev0

    Joined:
    Mar 21, 2014
    Posts:
    6
    So https://docs.unity3d.com/Manual/WindowsStandaloneBinaries.html is incomplete because it stated:
    It should say Symbol files for debugging the Unity Player exe

    By the way, GetBuildTargetName from the BuildPipeline should be public, not external to allow manipulating PlatformSettings using EditorUserBuildSettings.SetPlatformSettings
     
unityunity