Change assembly name
By default, the assembly name is Assembly-CSharp. Is there a way to change this name?
I personally need this because my Unity project is part of a bigger solution, and I can't have it called Assembly-CSharpXXXX every time Unity spits out its project files. Any idea how/where I can affect this change?
Answer by BorisOkunskiy · Nov 13, 2020 at 08:04 AM
For anyone who came here from Google search: the correct way is to create an Assembly Definition in your Assests/Scripts
folder and name it appropriately. This generates the correct .csproj
files and furthermore uses the correct assembly name everywhere (e.g. if you use JsonUtility
to serialize references with [SerializeReference]
you'll get an appropriate assembly name within your JSON files instead of Assembly-CSharp
).
Upvoting this because it indeed makes Unity not include Assembly-CSharp.dll
on the output, unless you have any runtime script outside the assembly definition directories (the folders containing .asmdef
and .asmref
). Once you get rid of all non-editor scripts outside the assembly def/ref folders, you'll want to delete the auto-generated Assembly-CSharp.csproj
, which won't be generated again.
Note: Remember that special folders like Editor
aren't special under asmdef/ref. Also, you'll need to explicitly reference any runtime assemblies you use (packages, plugins) on the asmdef, since they won't be Auto-Referenced.
Answer by FortisVenaliter · Jun 09, 2016 at 08:07 PM
Not that I'm aware of. And it's only an internal code project name, so why do you need to change it?
As someone who wants to change the assembly name, I can answer that question.
I'm developing a class library with internal types and members, and would like the InternalsVisibleTo assembly attribute to be more restrictive than "Assembly-CSharp"
Answer by Hauthorn · Aug 15, 2019 at 12:05 AM
Yes, you can. I'm able to change it like you would any project, via project properties (Alt + Enter). You may need to change a setting in Options -> Tools -> Tools for Unity called "Access to project properties". You also many need to close and re-open your solution to see the effects of changing the settings.
Your answer
Follow this Question
Related Questions
How to have Unity Cloud Build point to custom build call. 0 Answers
Unity Start not called on build, but it does when testing 0 Answers
/Editor Scripts Organization with 2017.3 Assembly Definition Files 2 Answers
UnityEditor unusable ? :: error CS0016 1 Answer
Adding additional C# scripts after build (Android, iOS) 1 Answer