diff --git a/README.md b/README.md index 570c512..97b4940 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Join me on [**Developer Thoughts**](https://egvijayanand.in/), an exclusive blog |NuGet|VS Marketplace| |:---:|:---:| -|[![VijayAnand.FormsTemplates - NuGet Package](https://badgen.net/nuget/v/VijayAnand.FormsTemplates/)](https://www.nuget.org/packages/VijayAnand.FormsTemplates/)|[![Xamarin.Forms Project and Item Templates - VS Marketplace](https://badgen.net/vs-marketplace/v/egvijayanand.xamarin-forms-templates)](https://marketplace.visualstudio.com/items?itemName=egvijayanand.xamarin-forms-templates)| +|[![VijayAnand.FormsTemplates - NuGet Package](https://badgen.net/nuget/v/VijayAnand.FormsTemplates/?icon=nuget)](https://www.nuget.org/packages/VijayAnand.FormsTemplates/)|[![Xamarin.Forms Project and Item Templates - VS Marketplace](https://badgen.net/vs-marketplace/v/egvijayanand.xamarin-forms-templates?icon=visualstudio)](https://marketplace.visualstudio.com/items?itemName=egvijayanand.xamarin-forms-templates)| #### Access within Visual Studio IDE @@ -42,32 +42,50 @@ dotnet new update --check-only ```shell dotnet new update ``` + +#### Templates Included + Project template for Xamarin.Forms Class Library and is named as `formsclasslib` -And it currently targets Xamarin.Forms 5.0 Service Release 12 (ver. 5.0.0.2515). +Class library project template take the below optional parameters to override its target framework and to include the officially supported [Xamarin.CommunityToolkit](https://www.nuget.org/packages/Xamarin.CommunityToolkit), [Xamarin.CommunityToolkit.Markup](https://www.nuget.org/packages/Xamarin.CommunityToolkit.Markup), [Xamarin.Essentials](https://www.nuget.org/packages/Xamarin.Essentials), [CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm) (aka Microsoft MVVM Toolkit) or all NuGet packages: + +* `-f` | `--framework` - Default value is `netstandard2.0` +* `-it` | `--include-toolkit` - Default value is `false` +* `-im` | `--include-markup` - Default value is `false` +* `-ie` | `--include-essentials` - Default value is `false` +* `-imt` | `--include-mvvm-toolkit` - Default value is `false` + +*Note: The NuGet package version being added out-of-the-box are v2.0.x for the Xamarin Toolkit packages, v1.7.x for the Xamarin.Essentials package, and v8.1.0 for the MVVM Toolkit package.* -Item templates for `ContentPage`, `ContentView`, `ShellPage`, and `ResourceDictionary` in XAML and named as `forms-page`, `forms-view`, `forms-shell`, and `forms-resdict` respectively. There's a C# item template for `ContentPage` and `ContentView` and named as `forms-page-cs` and `forms-view-cs` respectively. +|Item|Template Name| +|:---:|:---:| +|ContentPage (XAML)|forms-page| +|ContentPage (C#)|forms-page-cs| +|ContentView (XAML)|forms-view| +|ContentView (C#)|forms-view-cs| +|ResourceDictionary (XAML)|forms-resdict| +|ShellPage (XAML)|forms-shell| +|ShellPage (C#)|forms-shell-cs| Use the below .NET CLI command to create the project, pages, and views out these templates: -An optional parameter has been introduced to choose the library target framework (.NET Standard 2.0 / 2.1): +Here, `-n` denotes the name of the project/page/view that is to be created (for pages/views, don't need to suffix it with `.xaml` / `.cs`, it will be added automatically) (Can also be specified as `--name` in the expanded form). -* `-f` | `--framework` - Default value is `netstandard2.0` +*Note: If name parameter is not provided, the .NET CLI template engine will take the current folder name in the context as its name.* +And `-na` denotes the namespace under which the file is to be created (Can also be specified as `--namespace` in the expanded form). + +*While working with .NET 7 or higher SDK, the namespace parameter in short notation needs to be passed as `-p:na` (i.e., it needs to be prefixed with `-p:`).* + +Class Library: +```shell +dotnet new formsclasslib -n MyApp.Core +``` Library target framework override: ```shell dotnet new formsclasslib -n MyApp.Core -f netstandard2.1 ``` - -Class library project templates take the below optional parameters to include the officially supported `Xamarin.CommunityToolkit`, `Xamarin.CommunityToolkit.Markup`, `Xamarin.Essentials`, `CommunityToolkit.Mvvm` (aka Microsoft MVVM Toolkit) or all NuGet packages: - -* `-it` | `--include-toolkit` - Default value is `false` -* `-im` | `--include-markup` - Default value is `false` -* `-ie` | `--include-essentials` - Default value is `false` -* `-imt` | `--include-mvvm-toolkit` - Default value is `false` - -Note: `v2.0.x` is the NuGet package version being added out-of-the-box for Xamarin Toolkit packages, `v1.7.3` for Xamarin.Essentials package and `v8.0.0` for MVVM Toolkit package. - +Option to include NuGet packages: ```shell dotnet new formsclasslib -n MyApp.UI -it -im -ie -imt ``` @@ -92,21 +110,17 @@ Shell: ```shell dotnet new forms-shell -n AppShell -na MyApp ``` +```shell +dotnet new forms-shell-cs -n MobileShell -na MyApp +``` Resource Dictionary: With C# code-behind file: ```shell -dotnet new forms-resdict -n DarkTheme -na MyApp.Themes +dotnet new forms-resdict -n DefaultTheme -na MyApp.Themes ``` - -Without C# code-behind file - Xaml Only (Option can be `-xo` or `--xaml-only`): +Without C# code-behind file - Xaml only (Option can be specified as `-xo` or `--xaml-only`): ```shell dotnet new forms-resdict -n DarkTheme -na MyApp.Themes -xo ``` - -Here `-n` denotes the name of the project/page/view that is to be created (for pages/views, don't need to suffix it with .xaml, it will be added automatically) (Can also be specified as `--name`). - -*Note: If name parameter is not provided, the .NET CLI template engine will take the current folder name in the context as its name.* - -And `-na` denotes the namespace under which the file is to be created (Can also be specified as `--namespace`). _While working with .NET 7 SDK, the `namespace` parameter in short notation needs to be passed as `-p:na` (i.e., it needs to be prefixed with `-p:`)._ diff --git a/src/FormsTemplatesCLI/FormsClassLib/.template.config/template.json b/src/FormsTemplatesCLI/FormsClassLib/.template.config/template.json index 40ca4f8..ab5c74a 100644 --- a/src/FormsTemplatesCLI/FormsClassLib/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsClassLib/.template.config/template.json @@ -11,7 +11,8 @@ "Library" ], "identity": "VijayAnand.FormsTemplates.ClassLib", - "description": "A project template for Xamarin.Forms 5 Class Library (ver. 5.0.0.2515)", + "groupIdentity": "VijayAnand.FormsTemplates.Library", + "description": "A project template for Xamarin.Forms 5 Class Library", "name": "Xamarin.Forms 5 Class Library", "shortName": "formsclasslib", "sourceName": "FormsClassLib.1", diff --git a/src/FormsTemplatesCLI/FormsClassLib/FormsClassLib.1.csproj b/src/FormsTemplatesCLI/FormsClassLib/FormsClassLib.1.csproj index 93af69b..e0de404 100644 --- a/src/FormsTemplatesCLI/FormsClassLib/FormsClassLib.1.csproj +++ b/src/FormsTemplatesCLI/FormsClassLib/FormsClassLib.1.csproj @@ -1,25 +1,26 @@ + LIB_TFM - latest enable + latest enable FormsClassLib._1 - + - + - + - + - + diff --git a/src/FormsTemplatesCLI/FormsPage/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsPage/.template.config/ide.host.json index 49c58be..348ae09 100644 --- a/src/FormsTemplatesCLI/FormsPage/.template.config/ide.host.json +++ b/src/FormsTemplatesCLI/FormsPage/.template.config/ide.host.json @@ -1,3 +1,3 @@ { "$schema": "http://json.schemastore.org/vs-2017.3.host" -} \ No newline at end of file +} diff --git a/src/FormsTemplatesCLI/FormsPage/.template.config/template.json b/src/FormsTemplatesCLI/FormsPage/.template.config/template.json index a7f3f65..eedc974 100644 --- a/src/FormsTemplatesCLI/FormsPage/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsPage/.template.config/template.json @@ -8,6 +8,7 @@ "UWP", "Windows", "Xamarin.Forms", + "Page", "Xaml" ], "identity": "VijayAnand.FormsPage", @@ -21,7 +22,8 @@ "path": "FormsPage.1.xaml" }, { - "path": "FormsPage.1.xaml.cs" + "path": "FormsPage.1.xaml.cs", + "condition": "(!XamlOnly)" } ], "tags": { @@ -34,6 +36,28 @@ "replaces": "MyApp.Namespace", "datatype": "text", "description": "namespace for the generated code" + }, + "xaml-only": { + "type": "parameter", + "datatype": "bool", + "default": "false", + "description": "If true, the output is generated without a C# code-behind file." + }, + "XamlOnly": { + "type": "computed", + "value": "(xaml-only)" + } + }, + "sources": [ + { + "modifiers": [ + { + "condition": "(XamlOnly)", + "exclude": [ + "FormsPage.1.xaml.cs" + ] + } + ] } - } + ] } diff --git a/src/FormsTemplatesCLI/FormsPage/FormsPage.1.xaml b/src/FormsTemplatesCLI/FormsPage/FormsPage.1.xaml index bae3225..a6b8431 100644 --- a/src/FormsTemplatesCLI/FormsPage/FormsPage.1.xaml +++ b/src/FormsTemplatesCLI/FormsPage/FormsPage.1.xaml @@ -1,14 +1,30 @@ - + + + + + + - - \ No newline at end of file + diff --git a/src/FormsTemplatesCLI/FormsPageCS/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsPageCS/.template.config/ide.host.json index 49c58be..348ae09 100644 --- a/src/FormsTemplatesCLI/FormsPageCS/.template.config/ide.host.json +++ b/src/FormsTemplatesCLI/FormsPageCS/.template.config/ide.host.json @@ -1,3 +1,3 @@ { "$schema": "http://json.schemastore.org/vs-2017.3.host" -} \ No newline at end of file +} diff --git a/src/FormsTemplatesCLI/FormsPageCS/.template.config/template.json b/src/FormsTemplatesCLI/FormsPageCS/.template.config/template.json index 22ab963..8772d0f 100644 --- a/src/FormsTemplatesCLI/FormsPageCS/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsPageCS/.template.config/template.json @@ -8,6 +8,7 @@ "UWP", "Windows", "Xamarin.Forms", + "Page", "Code" ], "identity": "VijayAnand.FormsPageCS", diff --git a/src/FormsTemplatesCLI/FormsPageCS/FormsPage.1.cs b/src/FormsTemplatesCLI/FormsPageCS/FormsPage.1.cs index 7001bfb..059ead7 100644 --- a/src/FormsTemplatesCLI/FormsPageCS/FormsPage.1.cs +++ b/src/FormsTemplatesCLI/FormsPageCS/FormsPage.1.cs @@ -13,6 +13,7 @@ public FormsPage__1() new Label() { Text = "Hello from Xamarin.Forms!!!", + TextColor = Color.Purple, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand } diff --git a/src/FormsTemplatesCLI/FormsResDict/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsResDict/.template.config/ide.host.json index 49c58be..348ae09 100644 --- a/src/FormsTemplatesCLI/FormsResDict/.template.config/ide.host.json +++ b/src/FormsTemplatesCLI/FormsResDict/.template.config/ide.host.json @@ -1,3 +1,3 @@ { "$schema": "http://json.schemastore.org/vs-2017.3.host" -} \ No newline at end of file +} diff --git a/src/FormsTemplatesCLI/FormsResDict/.template.config/template.json b/src/FormsTemplatesCLI/FormsResDict/.template.config/template.json index 6368211..49084dd 100644 --- a/src/FormsTemplatesCLI/FormsResDict/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsResDict/.template.config/template.json @@ -16,6 +16,15 @@ "name": "Xamarin.Forms ResourceDictionary", "shortName": "forms-resdict", "sourceName": "FormsResDict.1", + "primaryOutputs": [ + { + "path": "FormsResDict.1.xaml" + }, + { + "path": "FormsResDict.1.xaml.cs", + "condition": "(!XamlOnly)" + } + ], "tags": { "language": "C#", "type": "item" diff --git a/src/FormsTemplatesCLI/FormsResDict/FormsResDict.1.xaml b/src/FormsTemplatesCLI/FormsResDict/FormsResDict.1.xaml index c75908c..9052f34 100644 --- a/src/FormsTemplatesCLI/FormsResDict/FormsResDict.1.xaml +++ b/src/FormsTemplatesCLI/FormsResDict/FormsResDict.1.xaml @@ -1,16 +1,24 @@ - + - + diff --git a/src/FormsTemplatesCLI/FormsShell/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsShell/.template.config/ide.host.json index 49c58be..348ae09 100644 --- a/src/FormsTemplatesCLI/FormsShell/.template.config/ide.host.json +++ b/src/FormsTemplatesCLI/FormsShell/.template.config/ide.host.json @@ -1,3 +1,3 @@ { "$schema": "http://json.schemastore.org/vs-2017.3.host" -} \ No newline at end of file +} diff --git a/src/FormsTemplatesCLI/FormsShell/.template.config/template.json b/src/FormsTemplatesCLI/FormsShell/.template.config/template.json index 45978c4..95d8945 100644 --- a/src/FormsTemplatesCLI/FormsShell/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsShell/.template.config/template.json @@ -8,10 +8,11 @@ "UWP", "Windows", "Xamarin.Forms", + "Shell", "Xaml" ], "identity": "VijayAnand.FormsShell", - "groupIdentity": "VijayAnand.FormsTemplates.Shell", + "groupIdentity": "VijayAnand.FormsTemplates.Shell.Xaml", "description": "An item template for Xamarin.Forms ShellPage in XAML", "name": "Xamarin.Forms ShellPage", "shortName": "forms-shell", @@ -21,7 +22,8 @@ "path": "FormsShell.1.xaml" }, { - "path": "FormsShell.1.xaml.cs" + "path": "FormsShell.1.xaml.cs", + "condition": "(!XamlOnly)" } ], "tags": { @@ -34,6 +36,28 @@ "replaces": "MyApp.Namespace", "datatype": "text", "description": "namespace for the generated code" + }, + "xaml-only": { + "type": "parameter", + "datatype": "bool", + "default": "false", + "description": "If true, the output is generated without a C# code-behind file." + }, + "XamlOnly": { + "type": "computed", + "value": "(xaml-only)" + } + }, + "sources": [ + { + "modifiers": [ + { + "condition": "(XamlOnly)", + "exclude": [ + "FormsShell.1.xaml.cs" + ] + } + ] } - } + ] } diff --git a/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml b/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml index 35047f9..b5b56c4 100644 --- a/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml +++ b/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml @@ -1,8 +1,23 @@ - + + + + + + - \ No newline at end of file + diff --git a/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml.cs b/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml.cs index 3c23dcd..a35d548 100644 --- a/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml.cs +++ b/src/FormsTemplatesCLI/FormsShell/FormsShell.1.xaml.cs @@ -13,11 +13,9 @@ public FormsShell__1() // UnComment the below method to handle Shell Menu item click event // And ensure appropriate page definitions are available for it work as expected - /* - private async void OnMenuItemClicked(object sender, EventArgs e) - { - await Current.GoToAsync("//login"); - } - */ + //private async void OnMenuItemClicked(object sender, EventArgs e) + //{ + // await Current.GoToAsync("//login"); + //} } } diff --git a/src/FormsTemplatesCLI/FormsShellCS/.template.config/dotnetcli.host.json b/src/FormsTemplatesCLI/FormsShellCS/.template.config/dotnetcli.host.json new file mode 100644 index 0000000..8c438fd --- /dev/null +++ b/src/FormsTemplatesCLI/FormsShellCS/.template.config/dotnetcli.host.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json.schemastore.org/dotnetcli.host", + "symbolInfo": { + "namespace": { + "shortName": "na" + } + } +} diff --git a/src/FormsTemplatesCLI/FormsShellCS/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsShellCS/.template.config/ide.host.json new file mode 100644 index 0000000..348ae09 --- /dev/null +++ b/src/FormsTemplatesCLI/FormsShellCS/.template.config/ide.host.json @@ -0,0 +1,3 @@ +{ + "$schema": "http://json.schemastore.org/vs-2017.3.host" +} diff --git a/src/FormsTemplatesCLI/FormsShellCS/.template.config/template.json b/src/FormsTemplatesCLI/FormsShellCS/.template.config/template.json new file mode 100644 index 0000000..567664b --- /dev/null +++ b/src/FormsTemplatesCLI/FormsShellCS/.template.config/template.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://json.schemastore.org/template", + "author": "Vijay Anand E G", + "defaultName": "AppShell", + "classifications": [ + "Android", + "iOS", + "UWP", + "Windows", + "Xamarin.Forms", + "Shell", + "Code" + ], + "identity": "VijayAnand.FormsShellCS", + "groupIdentity": "VijayAnand.FormsTemplates.Shell.Code", + "description": "An item template for Xamarin.Forms ShellPage in C#", + "name": "Xamarin.Forms ShellPage (C#)", + "shortName": "forms-shell-cs", + "sourceName": "FormsShell.1", + "primaryOutputs": [ + { + "path": "FormsShell.1.cs" + } + ], + "tags": { + "language": "C#", + "type": "item" + }, + "symbols": { + "namespace": { + "type": "parameter", + "replaces": "MyApp.Namespace", + "datatype": "text", + "description": "namespace for the generated code" + } + } +} diff --git a/src/FormsTemplatesCLI/FormsShellCS/FormsShell.1.cs b/src/FormsTemplatesCLI/FormsShellCS/FormsShell.1.cs new file mode 100644 index 0000000..717f798 --- /dev/null +++ b/src/FormsTemplatesCLI/FormsShellCS/FormsShell.1.cs @@ -0,0 +1,49 @@ +using Xamarin.Forms; + +namespace MyApp.Namespace +{ + public partial class FormsShell__1 : Shell + { + public FormsShell__1() + { + // Flyout Items + //Items.Add(new FlyoutItem() + //{ + // Title = "", + // Items = + // { + // new ShellContent() + // { + // ContentTemplate = new DataTemplate(typeof(ContentPage)), + // Route = "", + // }, + // } + //}); + + // Menu Items + //Items.Add(new MenuItem() + //{ + // Text = "", + //}.Invoke(x => x.Clicked += OnMenuItemClicked)); + + //TabBar Items + //Items.Add(new TabBar() + //{ + // Title = "", + // Items = + // { + // new ShellContent() + // { + // ContentTemplate = new DataTemplate(typeof(ContentPage)), + // Route = "", + // }, + // } + //}); + } + + //private void OnMenuItemClicked(object sender, EventArgs e) + //{ + // + //} + } +} diff --git a/src/FormsTemplatesCLI/FormsView/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsView/.template.config/ide.host.json index 49c58be..348ae09 100644 --- a/src/FormsTemplatesCLI/FormsView/.template.config/ide.host.json +++ b/src/FormsTemplatesCLI/FormsView/.template.config/ide.host.json @@ -1,3 +1,3 @@ { "$schema": "http://json.schemastore.org/vs-2017.3.host" -} \ No newline at end of file +} diff --git a/src/FormsTemplatesCLI/FormsView/.template.config/template.json b/src/FormsTemplatesCLI/FormsView/.template.config/template.json index 507fd36..61ce294 100644 --- a/src/FormsTemplatesCLI/FormsView/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsView/.template.config/template.json @@ -8,9 +8,11 @@ "UWP", "Windows", "Xamarin.Forms", + "View", "Xaml" ], - "identity": "VijayAnand.FormsTemplates.View.Xaml", + "identity": "VijayAnand.FormsView", + "groupIdentity": "VijayAnand.FormsTemplates.View.Xaml", "description": "An item template for Xamarin.Forms ContentView in XAML", "name": "Xamarin.Forms ContentView", "shortName": "forms-view", @@ -20,7 +22,8 @@ "path": "FormsView.1.xaml" }, { - "path": "FormsView.1.xaml.cs" + "path": "FormsView.1.xaml.cs", + "condition": "(!XamlOnly)" } ], "tags": { @@ -33,6 +36,28 @@ "replaces": "MyApp.Namespace", "datatype": "text", "description": "namespace for the generated code" + }, + "xaml-only": { + "type": "parameter", + "datatype": "bool", + "default": "false", + "description": "If true, the output is generated without a C# code-behind file." + }, + "XamlOnly": { + "type": "computed", + "value": "(xaml-only)" + } + }, + "sources": [ + { + "modifiers": [ + { + "condition": "(XamlOnly)", + "exclude": [ + "FormsView.1.xaml.cs" + ] + } + ] } - } + ] } diff --git a/src/FormsTemplatesCLI/FormsView/FormsView.1.xaml b/src/FormsTemplatesCLI/FormsView/FormsView.1.xaml index f4ae3e3..1481594 100644 --- a/src/FormsTemplatesCLI/FormsView/FormsView.1.xaml +++ b/src/FormsTemplatesCLI/FormsView/FormsView.1.xaml @@ -1,14 +1,30 @@ - + + + + + + - - \ No newline at end of file + diff --git a/src/FormsTemplatesCLI/FormsViewCS/.template.config/ide.host.json b/src/FormsTemplatesCLI/FormsViewCS/.template.config/ide.host.json index 49c58be..348ae09 100644 --- a/src/FormsTemplatesCLI/FormsViewCS/.template.config/ide.host.json +++ b/src/FormsTemplatesCLI/FormsViewCS/.template.config/ide.host.json @@ -1,3 +1,3 @@ { "$schema": "http://json.schemastore.org/vs-2017.3.host" -} \ No newline at end of file +} diff --git a/src/FormsTemplatesCLI/FormsViewCS/.template.config/template.json b/src/FormsTemplatesCLI/FormsViewCS/.template.config/template.json index cdb99ab..389fefb 100644 --- a/src/FormsTemplatesCLI/FormsViewCS/.template.config/template.json +++ b/src/FormsTemplatesCLI/FormsViewCS/.template.config/template.json @@ -8,9 +8,11 @@ "UWP", "Windows", "Xamarin.Forms", + "View", "Code" ], - "identity": "VijayAnand.FormsTemplates.View.Code", + "identity": "VijayAnand.FormsViewCS", + "groupIdentity": "VijayAnand.FormsTemplates.View.Code", "description": "An item template for Xamarin.Forms ContentView in C#", "name": "Xamarin.Forms ContentView (C#)", "shortName": "forms-view-cs", diff --git a/src/FormsTemplatesCLI/FormsViewCS/FormsView.1.cs b/src/FormsTemplatesCLI/FormsViewCS/FormsView.1.cs index b80ec5a..49c0310 100644 --- a/src/FormsTemplatesCLI/FormsViewCS/FormsView.1.cs +++ b/src/FormsTemplatesCLI/FormsViewCS/FormsView.1.cs @@ -13,6 +13,7 @@ public FormsView__1() new Label() { Text = "Hello from Xamarin.Forms!!!", + TextColor = Color.Purple, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand } diff --git a/src/FormsTemplatesCLI/VijayAnand.FormsTemplates.csproj b/src/FormsTemplatesCLI/VijayAnand.FormsTemplates.csproj index bdc6bca..2001a58 100644 --- a/src/FormsTemplatesCLI/VijayAnand.FormsTemplates.csproj +++ b/src/FormsTemplatesCLI/VijayAnand.FormsTemplates.csproj @@ -1,3 +1,4 @@ + netstandard2.0 @@ -6,7 +7,7 @@ 1.0.0 Xamarin.Forms Templates Vijay Anand E G - Copyright © 2022 Vijay Anand E G + Copyright © 2022-2023 Vijay Anand E G Project and Item templates for developing Xamarin.Forms App that runs on iOS, Android, and Windows. MIT true @@ -26,10 +27,10 @@ true - + - \ No newline at end of file + diff --git a/src/FormsTemplatesCLI/overview.md b/src/FormsTemplatesCLI/overview.md index 5fb80e4..590f36f 100644 --- a/src/FormsTemplatesCLI/overview.md +++ b/src/FormsTemplatesCLI/overview.md @@ -2,38 +2,59 @@ Project template for Xamarin.Forms Class Library and is named as `formsclasslib` -Item templates for ContentPage, ContentView, ShellPage, and ResourceDictionary in XAML and named as `forms-page`, `forms-view`, `forms-shell`, and `forms-resdict` respectively. - -All of these templates currently target Xamarin.Forms 5.0 Service Release 9 (ver. 5.0.0.2337). +Class library project template take the below optional parameters to override its target framework and to include the officially supported `Xamarin.CommunityToolkit`, `Xamarin.CommunityToolkit.Markup`, `Xamarin.Essentials`, `CommunityToolkit.Mvvm` (aka Microsoft MVVM Toolkit) or all NuGet packages: + +* `-f` | `--framework` - Default value is `netstandard2.0` +* `-it` | `--include-toolkit` - Default value is `false` +* `-im` | `--include-markup` - Default value is `false` +* `-ie` | `--include-essentials` - Default value is `false` +* `-imt` | `--include-mvvm-toolkit` - Default value is `false` + +*Note: The NuGet package version being added out-of-the-box are v2.0.x for the Xamarin Toolkit packages, v1.7.x for the Xamarin.Essentials package, and v8.1.0 for the MVVM Toolkit package.* + +|Item|Template Name| +|:---:|:---:| +|ContentPage (XAML)|forms-page| +|ContentPage (C#)|forms-page-cs| +|ContentView (XAML)|forms-view| +|ContentView (C#)|forms-view-cs| +|ResourceDictionary (XAML)|forms-resdict| +|ShellPage (XAML)|forms-shell| +|ShellPage (C#)|forms-shell-cs| To install the template NuGet package, use the below .NET CLI command: ```shell -dotnet new --install VijayAnand.FormsTemplates +dotnet new install VijayAnand.FormsTemplates ``` If you've already installed this package, then it can be updated to the latest version with the below command: ```shell -dotnet new --update-check +dotnet new update --check-only ``` ```shell -dotnet new --update-apply +dotnet new update ``` Use the below .NET CLI command to create the project, pages, and views out these templates: -```shell -dotnet new formsclasslib -n MyApp.Core -``` +Here, `-n` denotes the name of the project/page/view that is to be created (for pages/views, don't need to suffix it with `.xaml` / `.cs`, it will be added automatically) (Can also be specified as `--name` in the expanded form). -Class library project templates take the below optional parameters to include the officially supported CommunityToolkit and Essentials NuGet packages: +*Note: If name parameter is not provided, the .NET CLI template engine will take the current folder name in the context as its name.* + +And `-na` denotes the namespace under which the file is to be created (Can also be specified as `--namespace` in the expanded form). -* `-it` | `--include-toolkit` - Default value is false -* `-im` | `--include-markup` - Default value is false -* `-ie` | `--include-essentials` - Default value is false -* `-imt` | `--include-mvvm-toolkit` - Default value is false +*While working with .NET 7 or higher SDK, the namespace parameter in short notation needs to be passed as `-p:na` (i.e., it needs to be prefixed with `-p:`).* +```shell +dotnet new formsclasslib -n MyApp.Core +``` +Library target framework override: +```shell +dotnet new formsclasslib -n MyApp.Core -f netstandard2.1 +``` +Option to include NuGet packages: ```shell dotnet new formsclasslib -n MyApp.UI -it -im -imt -ie ``` @@ -58,20 +79,18 @@ Shell: ```shell dotnet new forms-shell -n AppShell -na MyApp ``` +```shell +dotnet new forms-shell-cs -n MobileShell -na MyApp +``` Resource Dictionary: With C# code-behind file: ```shell -dotnet new forms-resdict -n DarkTheme -na MyApp.Themes +dotnet new forms-resdict -n DefaultTheme -na MyApp.Themes ``` -Without C# code-behind file - Xaml Only (Option can be `-xo` or `--xaml-only`): +Without C# code-behind file - Xaml only (Option can be specified as `-xo` or `--xaml-only`): ```shell dotnet new forms-resdict -n DarkTheme -na MyApp.Themes -xo ``` -Here `-n` denotes the name of the project/page/view that is to be created (for pages/views, don't need to suffix it with .xaml, it will be added automatically) (Can also be specified as `--name`). - -*Note: If name parameter is not provided, the .NET CLI template engine will take the current folder name in the context as its name.* - -And `-na` denotes the namespace under which the file is to be created (Can also be specified as `--namespace`). diff --git a/src/FormsTemplatesCLI/release-notes.txt b/src/FormsTemplatesCLI/release-notes.txt index 55329da..b833c0a 100644 --- a/src/FormsTemplatesCLI/release-notes.txt +++ b/src/FormsTemplatesCLI/release-notes.txt @@ -1,4 +1,12 @@ -What's new in ver. 1.4.2: +What's new in ver. 1.4.3: +------------------------- +1. Package versions have been made dynamic to pull the latest stable version. + +2. Added a new item template for Shell definition in C# + +dotnet new forms-shell-cs -n AppShell -na MyLib + +v1.4.2: Little housekeeping to improve the reliability of the templates.