Search Unity

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:
    542
    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:
    542
    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.