monodevelop-template-creator-addin icon indicating copy to clipboard operation
monodevelop-template-creator-addin copied to clipboard

Latest Version

Open tpitman opened this issue 3 years ago • 14 comments

I would like to get a version of this that works with the latest Visual Studio 2019 for Mac. I tried to install it and got errors, but it also showed up. I then tried to use it and got errors.

tpitman avatar Jun 30 '21 22:06 tpitman

The template creator addin 0.5 works in Visual Studio for Mac 8.10.4.

Can you provide more information?

  1. Template creator addin version being used. Visual Studio for Mac's about dialog shows the current template creator addin version.
  2. Visual Studio for Mac's IDE log file - Help - Open Log Directory.
  3. What errors you are seeing.

Thanks.

mrward avatar Jul 01 '21 08:07 mrward

I think the errors might have been because I initially installed version 0.1 and then tried to upgrade. After getting that error I had removed the extension and posted my issue here. After your response I installed the extension directly from the gallery and didn't get any errors.

Now I think I just have some operational questions.

I want to make a Solution template that includes some set project, but also some generically named projects. I am making mobile apps that are all similar to each other. The basic shared app and iOS / Android apps I want to be able to fill in the names to those. Then those projects will reference some supporting projects that will have the same name and are shared libraries for all projects.

When I tried to create the solution template the names all had Android in them. Not sure why. Then I am not sure how to set up the generic names so they can be filled in when I use the template later to create a new Solution based on the template.

Can you help with that?

tpitman avatar Jul 01 '21 14:07 tpitman

Having project names that are replaced is done via sourceName in the template.json file:

https://docs.microsoft.com/en-gb/dotnet/core/tools/custom-templates#templatejson

image

image

So any names in code, in project files, or the names of the project files would need to use that name, at least part of it and it is replaced when the new solution is created from that template.

mrward avatar Jul 01 '21 14:07 mrward

So it is automatic then. That is good. I will play around with that.

My text question is once I have created the template it adds a .tempalte.config folder with the template json in it. What do I know do with this solution? It is my original solution that I created the template from.

How do I now "install" this template for creating new solutions from?

tpitman avatar Jul 01 '21 14:07 tpitman

I decided to just try creating a new solution from the "template" that I created and here is what I got:

image

That is not what I was hoping. Here is the solution I created the template from:

image

I expected the new solution to have all of the other projects included. It also does not have the shared project (should be called just parallax). It only has the .iOS and .Android project.

Here is the template.json file:

