question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use user input project name in template.json

See original GitHub issue

How to use user input project name in template.json?

I wanna rename some variables by project name, how can I get project name?

I’ve tried to use (name),but it did not work.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
seancpeterscommented, Sep 27, 2018

Ah ok, for something like this, you should use a “derived” type symbol. #1066 has a good explanation of how they work. For your specific situation, something like this should work:

"symbols": {
  "fullName": {
      "type": "derived",
      "valueSource": "name",  // "fullName" value will be derived from "name" value.
      "valueTransform": "prepend",  // the form to use to transform the value.
      "replaces": "ServiceName",
   }
},  // end of symbols section
"forms": {  // forms is a top level element
    "prepend": {
       "identifier": "replace",
       "pattern": "(?<=^)",  // match the start of the string. The lookbehind is probably unnecessary in this case.
       "replacement": "Service."  // replace what was matched by pattern with this value.
    }
}

A simpler method that might work (depending on your situation) is to have the literal “Service.” in your template content. For example if your sourceName = “Company.Application1”, in the content you could have something like this:

Service.Company.Application1

When the file is processed, Company.Application1 will be replaced by the value of the name parameter, but Service. will stay as is.

0reactions
TWiesendangercommented, Oct 1, 2022

Is there a way to use -o input from the user to replace something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference for template.json
To specify the template type, use the tag type . Supported types are: project , item , solution . no. shortName, A name...
Read more >
Custom templates for dotnet new - .NET CLI
You can quickly create a template from an existing project just by adding a ./.template.config/template.json configuration file to the project.
Read more >
how to update File Name in Visual Studio Project Template ...
I am trying to create a Visual Studio 2022 Project Template. ... I am not able to use the user input value to...
Read more >
How to Create Your .NET Project Template
Let's take a look. Assigning a custom application name. Using the dotnet new command with the built-in templates, you can specify the name...
Read more >
User Variables - Templates | Packer
User variables allow your templates to be further configured with variables from the command-line, environment variables, or files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found