Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Visual Studio (2022) C# file template parameter don't work with assembly definition project?

Discussion in 'Code Editors & IDEs' started by R1PFake, Apr 28, 2022.

  1. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    555
    Hello, I try to create a custom C# file template with the following parameter set: https://docs.microsoft.com/en-us/visualstudio/ide/template-parameters?view=vs-2022
    The template is loaded and works, but some of the parameters are not replaced as expected.

    Context: I have assembly definition projects, for example "Data", which creates a C# project with "Data" as project name and default namespace.

    For my template I try to get the name "Data", but the parameter like safeprojectname, projectname or defaultnamespace are not replaced at all, other parameter like rootnamespace work but they return the full namespace for example "Data.Subfolder.Blabla".

    Does anyone know why the other parameters don't work or is there any other useful parameter to get just "Data" alone?

    Btw the C# files are created inside Visual Studio, not in the Unity Editor, so VS handles the template loading and parameter replacing. These parameter work fine in a "normal" C# project, so I assume it has something to do with the way Unity creates project files, maybe some entry.
     
    Last edited: Aug 11, 2022
  2. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    555
    Bump,
    I assume there are not many people who use custom C# template files with Unity, at least on this forum, but it would still be nice to get a answer from a Unity member.