{ "$schema": "http://json.schemastore.org/template", "author": "Tony Pitman", "classifications": [], "description": "", "name": "Powerteq Mobile Bluetooth", "defaultName": "Powerteq", "identity": "Powertq.Mobile.CSharp", "groupIdentity": "Powertq.Mobile", "tags": { "language": "C#", "type": "project", "vsmac-category": "other/net/general" }, "shortName": "Flashsynq", "sourceName": "Flashsynq", "guids": [ "{9543F5C7-FAAF-40D3-AE86-D30E3AC9B423}", "{54F854A1-F420-46F8-A7DA-5A7F1625BADE}", "{E7BD3254-9FA9-48AF-8638-EF385C78DDE6}", "{DA0521D8-6A30-41B3-AD86-0249C432F942}", "{5CBA8CE4-7E39-4C27-8055-309BD7F01012}", "{DC32EE03-A79F-4E84-9CE7-0FB198B3B867}", "{25C5AB14-E22F-4A17-BA3B-E1E15C874BB9}", "{C7D6D56C-D52D-45CE-829C-528B08747153}", "{5FAB4F64-37CD-4AF3-BFFB-FCB671AE553A}" ], "sources": [ { "modifiers": [ { "exclude": [ ".vs/**/*" ] } ] } ], "primaryOutputs": [ { "path": "../../Components/ColorPicker/DSoft.XamarinForms.Controls/DSoft.XamarinForms.Controls.csproj" }, { "path": "Flashsynq.Android/Flashsynq.Android.csproj" }, { "path": "Flashsynq.iOS/Flashsynq.iOS.csproj" }, { "path": "../../Components/HybridWebView/HybridWebViewMobile/HybridWebViewMobile.csproj" }, { "path": "../../Components/HybridWebView/HybridWebViewMobile.Android/HybridWebViewMobile.Android.csproj" }, { "path": "../../Components/HybridWebView/HybridWebViewMobile.iOS/HybridWebViewMobile.iOS.csproj" }, { "path": "../../Components/bluetoothle/Plugin.BluetoothLE/Plugin.BluetoothLE.csproj" }, { "path": "../../Shared Libraries/Mobile/PowerteqBluetooth/PowerteqBluetooth.csproj" }, { "path": "../../Components/PowerteqUnits/PowerteqUnits.csproj" } ] } `

tpitman avatar Jul 01 '21 14:07 tpitman

How to install depends on how you want to use the template. The template creator addin registers any project template you created directly so it is available in the new project dialog within Visual Studio for Mac. In preferences there are folders you can define which will be scanned for these the template.json files and they will be picked up.

Another option here is to package them up and make them available to install with dotnet new from the command line - https://docs.microsoft.com/en-us/dotnet/core/tools/custom-templates

Visual Studio for Mac supports custom templates installed with dotnet new --install but you have to opt into this via preferences - Other - Preview features - Show all .NET Core templates in the New Project dialog.

Looking at your template.json I suspect the problem is that the missing projects are not in the primaryOutputs. Visual Studio for Mac will not add projects if they are missing from the set of primaryOutputs. There is also some logic in Visual Studio for Mac to look for all projects if the template does not specify any primary outputs but the recommended approach is to define the primary outputs.

As to why the project is missing from the template.json - might be a bug.

mrward avatar Jul 01 '21 15:07 mrward

Mmm, maybe it is just not happy about the ../ in the paths? All those projects are missing. Did they get created outside the solution or not at all?

mrward avatar Jul 01 '21 15:07 mrward

That is probably it then. I have a folder with many different solutions in it. Some are desktop, some are server, some are mobile. I then have folders with shared libraries and components. So in this case my Mobile apps live in a folder and some of these shared libraries live outside of that sub folder structure.

Is that something that you will be able to support? I don't know if it would be considered outside the normal since many companies do this sort of thing.

On the shared project not being there being a bug, is there something I can do to help diagnose that?

tpitman avatar Jul 01 '21 15:07 tpitman

It is more a question of whether template.json + VS Mac can support it. The solution file is created at the top level directory in VS Mac so I am not sure how this can work if the template wants to create projects above this solution directory. Can you have the solution at the root and other projects underneath that directory?

mrward avatar Jul 01 '21 16:07 mrward

That would break the way we have our shared projects arranged. I guess I can have the base project / solution template without the shared libraries and then just add them manually.

As long as we can get the main projects all there (shared, ios and Android) that would at least give us a big step up.

I will try making the template without those other shared libraries and see what happens.

tpitman avatar Jul 01 '21 17:07 tpitman

Another thing maybe to look at is using a solution template. VS Mac 8.10 should support those. These have a special type of 'solution' and the primary output is the solution itself, which may allow you to do some more complicated structure. An example of a solution template is the NuGet.Boxed templates that you can install with dotnet new.

https://github.com/Dotnet-Boxed/Templates/blob/main/Source/NuGetTemplate/.template.config/template.json#L16-L25

mrward avatar Jul 01 '21 21:07 mrward

I thought the solution template was what I did. I right clicked on the solution, not the project and used the Create Template menu item from there.

On Thu, Jul 1, 2021 at 3:15 PM Matt Ward @.***> wrote:

Another thing maybe to look at is using a solution template. VS Mac 8.10 should support those. These have a special type of 'solution' and the primary output is the solution itself, which may allow you to do some more complicated structure. An example of a solution template is the NuGet.Boxed templates that you can install with dotnet new.

https://github.com/Dotnet-Boxed/Templates/blob/main/Source/NuGetTemplate/.template.config/template.json#L16-L25

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mrward/monodevelop-template-creator-addin/issues/10#issuecomment-872555059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWFTQYJEFVGEYGFF6NKCD3TVTLIXANCNFSM47TGTTUA .

tpitman avatar Jul 01 '21 21:07 tpitman

Back when the template creator addin was made there was not really a real solution template. The template creator addin's concept of a solution template is a template that has multiple projects, the solution file would still be created by VS Mac. This new kind of solution template, that the Boxed templates have, means that you can have the template provide the solution file itself and VS Mac will not create its own for you.

mrward avatar Jul 01 '21 21:07 mrward

Ok. I didn't realize you were talking about a whole different type of template. I thought you were just talking about clicking on the solution create template in the package you wrote.

I will try taking a look at this other one.

On Thu, Jul 1, 2021 at 3:24 PM Matt Ward @.***> wrote:

Back when the template creator addin was made there was not really a real solution template. The template creator addin's concept of a solution template is a template that has multiple projects, the solution file would still be created by VS Mac. This new kind of solution template, that the Boxed templates have, means that you can have the template provide the solution file itself and VS Mac will not create its own for you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mrward/monodevelop-template-creator-addin/issues/10#issuecomment-872560233, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWFTQ3B7EWEVOWQ4GQGTFTTVTMHTANCNFSM47TGTTUA .

tpitman avatar Jul 01 '21 21:07 tpitman