Search Unity

how to modify properties of final compiled .exe file on the windows standalone platform?

Discussion in 'Windows' started by daleksan, Nov 9, 2018.

  1. daleksan

    daleksan

    Joined:
    Apr 15, 2018
    Posts:
    3
    Hi all,
    i would like to add information in final compiled application (windows standalone: myapp.exe) about "Copyright" and change file version from unity version to my own.

    Is it possible? If yes, how can i do it?

    screenshot with that i would like to do is attached:

    Untitled.png

    Thanks in Advance!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yes. There is an option to "Generate Visual Studio Solution" in the build window. Instead of generating final executable, it generates a visual studio project that builds the final executable. You can then change it in whatever way you want.
     
  3. daleksan

    daleksan

    Joined:
    Apr 15, 2018
    Posts:
    3
    Thank you so much. i dit it. I created visual studio solution from unity. Modified "WindowsPlayerVersion.rc" and got it.
    Untitled.png
     
  4. daleksan

    daleksan

    Joined:
    Apr 15, 2018
    Posts:
    3
    Well. I work on integration this in TeamCity.
    Tautvydas-Zilys, Do you know the way how to create visual studio solution for windows standalone through command line?
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yeah, it's non-obvious. You can do it like this:

    Code (csharp):
    1. EditorUserBuildSettings.SetPlatformSettings("Standalone", "CreateSolution", "true");
    You could also rebuild the executable once, and then commit it to your source control and just overwrite the one from the regular build - it should make your build faster.
     
    daleksan likes this.
  6. Cybernetic_Nick

    Cybernetic_Nick

    Joined:
    Nov 1, 2018
    Posts:
    4
    Is this still possible in Unity 2019.3? I am able to open the build in Visual Studios, but I am unable to locate and update the WindowsPlayerVersion.rc?

    I do see that WindowsPlayer.rc has a line of code that includes "WindowsPlayerVersion.rc", and that the Windows PlayerEngine located in the Unity Editor application folder has a file named "WindowsPlayerVersion.rc" but I am unable to change that file.

    What is the best approach for updating this file within Visual Studios to where I can still rebuild the project for distribution?

    Thank you.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Nothing changed in 2019.3. It's still there:
    upload_2020-2-20_14-10-55.png

    It references it from the project directory, not from Unity Editor application folder.
     
    Cybernetic_Nick likes this.
  8. Cybernetic_Nick

    Cybernetic_Nick

    Joined:
    Nov 1, 2018
    Posts:
    4
    Thank you for your help. I was trying to find this file within the Visual Studios solution but it was not showing up within the IDE's Resource View panel, and then I must have overlooked it when checking through the directory.
     
  9. localprojects

    localprojects

    Joined:
    Apr 26, 2019
    Posts:
    8
    Hi,

    Thank you for the info. got it working.

    I just wanted to confirm this is the only way(compile solution and then change) and that there is no other automation-friendly way, and also wanted to ask the reason the version number doesn't cascade from the app/unity version number.

    Thank you
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    It does cascade from Unity version. By default, the version field will be the same as the Unity version.

    Automation friendly way: do the change manually once, commit it to your repository and then have automation either build or copy it.
     
  11. hanidahanib75

    hanidahanib75

    Joined:
    Apr 17, 2020
    Posts:
    1
    upload_2020-4-17_17-39-35.png

    i want to ask how i can open this file if my computer using 32 bit
     
  12. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    While I can generate a .sln file - I'm no C++ expert and without documentation on what to change in WindowsPlayerVersion.rc -- everything I've tried just corrupts the WindowsPlayerVersion.rc file and I have to start over again. There must be more documentation out there but I can't find it?
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    It's a standard Windows Resource file, and the format is documented by Microsoft: https://docs.microsoft.com/en-us/windows/win32/menurc/about-resource-files
     
  14. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    View Code: WindowsPlayerVersion.rc

    #include <windows.h>
    #include "UnityConfigureRevision.gen.h"
    #include "UnityConfigureVersion.gen.h"
    #include "UnityConfigureOther.gen.h"

    VS_VERSION_INFO VERSIONINFO
    FILEVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN,UNITY_VERSION_BLD
    PRODUCTVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN,UNITY_VERSION_BLD
    FILEFLAGSMASK 0x17L
    #ifdef _DEBUG
    FILEFLAGS 0x1L
    #else
    FILEFLAGS 0x0L
    #endif
    FILEOS 0x4L
    FILETYPE 0x0L
    FILESUBTYPE 0x0L
    BEGIN
    BLOCK "StringFileInfo"
    BEGIN
    BLOCK "040904b0"
    BEGIN
    VALUE "FileVersion", UNITY_VERSION_WIN
    VALUE "ProductVersion", UNITY_VERSION_WIN
    VALUE "Unity Version", UNITY_VERSION_UNDER_HASH
    END
    END
    BLOCK "VarFileInfo"
    BEGIN
    VALUE "Translation", 0x409, 1200
    END
    END

    How would I add UNITY_COPYRIGHT as it isn't populated with this code?
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Something like this:

    Code (csharp):
    1. #include <windows.h>
    2. #include "UnityConfigureRevision.gen.h"
    3. #include "UnityConfigureVersion.gen.h"
    4. #include "UnityConfigureOther.gen.h"
    5.  
    6. VS_VERSION_INFO VERSIONINFO
    7.  FILEVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN,UNITY_VERSION_BLD
    8.  PRODUCTVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN,UNITY_VERSION_BLD
    9.  FILEFLAGSMASK 0x17L
    10. #ifdef _DEBUG
    11.  FILEFLAGS 0x1L
    12. #else
    13.  FILEFLAGS 0x0L
    14. #endif
    15.  FILEOS 0x4L
    16.  FILETYPE 0x0L
    17.  FILESUBTYPE 0x0L
    18. BEGIN
    19.     BLOCK "StringFileInfo"
    20.     BEGIN
    21.         BLOCK "040904b0"
    22.         BEGIN
    23.             VALUE "FileVersion", UNITY_VERSION_WIN
    24.             VALUE "ProductVersion", UNITY_VERSION_WIN
    25.             VALUE "Unity Version", UNITY_VERSION_UNDER_HASH
    26.             VALUE "LegalCopyright", "RambosRide (c) 2022"
    27.         END
    28.     END
    29.     BLOCK "VarFileInfo"
    30.     BEGIN
    31.         VALUE "Translation", 0x409, 1200
    32.     END
    33. END
    That section is documented here: https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
     
    RambosRide likes this.
  16. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    That's the information I couldn't find I didn't know to look for "StringFileInfo" - Thank you!
     
  17. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    2022-04-14_7-51-00.jpg

    IDK if I'm doing something wrong but if I comment out
    FILEVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN,UNITY_VERSION_BLD
    On the compiled exe the File Version gets set to 0.0.0.0 and not the FileVersion in StringFileInfo.

    In the Screen grab you can see it still shows unity FILEVERSION, not MY_VERSION

    I can override the FILEVERSION values but would have thought the StringFileInfo:FileVersion would populate that field.

    Unity version 2020.3.25f1
     
    Last edited: Apr 14, 2022
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I think those are two separate properties, and Properties dialog only shows one of them. If you used a tool that showed full information, you'd probably see both. You'll have to change FILEVERSION if you want it to show up in the Properties dialog.
     
    RambosRide likes this.
  19. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    Thanks for confirming the issue.

    I will modify the FILEVERSION as suggested.

    I really appreciate the help!
     
  20. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    When we went to 2021.3.4 the windowsstandalone visual studio sln project was changed (still using VS2019)
    When I compile now the ProductVersion displaying odd character, in code I use the same constant I use for File Version which does display correctly - any ideas? Thanks!

    VALUE "FileVersion", UNITY_VERSION_WIN
    VALUE "ProductVersion", UNITY_VERSION_WIN

    - please see attached pic.
     

    Attached Files:

  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I think the issue is that UNITY_VERSION_WIN is a number while it is expecting a string. Try replacing it with
    Code (csharp):
    1. ""
    or
    Code (csharp):
    1. "My Product Name"
    Alternatively you could completely delete that line from the .rc file.
     
  22. stfunity

    stfunity

    Joined:
    Sep 9, 2018
    Posts:
    65
    I found this thread partially helpful but in my result build from the Visual Studio SLN Unity outputs, it breaks my references to streaming assets. This is a Windows exe build.

    The directory structure of the output builds is that standard build/bin/x64/Master, which I suspect is problematic because I want my result application to look -just- like a Unity build i.e. the app sits next to its _Data folder in the root of the application, not 4 directories up and around the corner. So, if I put the x64 exe output into the root where it should be, I lose all my speech recognition models in StreamingAssets under the _Data folder.

    What do I do about that? How can I make the structure proper?
    My builds straight from Unity have no such issue, but then my app properties are generic and come with a Unity copyright stamp and I don't want that.

    Catch 22 so far, search queries on this subject lead nowhere because if you look up "unity visual studio build streamingassets path issues/wrong/structure/etc" you get nothing specific from those search queries and all the various issues people cite are absolute red herrings for my current problem. This is the only thread I've learned much of anything from that contains these terms

    Silly to me because why bother entering my Company and Product info if it's not going to be appended to the output build Exe from Unity?

    Going over to VSCode where they don't care if I lose my streamingassets when they make my "fancy" exe with 6 string properties reassigned [heaven forbid] seems like it shouldn't be the move but here I am.
     
  23. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    So first of all, yes, Visual Studio solution builds a little different folder structure. Instead of the usual:

    Code (csharp):
    1. Game_Data
    2. Game.exe
    3. UnityPlayer.dll
    You get:

    Code (csharp):
    1. Game_Data
    2. <ARCHITECTURE>\<CONFIG>\Game.exe
    3. <ARCHITECTURE>\<CONFIG>\UnityPlayer.dll
    What this allows doing is sharing the same data folder for several different game build configurations: you might want to ship both 32-bit and 64-bit player and duplicating the data folder would double the size of your game. This allows you only have one copy of it. It also makes builds faster because Unity and Visual Studio does not need to copy the data folder into each possible configuration output folder.

    You can take all the files from "x64\Release", move them 2 directories up and get rid of architecture specific folders. You could also just do normal builds from Unity, and replace the resulting .exe after the build with the one that you premade from a built Visual Studio project previously.

    That said, I don't understand how this breaks your streaming assets. Are you calculating the paths yourself or something? Application.streamingAssetsPath should point to the right folder regardless of how the build is made.

    I think it sets the game title in the titlebar and also uses that information to compute log paths and Application.persistentDataPath.
     
  24. stfunity

    stfunity

    Joined:
    Sep 9, 2018
    Posts:
    65
    It's hard to say -why- but basically after attempting the build like this and having no visible errors, the built app cannot access the StreamingAssets path, but inside Unity everything works perfectly. I can't tell what parameters might have been altered or whether Plastic SCM isn't detecting a difference, but even with rollback attempts, the results are the same now.

    If I attach a debugger to the build, it just indicates "model of model provider is null" out of the Vosk/Recognissimo libraries

    We had this same sort of error last week on an unrelated path on our Mac Studio running 2022.1.16f1 - before any of this came up, and to solve it we had to upgrade Unity to 2022.1.20f1 and that stopped the inexplicable "no streaming assets found at [the path is valid ?!, it's right there why is it null]"

    So I am not even sure if the issue is strictly related to any attempt to build VS Solutions out of the project. The project worked fine for months, then stopped having Speech Recognition on builds on the Mac suddenly, only solved by upgrading Unity 0.04 versions. Then we thought everything was good, then I tried to customize the App Details on Windows and otherwise found this thread helpful, except then the same error on a totally different platform.

    Details are scant on why.

    One thing I can tell you is on the PC here after this Solution build attempt, Unity now adds the WinPixEventRuntime.dll to my build folder, which it never did before. I don't tend to run debug builds.

    Not sure if any of those facts are clues but like I said, same TYPE of error but seemingly different cause on Mac vs Windows, on Mac, upgrading solved it. The other workstations were upgraded to match, then after VS build, PC goes down with the same problem and Mac version build is unaffected.

    And for the record, all the code I write and the code in the packages I'm using for Speech Recognition all refer to "Application.streamingAssetsPath" or "Application.persistentDataPath" explicitly rather than some hardcoded path.
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    WinPixEventRuntime.dll is used by development builds, which map to "Release" configuration in Visual Studio. To build non-development builds, use the "Master" configuration.
     
  26. P_e_t_a_c_h_e_k

    P_e_t_a_c_h_e_k

    Joined:
    Dec 26, 2017
    Posts:
    26
  27. philipgen

    philipgen

    Joined:
    Jul 19, 2018
    Posts:
    7
    Hello, I am using Unity 2021.3.9f1 and Visual Studio 2019
    I created the solution and modified the WindowsPlayerVersion.rc by Notepad and just changed the values.

    Code (CSharp):
    1. #include <windows.h>
    2. #include "UnityConfiguration.gen.cpp"
    3.  
    4. VS_VERSION_INFO VERSIONINFO
    5. FILEVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN
    6. PRODUCTVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN
    7. FILEFLAGSMASK 0x17L
    8. #ifdef _DEBUG
    9. FILEFLAGS 0x1L
    10. #else
    11. FILEFLAGS 0x0L
    12. #endif
    13. FILEOS 0x4L
    14. FILETYPE 0x0L
    15. FILESUBTYPE 0x0L
    16. BEGIN
    17.     BLOCK "StringFileInfo"
    18.     BEGIN
    19.         BLOCK "040904b0"
    20.         BEGIN
    21.             VALUE "FileVersion", "2.10.0.10800"
    22.             VALUE "ProductVersion", "2.1.0"
    23.             VALUE "Unity Version", "2021"
    24.         END
    25.     END
    26.     BLOCK "VarFileInfo"
    27.     BEGIN
    28.         VALUE "Translation", 0x409, 1200
    29.     END
    30. END
    31.  
    But when I rebuild the solution in Visual Studio and check the exe file. I'm still getting empty values.

    upload_2022-11-4_16-40-27.png
     
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you show the full WindowsPlayerVersion.rc file after your edits?
     
  29. philipgen

    philipgen

    Joined:
    Jul 19, 2018
    Posts:
    7
    It's in my previous post. All I did was change the value of the FileVersion, ProductVersion, Unity Version

    Code (CSharp):
    1. #include <windows.h>
    2. #include "UnityConfiguration.gen.cpp"
    3. VS_VERSION_INFO VERSIONINFO
    4. FILEVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN
    5. PRODUCTVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN
    6. FILEFLAGSMASK 0x17L
    7. #ifdef _DEBUG
    8. FILEFLAGS 0x1L
    9. #else
    10. FILEFLAGS 0x0L
    11. #endif
    12. FILEOS 0x4L
    13. FILETYPE 0x0L
    14. FILESUBTYPE 0x0L
    15. BEGIN
    16.     BLOCK "StringFileInfo"
    17.     BEGIN
    18.         BLOCK "040904b0"
    19.         BEGIN
    20.             VALUE "FileVersion", "2.10.0.10800"
    21.             VALUE "ProductVersion", "2.1.0"
    22.             VALUE "Unity Version", "2021"
    23.         END
    24.     END
    25.     BLOCK "VarFileInfo"
    26.     BEGIN
    27.         VALUE "Translation", 0x409, 1200
    28.     END
    29. END
    30.  
     
  30. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You might have to change these too:

    Code (csharp):
    1. FILEVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN
    2. PRODUCTVERSION UNITY_VERSION_VER,UNITY_VERSION_MAJ,UNITY_VERSION_MIN
     
  31. philipgen

    philipgen

    Joined:
    Jul 19, 2018
    Posts:
    7
    Code (CSharp):
    1. #include <windows.h>
    2. #include "UnityConfiguration.gen.cpp"
    3.  
    4. VS_VERSION_INFO VERSIONINFO
    5.     FILEVERSION 1, 0, 0, 0
    6.     PRODUCTVERSION 1, 0, 0, 0
    7.     FILEFLAGSMASK 0x17L
    8. #ifdef _DEBUG
    9. FILEFLAGS 0x1L
    10. #else
    11. FILEFLAGS 0x0L
    12. #endif
    13. FILEOS 0x4L
    14. FILETYPE 0x0L
    15. FILESUBTYPE 0x0L
    16.  
    17. BEGIN
    18.     BLOCK "StringFileInfo"
    19.     BEGIN
    20.         BLOCK "040904b0"
    21.             BEGIN
    22.                 VALUE "Comments", "Tenta a tua Sorte!"
    23.                 VALUE "CompanyName", "Adsglobal"
    24.                 VALUE "FileDescription", "Jogo Simples"
    25.                 VALUE "FileVersion", "1.0.0.0"
    26.                 VALUE "InternalName", "Tenta a Sorte"
    27.                 VALUE "LegalCopyright", "Copyright © Rodrigo Santos 2020"
    28.                 VALUE "OriginalName", "Tenta a Sorte"
    29.                 VALUE "ProductName", "Tenta a Sorte"
    30.                 VALUE "ProductVersion", "1.0.0.0"
    31.             END
    32.     END
    33.     BLOCK "VarFileInfo"
    34.         BEGIN
    35.             VALUE "Translation", 0x0816, 1200
    36.         END
    37. END
    No. I did it like this and I am still getting empty results. I even started with a brand new Unity 2021.3.9f1 project.
     
  32. philipgen

    philipgen

    Joined:
    Jul 19, 2018
    Posts:
    7
    Turns out it does work.
    Before, for some reason, when I build in my folder that is linked to my cloud account, (Box.com), I was unable to see the properties.
    I then built it on a local folder, (C:\temp\), and it works perfectly.
     
    Tautvydas-Zilys likes this.
  33. RambosRide

    RambosRide

    Joined:
    Nov 8, 2020
    Posts:
    41
    Sorry for delayed response.. this fixed the problem. Thanks!
     
  34. foozuu

    foozuu

    Joined:
    Jan 26, 2015
    Posts:
    1
    ul_antnasce likes this.
  35. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    376
    I simple use the resource hacker tool for my exe files, very easy to use and works fine ^^ :)
    open the exe file -> edit -> compile script -> save as new exe file or replace.
    But it would be great when we can edit this in player settings before we compile.

    http://angusj.com/resourcehacker/
     
    Last edited: Jan 26, 2023
  36. daddycaddy

    daddycaddy

    Joined:
    Sep 10, 2019
    Posts:
    1
    Hi was going through the steps in this forum but when i tried to build my project through the Sln i got these errors
     
  37. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You should be able to right click on the solution file in the solution explorer and press "Retarget solution".