RehanSaeed / rehansaeed.github.io

Muhammad Rehan Saeed's Blog
https://rehansaeed.com
30 stars 6 forks source link

[Comment] Custom Project Templates Using dotnet new #69

Open RehanSaeed opened 4 years ago

RehanSaeed commented 4 years ago

https://rehansaeed.com/custom-project-templates-using-dotnet-new/

RehanSaeed commented 4 years ago

Mike-EEE Mike-EEE commented on 2017-01-18 21:38:44

WOWWWW... template.json and Templates.nuspec that is described in XML. Great to see that everything is nice and consistent and you aren't forced to constantly switch between data formats! ;)

You would think we would all learn after project.json. Guess not. Everything else looks cool, though. Well, except for the minor detail that this is all baked in the error-prone and difficult-to-work-with-and-discover CLI that we have spent 20 years after DOS to remove ourselves from...

But besides that, looks good. :)

RehanSaeed commented 4 years ago

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-01-18 21:49:38

WOWWWW... template.json and Templates.nuspec that is described in XML. Great to see that everything is nice and consistent and you aren't forced to constantly switch between data formats! ;)

You would think we would all learn after project.json. Guess not. Everything else looks cool, though. Well, except for the minor detail that this is all baked in the error-prone and difficult-to-work-with-and-discover CLI that we have spent 20 years after DOS to remove ourselves from...

But besides that, looks good. :)

Templates.nuspec is a NuGet file which has been around for a long time in XML. New things tend to get built in JSON because it's less verbose. I tend to think that both formats have their strengths. I really liked project.json and am sad to see it go but I can see why they did it.

RehanSaeed commented 4 years ago

nemke nemke commented on 2017-01-24 19:12:23

Can this be used for multi-project templates?

RehanSaeed commented 4 years ago

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-01-25 08:58:33

Can this be used for multi-project templates?

I'm not sure. I've asked the question, just can't remember the answer.

RehanSaeed commented 4 years ago

EBekker EBekker commented on 2017-02-01 15:07:12

WOWWWW... template.json and Templates.nuspec that is described in XML. Great to see that everything is nice and consistent and you aren't forced to constantly switch between data formats! ;)

You would think we would all learn after project.json. Guess not. Everything else looks cool, though. Well, except for the minor detail that this is all baked in the error-prone and difficult-to-work-with-and-discover CLI that we have spent 20 years after DOS to remove ourselves from...

But besides that, looks good. :)

For you, there is the Visual Studio IDE.

RehanSaeed commented 4 years ago

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-02-01 15:27:17

For you, there is the Visual Studio IDE.

The VS IDE does not provide optional feature support. The VS IDE will soon use the templating engine I describe here to drive their project and item templates.

RehanSaeed commented 4 years ago

Sayed Ibrahim Hashimi (MSFT) Sayed Ibrahim Hashimi (MSFT) commented on 2017-02-08 18:21:21

Can this be used for multi-project templates?

Yes there is no distinction between single and multi project templates.

RehanSaeed commented 4 years ago

Sayed Ibrahim Hashimi (MSFT) Sayed Ibrahim Hashimi (MSFT) commented on 2017-02-08 18:23:59

WOWWWW... template.json and Templates.nuspec that is described in XML. Great to see that everything is nice and consistent and you aren't forced to constantly switch between data formats! ;)

You would think we would all learn after project.json. Guess not. Everything else looks cool, though. Well, except for the minor detail that this is all baked in the error-prone and difficult-to-work-with-and-discover CLI that we have spent 20 years after DOS to remove ourselves from...

But besides that, looks good. :)

The format of the template json file is extensible. It doesn't have to be JSON, it can be any format. We just created a provider that reads from JSON to begin with.

RehanSaeed commented 4 years ago

Giuseppe Piscopo Giuseppe Piscopo commented on 2017-02-23 00:04:48

Just making sure, after reading through whole post: can you include more than one project template in one nuget package? Thank you!

RehanSaeed commented 4 years ago

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-02-23 10:13:11

Just making sure, after reading through whole post: can you include more than one project template in one nuget package? Thank you!

I've not tried this yet but I think you can move the .template.config folder up a level so that it exists alongside both project folders and it should still work.

RehanSaeed commented 4 years ago

Sayed Ibrahim Hashimi Sayed Ibrahim Hashimi commented on 2017-03-04 00:07:21

Just making sure, after reading through whole post: can you include more than one project template in one nuget package? Thank you!

Yes a NuGet package can contain several templates.

RehanSaeed commented 4 years ago

Issa Issa commented on 2019-04-18 21:38:14

How can I create the template so that it includes a solution file (.sln) and any other files in the directory. Creating the nuget package shows everything in the content folder sln, extra files, subfolder for project. Everything is there.

But doing a dotnet new MySolutionTemplate only creates the csproj and its files. It ignores the parent directory which includes the solution file.

Is there a way to do this?

RehanSaeed commented 4 years ago

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2019-04-19 14:29:59

How can I create the template so that it includes a solution file (.sln) and any other files in the directory. Creating the nuget package shows everything in the content folder sln, extra files, subfolder for project. Everything is there.

But doing a dotnet new MySolutionTemplate only creates the csproj and its files. It ignores the parent directory which includes the solution file.

Is there a way to do this?

You can look at https://github.com/Dotnet-Boxed/Templates for an example.

Malayp commented 4 years ago

Hello, after installing these templates.

But the problem is, It is not showing in Visual Studio Project Templates. Can you please let me why it's not showing in visual sudio?

RehanSaeed commented 4 years ago

A UI in Visual Studio does not exist yet, although it's currently being built.

Malayp commented 4 years ago

Hi @RehanSaeed

Thank you so much for your quick response.

I am having few more questions : What is the installation path for both VSIX Project templates and dotnet CLI Project templates?

And can you please give a rough timeline, when that UI will be ready in Visual Studio? So that we can answer our clients as they are facing difficulties by using command line and visual studio both.

And Is there a way to PACK VSIX installer for NUGET sharing?

RehanSaeed commented 4 years ago

Not sure about install path.

Regarding timeline, that's something you can ask in the thread I linked.

Malayp commented 4 years ago

Thank you 👍 @RehanSaeed I will ask that in that linked thread.