Skip to content

Commit

Permalink
Merge pull request #101 from egvijayanand/working
Browse files Browse the repository at this point in the history
Updated version of MauiTemplates CLI package
  • Loading branch information
egvijayanand authored Feb 6, 2023
2 parents ceb959b + 532eeff commit 038684b
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 12 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ ContentView | maui-view | Item
ContentView (C#) | maui-view-cs | Item
ResourceDictionary | maui-resdict | Item
ShellPage | maui-shell | Item
Partial Class | class | Item

![All-in-One .NET MAUI App Project Template](images/dotnetmaui-all-in-one-project-template-pinned.png)

Expand Down Expand Up @@ -371,6 +372,11 @@ Resource Dictionary:
dotnet new maui-resdict -n LightTheme -na MyApp.Themes
```

Partial Class:
```shell
dotnet new class -n BaseViewModel
```

With parameter names expanded:

.NET MAUI App:
Expand Down Expand Up @@ -429,6 +435,11 @@ Resource Dictionary:
```shell
dotnet new maui-resdict --name LightTheme --namespace MyApp.Themes
```

Partial Class:
```shell
dotnet new class --name BaseViewModel
```
<!--
### For VS2019 users:
Expand Down
2 changes: 1 addition & 1 deletion src/MauiTemplatesCLI/MauiAppX/MauiApp.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<PackageReference Include="CommunityToolkit.Maui" Version="4.0.0"/>
<!--#endif-->
<!--#if (AddMarkupPackage)-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="2.1.0"/>
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="3.0.0"/>
<!--#endif-->
<!--#if (AddMediaPackage)-->
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="1.0.1"/>
Expand Down
2 changes: 1 addition & 1 deletion src/MauiTemplatesCLI/MauiClassLib/MauiClassLib.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PackageReference Include="CommunityToolkit.Maui" Version="4.0.0"/>
<!--#endif-->
<!--#if (AddMarkupPackage)-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="2.1.0"/>
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="3.0.0"/>
<!--#endif-->
<!--#else-->
<!--#if (AddToolkitPackage)-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"namespace": {
"shortName": "na"
}
}
}
3 changes: 3 additions & 0 deletions src/MauiTemplatesCLI/MyClass/.template.config/ide.host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "http://json.schemastore.org/vs-2017.3.host"
}
43 changes: 43 additions & 0 deletions src/MauiTemplatesCLI/MyClass/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "https://json.schemastore.org/template",
"author": "Vijay Anand E G",
"defaultName": "Class1",
"classifications": [
"Code"
],
"identity": "VijayAnand.MyClass",
"groupIdentity": "VijayAnand.MauiTemplates.Class.Code",
"description": "An item template for Partial Class in C#",
"name": "Partial Class",
"shortName": "class",
"sourceName": "MyClass.1",
"primaryOutputs": [
{
"path": "MyClass.1.cs"
}
],
"tags": {
"language": "C#",
"type": "item"
},
"symbols": {
"namespace": {
"type": "bind",
"binding": "msbuild:RootNamespace",
"replaces": "MyApp.Namespace",
"defaultValue": "MyApp.Namespace"
}
},
"constraints": {
"dotnet7-sts": {
"type": "sdk-version",
"args": [
"[7.0,)"
]
},
"csharp-only": {
"type": "project-capability",
"args": "CSharp"
}
}
}
10 changes: 10 additions & 0 deletions src/MauiTemplatesCLI/MyClass/MyClass.1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MyApp.Namespace
{
public partial class MyClass__1
{
public MyClass__1()
{

}
}
}
2 changes: 1 addition & 1 deletion src/MauiTemplatesCLI/PackageVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<!--#endif-->
<!--#if (AddMauiMarkup)-->
<!--#if (Net7)-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="2.1.0" />
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="3.0.0" />
<!--#else-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="1.2.1" />
<!--#endif-->
Expand Down
2 changes: 1 addition & 1 deletion src/MauiTemplatesCLI/VijayAnand.MauiTemplates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>
<ItemGroup>
<Content Include="MauiPage\**\*;MauiPageCS\**\*;MauiView\**\*;MauiViewCS\**\*;MauiShell\**\*;MauiClassLib\**\*;MauiAppX\**\*;MauiResDict\**\*;SharedClassLib\**\*"
<Content Include="MauiPage\**\*;MauiPageCS\**\*;MauiView\**\*;MauiViewCS\**\*;MauiShell\**\*;MauiClassLib\**\*;MauiAppX\**\*;MauiResDict\**\*;SharedClassLib\**\*;MyClass\**\*"
Exclude="**\bin\**;**\obj\**"/>
<Compile Remove="**\*"/>
<None Include="overview.md" Pack="true" PackagePath="\" />
Expand Down
24 changes: 18 additions & 6 deletions src/MauiTemplatesCLI/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Item templates for the following:
|ContentView (C#)|maui-view-cs|
|ResourceDictionary (XAML)|maui-resdict|
|Shell (XAML)|maui-shell|
|Partial Class (C#)|class|

All of these templates currently target `.NET MAUI on .NET 7 GA`, stable release as of Nov 2022.
All of these templates currently target `.NET MAUI on .NET 6/7 GA and its Service Releases`.

Install the template package from NuGet with the below command.

Expand Down Expand Up @@ -85,12 +86,13 @@ The target for the Windows platform can be either `Package` (MSIX) or `Unpackage

* `-wu` | `--windows-unpackaged` - Default is `false`

While targeting `.NET 7`, an option to add and configure `Microsoft.Maui.Controls.Foldable`, `Microsoft.Maui.Controls.Maps`, or both NuGet packages.
While targeting `.NET 7`, an option to add and configure `CommunityToolkit.Maui.MediaElement`, `Microsoft.Maui.Controls.Foldable`, `Microsoft.Maui.Controls.Maps`, or all NuGet packages.

* `-ime` | `--include-media-element` - Default is `false`
* `-if` | `--include-foldable` - Default is `false`
* `-inm` | `--include-maps` - Default is `false`

*Note: If the project target `.NET 6`, selecting the Foldable/Maps option will NOT have any impact.*
*Note: If the project target `.NET 6`, selecting the MediaElement/Foldable/Maps option will NOT have any impact.*

##### Conditional Compilation

Expand Down Expand Up @@ -163,7 +165,7 @@ Can take any one of the following values, with default value set to `Plain`:

* `-tp` | `--target-platform`

Can take any one of the following values, with default value set to `All`:
Can take a combination of the following values, with default value set to `All`:

|Parameter Value|Description|
|:---:|:---|
Expand Down Expand Up @@ -235,7 +237,7 @@ dotnet new mauiapp -n MyApp -dp Hybrid
```
Option to include NuGet packages:
```shell
dotnet new mauiapp -n MyApp -dp Shell -it -im -imt -inm -if
dotnet new mauiapp -n MyApp -dp Shell -it -im -imt -ime -inm -if
```
Option to configure conditional compilation:
```shell
Expand Down Expand Up @@ -290,6 +292,11 @@ Resource Dictionary:
dotnet new maui-resdict -n LightTheme -na MyApp.Themes
```

Partial Class:
```shell
dotnet new class -n BaseViewModel
```

With parameter names expanded:

.NET MAUI App:
Expand All @@ -298,7 +305,7 @@ dotnet new mauiapp --name MyApp --design-pattern Hybrid
```
Option to include NuGet packages:
```shell
dotnet new mauiapp --name MyApp --design-pattern Shell --include-toolkit --include-markup --include-mvvm-toolkit --include-maps --include-foldable
dotnet new mauiapp --name MyApp --design-pattern Shell --include-toolkit --include-markup --include-mvvm-toolkit --include-media-element --include-maps --include-foldable
```
```shell
dotnet new mauiapp -n MyApp --design-pattern Shell --conditional-compilation
Expand Down Expand Up @@ -348,3 +355,8 @@ Resource Dictionary:
```shell
dotnet new maui-resdict --name LightTheme --namespace MyApp.Themes
```

Partial Class:
```shell
dotnet new class --name BaseViewModel
```
18 changes: 17 additions & 1 deletion src/MauiTemplatesCLI/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
What's new in ver. 2.3.1:
What's new in ver. 2.4.0:
-------------------------
1. CommunityToolkit.Maui.Markup NuGet package bumped to v3.0.0 that supports TypedBindings

2. Introduced a new item template for creating a C# class (partial) from CLI

dotnet new class -n BaseViewModel

Note:

Auto binding the project's RootNamespace as the namespace for newly created class type is supported only on .NET 7 SDK or later.

While running on earlier SDK versions, it has to be manually modified.

And due to the limitation in the templating engine, only the RootNamespace would get added, need to manually adjust for sub-folders, if any.

v2.3.1:

CommunityToolkit.Maui.MediaElement NuGet package bumped to v1.0.1 with the explicit WindowsAppSDK reference removed.

v2.3.0:
Expand Down

0 comments on commit 038684b

Please sign in to comment.