Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Build Report Tool - Track files in your project that need slimming down!

Discussion in 'Assets and Asset Store' started by AnomalusUndrdog, Apr 14, 2013.

?

How much would you be willing to pay for this?

Poll closed Oct 26, 2015.
  1. $2

    23.5%
  2. $5

    50.0%
  3. $10

    26.5%
  1. LeGiangAnh

    LeGiangAnh

    Joined:
    Nov 10, 2013
    Posts:
    113
    Here it is.
    What I meant is it still loads the log from my local build.
    2018-08-21_14-20-33.jpg
     
  2. abhuva

    abhuva

    Joined:
    Dec 23, 2011
    Posts:
    76
    I dont have an own class "SceneManager", but i tried the fix anyway and its working. Thx for the response!
     
  3. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Sorry for the late reply. That sounds odd. I can't think of any other explanation apart from: maybe your local build has very similar results to the cloud build?

    One way to make sure is to close and re-open Unity. At the very start of using Unity, there will be no build log data locally since Unity just started. Then you can attempt to get a build report from that override log file. If it was really using the log from the local build at that moment, then it would report an error saying there's no build log data to obtain.
     
  4. Anasthera

    Anasthera

    Joined:
    Nov 20, 2015
    Posts:
    1
    Hey I'm having trouble with build errors with BRT imported. It's preventing me from running a build.

    The errors I'm getting are here:

    Assets/BuildReport/Scripts/Editor/Utility/BRT_Util.cs(1580,25): error CS0029: Cannot implicitly convert type `System.IO.StringReader' to `TextReader'

    Assets/BuildReport/Scripts/Editor/Utility/BRT_Util.cs(1581,24): error CS1502: The best overloaded method match for `System.Xml.Serialization.XmlSerializer.Deserialize(System.IO.Stream)' has some invalid arguments

    Assets/BuildReport/Scripts/Editor/Utility/BRT_Util.cs(1581,36): error CS1503: Argument `#1' cannot convert `TextReader' expression to type `System.IO.Stream'

    I also cannot seem to find the actual tool in the unity GUI once imported.

    Currently running 2017.4.5f1, and I've tried looking this up on my own and I just cannot find any help anywhere.
     
  5. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Hi there,

    That's strange. TextReader is the base class for System.IO.StringReader, so it should not be a problem. The only way I see it not working is if your project also has another class with the same name TextReader (perhaps from another 3rd party plugin?) which can make the compiler confused as to which class is being referred to.

    A quick way to fix is this probably just to use the "var" keyword instead of explicitly using "TextReader".

    Code (CSharp):
    1.  
    2. // line 1580
    3. // change this:
    4.                 TextReader reader = new StringReader(correctedXmlData);
    5.  
    6. // to this:
    7.                 var reader = new StringReader(correctedXmlData);
    8.  
    Let me know if that works or not.
     
  6. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    779
    Having issues on 2018.2.13 where after a build it will not generate a report at all.
     
  7. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Thanks for notifying me, I will look into it soon.
     
  8. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    @mimminito: I tested building an empty scene (and a 2nd time with scenes that have 3d models inside) in Unity 2018.2.13 just now, it works fine. But there could be something in your project that is making Build Report Tool misbehave.

    Is the Build Report Tool window not showing up at all? Or does it show up but gets stuck in the "Waiting for the build to complete..." part?

    Try unchecking this checkbox in the Build Report Tool's Options section (it will make Build Report Tool run completely on the main thread):



    You can also try generating a Build Report manually. After building, open the Build Report Tool window, then initiate a Build Report generation manually by clicking on the "Get Log" button.



    You can also try setting the Calculation Level to the lowest (1 - Overview only). That will skip over quite a few calculations which may be what is getting it stuck. If that works, you can try raising the Calculation Level bit by bit and make a new Build Report (click on the "Get Log" button) each time, and see where it stops working:


    Let me know if that works or not.
     
  9. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    779
    I'll give this a go soon and see if I can get it to work.
     
  10. LeGiangAnh

    LeGiangAnh

    Joined:
    Nov 10, 2013
    Posts:
    113
    Got this error message when upgrading to Unity 2018.3B10.
    Assets\BuildReport\Scripts\Editor\ReportGeneration\BRT_UnityBuildSettingsUtility.cs(816,45): error CS0117: 'PlayerSettings' does not contain a definition for 'PSVita'
     
  11. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Thanks for notifying me, I'll get to work on that soon.

    UPDATE: Bugfix uploaded to the Asset Store. Will take about 1 week more or less for approval from the Unity Asset Store team, before it goes live.
     
    Last edited: Nov 27, 2018
  12. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,073
    hey @AnomalusUndrdog
    just a quick one, will the build report tool work when I run a build in Unity batchmode via console line arguments?
     
  13. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Not automatically. You have to add
    Code (CSharp):
    1. BuildReportTool.ReportGenerator.CreateReport();
    after calling BuildPipeline.BuildPlayer() in your build script.

    Doing this will generate a build report XML file as usual wherever build report files were configured to be saved to (by default inside a folder named "UnityBuildReports" in the My Documents/home folder).

    Here's an example:

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEditor;
    5. using UnityEngine;
    6.  
    7. public class SimpleBuilder
    8. {
    9.     // Execute this from the command line. For example (in Windows):
    10.     // C:\Program Files\Unity\Editor\Unity.exe -quit -batchmode -executeMethod SimpleBuilder.Build
    11.     //
    12.     static void Build()
    13.     {
    14. #if UNITY_5
    15.         // Unity 5 has a different way of building.
    16.         // You can remove this if your project isn't for Unity 5.
    17.         BuildPipeline.BuildPlayer(
    18.             new[] {"Assets/TestScene.unity"}, // put all scenes to build here
    19.             "C:\\Path\\to\\build.exe", // destination of build
    20.             BuildTarget.StandaloneWindows64, BuildOptions.None); // build platform and extra options
    21.      
    22.         Console.WriteLine("Finished building project");
    23. #else
    24.         // In Unity 2017 and above, BuildPipeline.BuildPlayer now allows the use
    25.         // of a struct called BuildPlayerOptions, so you can prepare the values
    26.         // more neatly before building.
    27.  
    28.         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    29.  
    30.         // EditorBuildSettings.scenes is an array that contains all the
    31.         // scenes included for the build, as it was configured in the project.
    32.         // Since I will be using that array, I check if it's empty first.
    33.         if (EditorBuildSettings.scenes.Length == 0)
    34.         {
    35.             // No scenes to build! Aborting.
    36.  
    37.             // The 1 indicates an error.
    38.             EditorApplication.Exit(1);
    39.             return;
    40.         }
    41.  
    42.         // Put all scenes to build here.
    43.         //
    44.         // In this example, I'm only adding the first scene,
    45.         // but you can change this to whatever you want.
    46.         //
    47.         // buildPlayerOptions.scenes is a string array,
    48.         // and the values just need to be paths to scene files,
    49.         // relative to the project's Assets folder.
    50.         // Example: "Assets/Scenes/TestScene.unity"
    51.         buildPlayerOptions.scenes = new[] {EditorBuildSettings.scenes[0].path};
    52.  
    53.         // Destination of build
    54.         buildPlayerOptions.locationPathName = "C:\\Path\\to\\build.exe";
    55.  
    56.         // Platform of the build
    57.         // See https://docs.unity3d.com/ScriptReference/BuildTarget.html for all possible values.
    58.         buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
    59.  
    60.         // Extra options you may want to turn on.
    61.         //
    62.         // See https://docs.unity3d.com/ScriptReference/BuildOptions.html for all possible values.
    63.         // This enum is a flag type, so you can assign more than one value.
    64.         // For example, use:
    65.         // buildPlayerOptions.options = BuildOptions.Development | BuildOptions.CompressWithLz4;
    66.         // If you want both a development build and use LZ4 type of compression at the same time.
    67.         buildPlayerOptions.options = BuildOptions.None;
    68.  
    69.         // Finally, do the build.
    70.         var result = BuildPipeline.BuildPlayer(buildPlayerOptions);
    71.  
    72.         // In Unity 2017, result is simply a string.
    73.         // In Unity 2018, result is a UnityEditor.Build.Reporting.BuildReport (a class).
    74.         // See https://docs.unity3d.com/ScriptReference/Build.Reporting.BuildReport.html
    75.         // if you want to output specific parts of the build result to the console.
    76.         // For example, if there are build errors, you can output
    77.         // result.summary.totalErrors to show the number of errors.
    78.         Console.WriteLine("Finished building project: " + result);
    79. #endif
    80.  
    81.         // And now create the Build Report. It will save a Build Report XML file
    82.         // in the usual place where they've been configured to be saved to
    83.         // (by default inside a folder named "UnityBuildReports" in the
    84.         // My Documents/home folder).
    85.         BuildReportTool.ReportGenerator.CreateReport();
    86.  
    87.         // The 0 indicates a successful exit with no errors.
    88.         EditorApplication.Exit(0);
    89.     }
    90. }
    91.  
     
    Last edited: Dec 6, 2018
    BTStone likes this.
  14. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,073
    Ah I see, great! :D
     
  15. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Great to see that this package is getting more and more awesome over the years.

    I have a use case where I need to find out which DLL or scripts are included in the build. Is this information available somewhere?

    Perhaps someone might know the answer to the following question:

    Also is there a way to select only certain things that we want to be in the build.
     
  16. raxashafique

    raxashafique

    Joined:
    Sep 12, 2015
    Posts:
    5
    I am unable to download the asset? Is there something wrong? all other assets seems to download just fine.
     
  17. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    298
    I love this tool, for me it is 5/5.

    My only suggestion is to have more features for iOS and Android since majority of Unity Developers works for mobile sector. Specially estimation for final .APK and .IPA files would be amazing, and auto suggestions for how to reduce size more, for example Google Play have 100 mb limit before splitting apk..
     
  18. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    111
    Hi!
    In the used asset option, is there any way that I can get why is an asset in this category?

    I'll explain myself:
    Imaging you have an asset inside used assets, but you do not know why. it would be great if the tool could tell you that this asset is in the build because is in the prefab {XXX} that it is inside the scene {YYY}, for example.

    Very useful tool by the way, thank you
     
    Last edited: Jan 18, 2019
  19. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Hi, sorry for the late replies, everyone.

    DLLs are reported in the Size Stats tab:


    The individual scripts used can be found in the Used Assets tab, change the filter to Scripts:


    If I understand your question right, you want a way for only certain things to be in the build?

    Ultimately, the things that end up in the build are:
    1. scenes you've included in the build settings
    2. any prefabs that are in those scenes
    3. any assets that are used by the previously mentioned scenes and prefabs (terrain data, textures, 3d models, audio, scriptable objects, etc.)
    4. any asset in a Resources folder, and everything in the StreamingAssets folder

    That's how you make something be in the build. The plugin can't do these decisions for you, but I plan to add a feature to tell you why something ended up in the build, like @Maeslezo mentioned.


    I've been having problems with the Asset Store tab in the Unity Editor myself, with downloads being stuck. Try downloading it from the "My Assets" tab.


    Thanks, this has also been suggested to me before. I can't promise anything as I do not have much expertise in Android/iOS api's.


    This is one of the features I want to add to Build Report Tool myself. I don't have the time to add such a thing right now sadly. For now, I can recommend you check out free plugins that can do that, like Asset Usage Detector.
     
    Maeslezo likes this.
  20. adam-goodchild-omobile

    adam-goodchild-omobile

    Joined:
    Jan 12, 2017
    Posts:
    13
    @AnomalusUndrdog I am using your asset with Unity 2018.3.5f1 and I am getting no file sizes showing correctly. Could you look into this?
     
  21. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Can you describe more about no file sizes showing correctly? Maybe some screenshots, or send me one example of a file whose size doesn't get shown correctly so I could experiment with it. I downloaded Unity 2018.3.5f1 and did a test build for Windows standalone, and it seems to work fine.
     
  22. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    111
    Hello,

    I can't get the report by batchmode.

    This is my call
    Code (CSharp):
    1.         var buildReport = BuildPipeline.BuildPlayer(scenes, path + "/main.exe", BuildTarget.StandaloneWindows64, GetBuildOptions());
    2.         BuildReportTool.ReportGenerator.CreateReport();
    Any idea? Could be some problem with any buildoptions?
     
  23. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    BuildReportTool will get build log from Unity's Editor.log file. By default it will look for the Editor.log file where it's normally present (C:\Users\username\AppData\Local\Unity\Editor\Editor.log), but if your build script is moving it in a different location, it won't generate a report. You can set where Build Report Tool will look for the log file via the Options:


    I will be adding an optional parameter in BuildReportTool.ReportGenerator.CreateReport() to let you specify the log file via code.
     
    Maeslezo likes this.
  24. adam-goodchild-omobile

    adam-goodchild-omobile

    Joined:
    Jan 12, 2017
    Posts:
    13
    Sure. Attached is a screenshot. I am on MacOS 10.12.6.
     

    Attached Files:

  25. adam-goodchild-omobile

    adam-goodchild-omobile

    Joined:
    Jan 12, 2017
    Posts:
    13
    @AnomalusUndrdog It seems to be working again now, odd! Maybe Unity was doing something odd with the build logs. Oh well, all back to normal. Thanks.
     
  26. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    645
    Problems with Build Report with Unity 5.6.6.

    1. The get log button fails to get the log.

    2. If I manually open the file I get 2 errors:

    System Invalid Operation Exception. There is an error in XML document.
    <filefiltergroup xmins=" was not expected....

    Build Report Tool Invalid data in build info file

    The build plays, but I cannot use your report tool.
     
  27. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    I just downloaded Unity 5.6.6 and did a test build and it worked fine.

    I'll need to know more. Can you tell me about the "Get Log" button failing, what error message did it say, if any?
    Once that gets fixed, the build report XML files generated afterwards should be ok.
     
  28. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    645
    I opened the Build Report Window.

    Nothing happens when I click the "get log" button, (no errors) but the window already reports "no build info."

    If I click the "Open" button there is one file in the Unity Build Reports folder to select from, titled, "FileFiltersUsed.xml
     
  29. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Have you created a build? Build Report Tool can only work right after a build has been made. If you close then re-open Unity, then you'd have to make a build again before Build Report Tool can do its work.
     
  30. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    645
    That's probably it, because I had closed and reopened Unity. I bought Build Report when I discovered that my water asset was not visible in the build, and I was going to use it to research the issue. Now I know and I will use the tool after my next build. Thank's for the prompt advice!
     
  31. dave_thrive

    dave_thrive

    Joined:
    Jan 30, 2019
    Posts:
    22
    upload_2019-3-4_10-32-6.png
    Can anyone tell me what is classified as "User Assets"? I presumed it would be textures and prefabs and such but those seem to be classified in other categories.
     
  32. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Hi, thanks for pointing this out, this is a wrong calculation on my part. "Total User Assets" is actually the entire total of the assets (but not counting the size of Streaming Assets). So if you add up everything in that table except the first two, it should be equivalent to what Total User Assets say (24 MB). It seems to be a new build log entry in Unity 2018 and above. I'll release a bugfix that removes that.
     
  33. dave_thrive

    dave_thrive

    Joined:
    Jan 30, 2019
    Posts:
    22
    Ok, thanks :)
     
  34. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Build Report Tool 3.4.11 has been released!

    @dave_thrive: The "Total User Assets" should be removed now.

    @Maeslezo: 3.4.11 now allows adding an optional string argument to BuildReportTool.ReportGenerator.CreateReport() to let you specify where your Unity Editor log file is, you can try this if your Editor log file is in a custom path.
     
    dave_thrive likes this.
  35. Dark_Swordsman

    Dark_Swordsman

    Joined:
    Dec 4, 2018
    Posts:
    27
    Hi, can we expect an update for 2019.1? There are compilation issues due to obsolete API-use.
     
    hungrybelome and EdKirby like this.
  36. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Hi, thanks for notifying me, I'll work on it soon when I get the time.
     
    Dark_Swordsman likes this.
  37. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    274
    Great, looking forward to it too!
     
  38. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    @Dark_Swordsman @hungrybelome: Version 3.4.14 fixes compatibility with Unity 2019.1.0f2. Please update, let me know if there are further problems.
     
  39. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Alright everyone, sorry for taking so long on this, but I now have an asset dependency view in Build Report Tool. What this means is that it can now tell you why something got included in the build in the form of "something.png is used by another.mat which is used by something.prefab which is used by thing.unity which is in the build"

    This is not available yet, but I want to share it first so everyone knows what's coming.

    EDIT: This is now available in version 3.5!

    All these updates will be free for existing customers of Build Report Tool when the new version comes out, but I will be raising the regular price from $10 to $15 so for those of you reading this post that have Build Report Tool on their wishlist, now may be a good time to get it while the new version isn't out yet!

    Asset Dependencies

    This is the basic view of the asset dependencies. It shows one dependency "chain" when you click on an asset.


    To view all asset usages, click on the "Show More Usages" button. This shows you everything that makes use of the selected asset, both explicitly and implicitly, in one giant list.


    If that list is too long and difficult to make sense of, you can click on the "Direct" button. This will show only the files that explicitly use the asset (the "direct" users). You can then click on the Inspect button on each asset user, to follow the usage "chain".


    If you don't care about the asset usage "chain" itself, you can click on the "End" button. This will show only the scenes and Resources files that use the selected asset (explicitly or implicitly). They are the primary reason why the asset got included in the build (the "end" users).



    If you prefer a less wordy view of the asset usage chain, you can set the Asset usage labels to "Minimal" in the Options:





    ----

    Also included will be a few minor improvements:

    Ping Method

    You can now choose to allow double-click as the method to ping. This will remove the "Ping" button beside each asset.





    Multi-Select Ping

    You can choose to have multiple assets selected when doing the ping. This is useful for quickly changing the import settings of multiple files in one go.

    To do this, hold Alt while double-clicking the selected assets. If you set the Asset Ping method to having a Ping button, hold Alt when clicking the Ping button.


    Asset Path toggle

    You can now toggle showing the asset's complete path, or just the filename. There is now a checkbox beside the Asset Path column:



    Preview Tooltips

    There's also now tooltips that show a bigger view of the asset when you hover over the icon:


    If you move the mouse quickly through many icons, the Editor may lag a bit since it's loading all those images for the tooltip. If you don't want this tooltip, you can turn it off in the Options, you can also set how big the tooltip display will be, plus other settings for it:


    You can hold Ctrl to zoom-in on the tooltip:


    You can press Alt to toggle showing the alpha channel:


    Still to come:
    1. When viewing a list of meshes, there will be additional columns to show vertex/triangle count. Having them as columns also mean the list can be sorted by vertex/triangle count.
    2. When viewing a list of textures/images, there will be additional columns to show texture type (whether it's imported as lightmap, normal map, UI/sprite, etc.), width x height, compression setting, etc. Having them as columns also mean the list can be sorted by those properties.
    3. More detail on asset usage. For example, it will display whether a texture is used as the Albedo, Occlusion, or Normals, etc. in the material file it's used in. If a prefab is used in a scene, it will display where in that scene it's used (ex: "something.prefab is used in GameObject 'test/building/mount' of main.unity"). If the prefab is used many times in the scene, it will display each of them. This can be slow, so the calculation of more asset usage details can be toggled off.
    4. Asset Usage Overview: This will be a new tab that shows asset usage from the top, going down. It will initially show you a list of all scenes in the build, and how many assets each scene uses (and their total size). Double-clicking on a scene will let you view the insides, showing the assets used in that scene, which you can also double-click to go in further.
    5. Diff mode between two Build Reports
    6. Duplicate searcher and consolidator: For example, if two materials in your project each use their own copy of hero_char_diffuse.png which are identical (images themselves checked using file checksum, and their import settings are checked if identical), this tool will delete the other texture, and make both materials use only the remaining one. This will go on further: If two materials being used are identical in their values, one of them will be deleted, and all users of the deleted material will be assigned the other material, etc.
    7. Plus a few more that I'm experimenting with, like having Build Reports on Asset Bundles
     
    Last edited: Aug 10, 2019
    gecko and Meceka like this.
  40. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    636
    Hi @AnomalusUndrdog, I'm getting a ArgumentException at the point of generating the report.

    Code (csharp):
    1.  
    2. ArgumentException: Invalid path
    3. System.IO.Path.GetDirectoryName (System.String path) (at <7d97106330684add86d080ecf65bfe69>:0)
    4. BuildReportTool.ReportGenerator.GetStandaloneBuildWithDataFolderSize (System.String buildFilePath, System.String unityVersion) (at Assets/Plugins/BuildReport/Scripts/Editor/ReportGeneration/BRT_ReportGenerator.cs:1773)
    5. BuildReportTool.ReportGenerator.GetStandaloneBuildSize (System.String buildFilePath, System.String unityVersion) (at Assets/Plugins/BuildReport/Scripts/Editor/ReportGeneration/BRT_ReportGenerator.cs:1762)
    6. BuildReportTool.ReportGenerator.GetValues (BuildReportTool.BuildInfo buildInfo, System.String buildFilePath, System.String projectAssetsPath, System.String editorAppContentsPath, System.Boolean calculateBuildSize) (at Assets/Plugins/BuildReport/Scripts/Editor/ReportGeneration/BRT_ReportGenerator.cs:2221)
    7. BuildReportTool.ReportGenerator.CreateBuildReport (BuildReportTool.BuildInfo buildInfo) (at Assets/Plugins/BuildReport/Scripts/Editor/ReportGeneration/BRT_ReportGenerator.cs:2552)
    8. BuildReportTool.ReportGenerator+<>c__DisplayClass50_0.<CreateBuildReportInBackgroundIfNeeded>b__0 () (at Assets/Plugins/BuildReport/Scripts/Editor/ReportGeneration/BRT_ReportGenerator.cs:2526)
    9. System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <7d97106330684add86d080ecf65bfe69>:0)
    10. System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <7d97106330684add86d080ecf65bfe69>:0)
    11. System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <7d97106330684add86d080ecf65bfe69>:0)
    12. System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <7d97106330684add86d080ecf65bfe69>:0)
    13. System.Threading.ThreadHelper.ThreadStart () (at <7d97106330684add86d080ecf65bfe69>:0)
    14. UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
    15.  
    16.  
    I had the location of the asset under Plugins/BuildReport, tried moving it directly under Assets, same thing. Did some debugging, it seems that EditorUserBuildSettings.GetBuildLocation is returning an empty string. The tool seems to run twice, before and after build. Before the build in BuildGenerator.Init, it grabs the right file path but somehow loses it after.

    Any idea what's wrong?

    Using Build Report v3.5, Unity 2019.1.9f1
     
  41. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Init gets called in OnPostprocessBuild (I'm not using IPreprocessBuildWithReport to maintain backwards compatibility with Unity 5.0, but I probably should change that now), which is automatically called by Unity after a build. For some reason, it's also called whenever the scene is changed (like when loading a new scene when the game is running). When building, Unity goes through each scene in the build settings, so that's probably why it's getting called many times.

    I will probably just switch to using UnityEditor.Build.IPreprocessBuildWithReport when it's being run in Unity 2018 and above.

    My guess is EditorUserBuildSettings.GetBuildLocation is returning an empty string because my code is passing the wrong BuildTarget to it. It gets the build target by getting the value of EditorUserBuildSettings.activeBuildTarget in OnPostprocessBuild (I have to do it there because I can only use the Unity API while in the main thread, and report generation is in a separate thread so that it doesn't stall the main thread, so it can't use things like EditorUserBuildSettings.GetBuildLocation inside the report generation code).

    2019.1 probably changed something in the way the API works. I'll be downloading 2019.1.9f1 and will look into it soon.

    If you need this fixed urgently, here's a quick and dirty fix: just prevent the value from being overwritten if the new one is an empty string:

    In line 201 of BRT_ReportGenerator.cs:

    Change:
    Code (CSharp):
    1. buildInfo.BuildFilePath =
    2.                 EditorUserBuildSettings.GetBuildLocation(BuildReportTool.Util.BuildTargetOfLastBuild);
    to:
    Code (CSharp):
    1. var newBuildFilePath = EditorUserBuildSettings.GetBuildLocation(BuildReportTool.Util.BuildTargetOfLastBuild);
    2. if (!string.IsNullOrEmpty(newBuildFilePath))
    3. {
    4.     buildInfo.BuildFilePath = newBuildFilePath;
    5. }
     
    Last edited: Aug 10, 2019
  42. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    636
    @AnomalusUndrdog same error it seems. I tried logging that BuildFilePath, I get two logs. First log points to an older build location, second log is null/empty string.
     
  43. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    It's quite strange, I did a simple test build in Unity 2019.1.9f1 and it's not exhibiting the same problem. Are you doing the build from command line, or do you have custom build scripts? Something might be calling EditorUserBuildSettings.SetBuildLocation to change the value.
     
  44. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    636
    Yeah I have a simple function I run via MenuItem in editor to run my build. Doesn't do anything crazy just BuildPipeline.BuildPlayer. I can post the code when I'm home if that helps!
     
  45. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Yes, it wouldn't hurt to post the code, I can take a look at it. But basically, in this situation, you should call BuildReportTool.ReportGenerator.CreateReport() after BuildPipeline.BuildPlayer to create the build report.

    The build location you assign in BuildPlayerOptions.locationPathName won't show up as the value of EditorUserBuildSettings.GetBuildLocation (it's just how the Unity API works). So the BuildPlayerOptions that you made also has to be passed to CreateReport(), for it to work properly. It gets the build location from BuildPlayerOptions.locationPathName.

    If you're not using BuildPlayerOptions, there's an overload for CreateReport() so you can pass the build location as a plain string.

    There's example code on how to use it in the BuildReport folder, in a txt file named CustomBuildScriptExample.txt
     
  46. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    636
    Here's my build basically.

    Code (csharp):
    1.  
    2.  
    3.     public static void Build(bool IsDebug)
    4.     {
    5.         Debug.Log("Build started: " + (IsDebug?"DEBUG":"RELEASE"));
    6.  
    7.         int BuildNumber = PlayerPrefs.GetInt("BuildNumber", 0);
    8.         string Filepath = Directory.GetParent(Application.dataPath).FullName;
    9.         Filepath += "/Builds/IOU_b"+BuildNumber+"/IOU_b"+BuildNumber+(IsDebug?"_d":"_r")+".exe";
    10.         PlayerPrefs.SetInt("BuildNumber", BuildNumber + 1);
    11.  
    12.         bool HotReloadON = TinyDLLTools.IsDefined("ENABLE_HOTRELOAD");
    13.         TinyDLLTools.SetHotReload(false);
    14.  
    15.         string[] Scenes = new string[]
    16.         {
    17.             GetSceneFile("SceneGame"),
    18.         };
    19.  
    20.         BuildOptions Options = 0;
    21.         if (IsDebug)
    22.         {
    23.             Options |= BuildOptions.Development |
    24.                        BuildOptions.AllowDebugging;
    25.         }
    26.  
    27.         BuildPipeline.BuildPlayer(Scenes, Filepath,
    28.             BuildTarget.StandaloneWindows, Options);
    29.  
    30.         TinyDLLTools.SetHotReload(HotReloadON);
    31.  
    32.         var EXE = new Process();
    33.         EXE.StartInfo.FileName = Filepath;
    34.         EXE.Start();
    35.         Debug.Log("Build Complete: " + Filepath);
    36.     }
    37.  
    38.  
    39.  
    Build generator seems to run after this so I didn't think I'd have to call anything myself, hmm. I'll try it!

    [Edit] That seemed to work, thanks! Calling Generate report like you said with a populated PlayerBuildOptions struct.
     
    Last edited: Aug 14, 2019
  47. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Yes, just to clarify, by default, Build Report Window automatically shows after a build, but since you used BuildPipeline.BuildPlayer in your own scripts, the values you passed to it (list of scenes, build location, the build target), you can think of them as custom overrides. They can't be retrieved from the Unity API, so BuildReportTool can't see them. This was why I provided a public API in the form of BuildReportTool.ReportGenerator.CreateReport() so that you can manually pass those values in.

    Since the code you showed doesn't use BuildPlayerOptions, there's an overload to CreateReport to just pass those values individually, so you can do this as well:

    Code (CSharp):
    1. BuildReportTool.ReportGenerator.CreateReport(Scenes, Filepath, BuildTarget.StandaloneWindows);
     
    vexe likes this.
  48. Flexford

    Flexford

    Joined:
    Dec 8, 2016
    Posts:
    3
    We make assemblies through TeamCity and copy the result to the network shared folder. Today I made the assembly report also copied there. Having opened the report on another machine in the context of the same project, I found that the hints did not work there on hover and actually I threw you an error.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. BuildReportTool.Window.Screen.AssetList.DrawAssetUsage (UnityEngine.Rect position, BuildReportTool.AssetList listToDisplay, BuildReportTool.BuildInfo buildReportToDisplay, BuildReportTool.AssetDependencies assetDependencies) (at Assets/BuildReport/Scripts/Editor/Window/Screen/BRT_AssetListScreen_AssetUsage.cs:379)
    3. BuildReportTool.Window.Screen.AssetList.DrawGUI (UnityEngine.Rect position, BuildReportTool.BuildInfo buildReportToDisplay, BuildReportTool.AssetDependencies assetDependencies, System.Boolean& requestRepaint) (at Assets/BuildReport/Scripts/Editor/Window/Screen/BRT_AssetListScreen.cs:249)
    4. BRT_BuildReportWindow.OnGUI () (at Assets/BuildReport/Scripts/Editor/Window/BRT_BuildReportWindow.cs:1102)
    5. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
    6. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    7. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
    8. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
    9. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:342)
    10. UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:336)
    11. UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:310)
    12. UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean customBorder, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:361)
    13. UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:320)
    14. UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:266)
    15. UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:438)
    16. UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:421)
    17. UnityEngine.Experimental.UIElements.IMGUIContainer.HandleEvent (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:401)
    18. UnityEngine.Experimental.UIElements.EventDispatcher.PropagateEvent (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:754)
    19. UnityEngine.Experimental.UIElements.EventDispatcher.ProcessEvent (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:599)
    20. UnityEngine.Experimental.UIElements.EventDispatcher.Dispatch (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:307)
    21. UnityEngine.Experimental.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.Experimental.UIElements.EventBase e, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:176)
    22. UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:245)
    23. UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:68)
    24. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
    25.  
     
  49. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Sorry for the late reply. I hadn't anticipated this being used on network share folders. I'll at least fix that null reference exception for now. Then I'll see if I can somehow make it work on network shares.
     
  50. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    581
    Hi @AnomalusUndrdog,

    I just got the tool and really like the automatic process of saving reports. However I hoped, that the build time would be included as well. This would really help to track the build times over time to get an idea when the process got slow.
    Any chance you could include that?

    Cheers
    Johannes