Skip to content

Commit

Permalink
Merge pull request #3 from egvijayanand/working
Browse files Browse the repository at this point in the history
VS extension for Xamarin.Forms templates
  • Loading branch information
egvijayanand committed Feb 28, 2022
2 parents 6591391 + a7d88ff commit 101ddc5
Show file tree
Hide file tree
Showing 17 changed files with 337 additions and 5 deletions.
66 changes: 61 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
### CLI Project and Item Templates for developing Xamarin.Forms App that runs on iOS, Android, and Windows
### Project and Item Templates for building native apps for iOS, Android, UWP, macOS, Tizen from a single, shared C# codebase.

[![VijayAnand.FormsTemplates - NuGet Package](https://badgen.net/nuget/v/VijayAnand.FormsTemplates/)](https://www.nuget.org/packages/VijayAnand.FormsTemplates/)
#### Available to install from

Project template for Xamarin.Forms Class Library and is named as `formsclasslib`
|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)|

#### Access within Visual Studio IDE

Installation:

![Install from VS Marketplace](images/xamarin-forms-vs-extension.png)

Project Template Listing:

![Xamarin.Forms Class Library Project Template](images/xamarin-forms-class-library.png)

Project Options:

![Xamarin.Forms Class Library - Project Options](images/xamarin-forms-class-library-options.png)

Item templates for ContentPage, ContentView, and ShellPage in XAML and named as `forms-page`, `forms-view`, and `forms-shell` respectively.
Item Templates:

Project template currently target Xamarin.Forms 5.0 Service Release 9 (ver. 5.0.0.2337).
![Xamarin.Forms - Item Templates](images/xamarin-forms-item-templates.png)

#### Access via CLI

To install the template NuGet package, use the below .NET CLI command:

Expand All @@ -18,22 +36,60 @@ If you've already installed this package, then it can be updated to the latest v

```shell
dotnet new --update-check
```
```shell
dotnet new --update-apply
```
Project template for Xamarin.Forms Class Library and is named as `formsclasslib`

And it currently targets Xamarin.Forms 5.0 Service Release 9 (ver. 5.0.0.2337).

Item templates for `ContentPage`, `ContentView`, `ShellPage`, and `ResourceDictionary` in XAML and named as `forms-page`, `forms-view`, `forms-shell`, and `forms-resdict` respectively.

Use the below .NET CLI command to create the project, pages, and views out these templates:

```shell
dotnet new formsclasslib -n MyApp.Core
```

Class library project templates take the below optional parameters to include the officially supported Xamarin.CommunityToolkit, Xamarin.CommunityToolkit.Markup or both NuGet packages:

* `-it` | `--include-toolkit` - Default value is `false`
* `-im` | `--include-markup` - Default value is `false`

Note: `v2.0.0` is the NuGet package version being added out-of-the-box.

```shell
dotnet new formsclasslib -n MyApp.UI -it -im
```

Page:
```shell
dotnet new forms-page -n LoginPage -na MyApp.Views
```

View:
```shell
dotnet new forms-view -n CardView -na MyApp.Views
```

Shell:
```shell
dotnet new forms-shell -n AppShell -na MyApp
```

Resource Dictionary:

With C# code-behind file:
```shell
dotnet new forms-resdict -n DarkTheme -na MyApp.Themes
```

Without C# code-behind file - Xaml Only (Option can be `-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.*
Expand Down
Binary file added images/xamarin-forms-class-library-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/xamarin-forms-class-library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/xamarin-forms-item-templates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/xamarin-forms-vs-extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/Extensions/XFormsTemplates/XFormsTemplates.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32210.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XFormsTemplates", "XFormsTemplates\XFormsTemplates.csproj", "{FBA856CD-61CF-47A3-8F97-756843779ED6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Debug|x86.ActiveCfg = Debug|x86
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Debug|x86.Build.0 = Debug|x86
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Release|Any CPU.Build.0 = Release|Any CPU
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Release|x86.ActiveCfg = Release|x86
{FBA856CD-61CF-47A3-8F97-756843779ED6}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F22699EA-F23E-4541-BC95-067F10E4AD7D}
EndGlobalSection
EndGlobal
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[$RootKey$\TemplateEngine\Templates\VijayAnand.FormsTemplates\1.1.0]
"InstalledPath"="$PackageFolder$\ProjectTemplates"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Reflection;
using System.Runtime.InteropServices;
using VijayAnand.XFormsTemplates;

[assembly: AssemblyTitle(Vsix.Name)]
[assembly: AssemblyDescription(Vsix.Description)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(Vsix.Author)]
[assembly: AssemblyProduct(Vsix.Name)]
[assembly: AssemblyCopyright(Vsix.Author)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: AssemblyVersion(Vsix.Version)]
[assembly: AssemblyFileVersion(Vsix.Version)]

namespace System.Runtime.CompilerServices
{
public class IsExternalInit { }
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions src/Extensions/XFormsTemplates/XFormsTemplates/XFormsTemplates.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{FBA856CD-61CF-47A3-8F97-756843779ED6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VijayAnand.XFormsTemplates</RootNamespace>
<AssemblyName>VijayAnand.XFormsTemplates</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<UseCodebase>true</UseCodebase>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
<IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment>
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
<StartAction>Program</StartAction>
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="source.extension.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>source.extension.vsixmanifest</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="ItemTemplates\FormsResDict.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>ItemTemplates\Xamarin.Forms</VSIXSubPath>
</Content>
<Content Include="ItemTemplates\FormsResDictXaml.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>ItemTemplates\Xamarin.Forms</VSIXSubPath>
</Content>
<Content Include="ItemTemplates\FormsShell.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>ItemTemplates\Xamarin.Forms</VSIXSubPath>
</Content>
<None Include="Assets\VijayAnand.FormsTemplates.1.1.0.nupkg"/>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
<Generator>VsixManifestGenerator</Generator>
<LastGenOutput>source.extension.cs</LastGenOutput>
</None>
<Content Include="license.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="NuGetTemplates.pkgdef">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="release-notes.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Resources\Icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Design"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Community.VisualStudio.Toolkit.17" Version="17.0.394" ExcludeAssets="Runtime">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.1.4054">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup/>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''"/>
<!-- For distributing NuGet package loaded with CLI Templates -->
<Target Name="PreCreateVsixContainer" BeforeTargets="GetVsixSourceItems">
<ItemGroup>
<!-- Ensure that the path below is correct -->
<_TemplatePackage Include="Assets\*.nupkg"/>
</ItemGroup>
<Error Text="No template files found." Condition="@(_TemplatePackage-&gt;Count()) == 0"/>
<Message Text="Template nuget packages found: @(_TemplatePackage)" Importance="low"/>
<!-- Don't modify the following, the pkgdef file uses the path below -->
<ItemGroup>
<VSIXSourceItem Include="@(_TemplatePackage)">
<VSIXSubPath>ProjectTemplates\</VSIXSubPath>
</VSIXSourceItem>
</ItemGroup>
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
21 changes: 21 additions & 0 deletions src/Extensions/XFormsTemplates/XFormsTemplates/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Vijay Anand E G

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions src/Extensions/XFormsTemplates/XFormsTemplates/release-notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
What's new in ver. 1.0.0.0:

Initial release of Xamarin.Forms Project and Item Templates for building native apps for iOS, Android, UWP, macOS, Tizen from a single, shared C# codebase published as VS extension (VSIX).

This VS extension is loaded with a Project template for creating a Xamarin.Forms Class Library.

This project template has the provision to optionally include the officially supported CommunityToolkit NuGet packages.

And Item templates for (available in the Xamarin.Forms section):

1. Shell Page
2. Resource Dictionary
3. Resource Dictionary (XAML only)
18 changes: 18 additions & 0 deletions src/Extensions/XFormsTemplates/XFormsTemplates/source.extension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by VSIX Synchronizer
// </auto-generated>
// ------------------------------------------------------------------------------
namespace VijayAnand.XFormsTemplates
{
internal sealed partial class Vsix
{
public const string Id = "XFormsTemplates.2924dcc2-7ffd-4b48-8828-c830a2fab6e0";
public const string Name = "Xamarin.Forms Project and Item Templates";
public const string Description = @"Xamarin.Forms Project and Item Templates for building native apps for iOS, Android, UWP, macOS, Tizen from a single, shared C# codebase.";
public const string Language = "en-US";
public const string Version = "1.0.0.0";
public const string Author = "Vijay Anand E G";
public const string Tags = "Xamarin.Forms, Mobile, iOS, Android, UWP, Desktop, Windows, Templates, Shell, Library, Visual Studio, Resource Dictionary, Xamarin, macOS, Tizen";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="XFormsTemplates.2924dcc2-7ffd-4b48-8828-c830a2fab6e0" Version="1.0.0.0" Language="en-US" Publisher="Vijay Anand E G" />
<DisplayName>Xamarin.Forms Project and Item Templates</DisplayName>
<Description xml:space="preserve">Xamarin.Forms Project and Item Templates for building native apps for iOS, Android, UWP, macOS, Tizen from a single, shared C# codebase.</Description>
<MoreInfo>https://egvijayanand.in/</MoreInfo>
<License>license.txt</License>
<GettingStartedGuide>https://github.com/egvijayanand/xamarin-forms-templates</GettingStartedGuide>
<ReleaseNotes>release-notes.txt</ReleaseNotes>
<Icon>Resources\Icon.png</Icon>
<PreviewImage>Resources\Icon.png</PreviewImage>
<Tags>Xamarin.Forms, Mobile, iOS, Android, UWP, Desktop, Windows, Templates, Shell, Library, Visual Studio, Resource Dictionary, Xamarin, macOS, Tizen</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
<InstallationTarget Version="[17.0,18.0)" Id="Microsoft.VisualStudio.Pro">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
<InstallationTarget Version="[17.0,18.0)" Id="Microsoft.VisualStudio.Enterprise">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,)" DisplayName="Visual Studio core editor" />
<Prerequisite Id="Component.Xamarin" Version="[17.0,18.0)" DisplayName="Xamarin" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.ItemTemplate" d:Source="File" Path="ItemTemplates" TargetVersion="[17.0,18.0)" d:TargetPath="ItemTemplates\FormsResDict.zip" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" d:Source="File" Path="ItemTemplates" TargetVersion="[17.0,18.0)" d:TargetPath="ItemTemplates\FormsResDictXaml.zip" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" d:Source="File" Path="ItemTemplates" TargetVersion="[17.0,18.0)" d:TargetPath="ItemTemplates\FormsShell.zip" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="File" Path="NuGetTemplates.pkgdef" />
</Assets>
</PackageManifest>

0 comments on commit 101ddc5

Please sign in to comment.