Skip to content

Commit

Permalink
feat: Add support for Prism library dotnet new template
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 26, 2020
1 parent ff5171b commit 18cccbb
Show file tree
Hide file tree
Showing 92 changed files with 3,303 additions and 4 deletions.
58 changes: 58 additions & 0 deletions doc/articles/get-started-dotnet-new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Getting started with dotnet new templates

The Uno Platform provides a set of command line templates to create cross platform applications.

To install the templates, type the following:
```
dotnet new -i Uno.ProjectTemplates.Dotnet::2.2
```

If you need to determine the parameters available for a template use `dotnet new [templatename] -h`.

## Uno Platform Blank Application

This template can be used to create a blank cross-platform application for iOS, Android, WebAssembly and macOS.

A basic example:
```
dotnet new unoapp -o MyApp
```

A more advanced example which will not generate the android and macOS heads:

```
dotnet new unoapp -o MyApp -android=false -macos=false
```

## Uno Platform Blank Prism Application

This template is specializing in the creation of a [Prism Library](https://github.com/PrismLibrary/Prism) enabled blank application.

A basic example:
```
dotnet new unoapp-prism -o MyApp
```

A more advanced example which will not generate the android and macOS heads:

```
dotnet new unoapp -o MyApp -android=false -macos=false
```

## Uno Platform WebAssembly support for Xamarin Forms

This template is built to enhance an existing Xamarin.Forms application with the [Uno Platform WebAssembly support](https://github.com/unoplatform/Uno.Xamarin.Forms.Platform).

To use it:

1. Create a Xamarin.Forms project
1. Check **Place project and solution in the same directory**
1. Check **Windows (UWP)**
1. Using a **VS Developer Command Prompt**, navigate to the folder containing the solution
```
dotnet new wasmxfhead
```
1. Open or Reload the solution in Visual Studio
1. Set the Wasm project as the startup project
1. Open the **Nuget Package manager** for the Wasm project and update the `Uno.Xamarin.Forms.Platform` project to the latest **stable** package
1. Run the app using **Ctrl+F5** (without the Visual Studio debugger), and you’re good to go!
5 changes: 4 additions & 1 deletion src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ override void OnLaunched(LaunchActivatedEventArgs e)
#endif
var sw = Stopwatch.StartNew();
var n = Windows.UI.Xaml.Window.Current.Dispatcher.RunIdleAsync(
_ => Console.WriteLine("Done loading " + sw.Elapsed));
_ =>
{
Console.WriteLine("Done loading " + sw.Elapsed);
});

#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<IsTool>true</IsTool>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageType>Template</PackageType>
<ContentTargetFolders>content</ContentTargetFolders>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -16,6 +17,7 @@
<Description></Description>
<Copyright>Copyright (C) 2015-2019 nventive inc. - all rights reserved</Copyright>
<GeneratePackageOnBuild Condition="'$(Configuration)'=='Release'">true</GeneratePackageOnBuild>
<PackageTags>dotnet-new;templates;uno-platform;webassembly;ios;android;uwp;winui</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand All @@ -24,6 +26,10 @@

<ItemGroup>
<Compile Remove="content/**/*.cs" />
<Compile Remove="content\uno-prism-app\UnoQuickStart.macOS\**" />
<EmbeddedResource Remove="content\uno-prism-app\UnoQuickStart.macOS\**" />
<None Remove="content\uno-prism-app\UnoQuickStart.macOS\**" />
<UpToDateCheckInput Remove="content\uno-prism-app\UnoQuickStart.macOS\**" />
<Content Include="content/xamarinforms-wasm/nuget.config">
<Pack>true</Pack>
<PackagePath>content/xamarinforms-wasm</PackagePath>
Expand All @@ -48,6 +54,14 @@
<PackagePath>content\unoapp</PackagePath>
<Pack>true</Pack>
</Content>
<Content Include="content\unoapp\UnoQuickStart\**">
<PackagePath>content\unoapp</PackagePath>
<Pack>true</Pack>
</Content>
<Content Include="content\unoapp-prism\**">
<PackagePath>content\unoapp-prism</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>

<Target Name="CopyTemplate" BeforeTargets="Build">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"WebAssembly": {
"longName": "webassembly",
"shortName": "wasm"
},
"UWP": {
"longName": "uwp",
"shortName": "uwp"
},
"iOS": {
"longName": "ios",
"shortName": "ios"
},
"Android": {
"longName": "android",
"shortName": "android"
},
"macOS": {
"longName": "macos",
"shortName": "macos"
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Uno Platform",
"classifications": [ "Prism", "Xamarin", "Uno Platform", "WebAssembly", "iOS", "Android", "WinUI", "UWP" ],
"name": "Prism Cross-Platform App (Uno Platform)",
"identity": "Uno.Platform.Prism.CSharp", // Unique name for this template
"groupIdentity": "Uno.Platform.Prism",
"shortName": "unoapp-prism", // Short name that can be used on the cli
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "BlankApp",
"preferNameDirectory": true,
"guids": [
"4C26868E-5E7C-458D-82E3-040509D0C71F", // Solution file (SLN)
"99E19497-29A6-4B77-B773-BEC55F9B55DC", // .NET Standard Library
"8D9F8CF0-E178-402D-8D40-A88B7B5F3D42", // Android
"91D74A40-E440-42AD-B51F-C2D641C49384", // iOS
"B445DF73-AC9E-4276-9FBA-7CB5AD5D2518",
"3EA9E612-E717-4E55-9034-DE653429FEFD", // WPF
"3EA9E612-E717-4E55-9034-C415CD62AF9A", // UWP
"2B1FDFB6-C93C-4CA1-A6AB-528C4B3654B9" // UWP
],
"symbols": {
"guid1": {
"type": "generated",
"generator": "guid",
"replaces": "$guid1$",
"parameters": {
"format": "N"
}
},
"guid2": {
"type": "generated",
"generator": "guid",
"replaces": "$guid2$",
"parameters": {
"format": "N"
}
},
"windowsPublisherName": {
"type": "parameter",
"datatype": "text",
"replaces": "$XmlEscapedPublisherDistinguishedName$",
"description": "Provides the value to use for the Windows head publisher",
"defaultValue": "O=MyCompany"
},
"WebAssembly": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "true",
"description": "Enables the WebAssembly platform support project"
},
"UWP": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "true",
"description": "Enables the Windows platform support project"
},
"iOS": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "true",
"description": "Enables the iOS platform support project"
},
"Android": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "true",
"description": "Enables the Android platform support project"
},
"macOS": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "true",
"description": "Enables the macOS platform support project"
},
"vscodeWasm": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "false",
"description": "Adds the Visual Studio Code Debugging support files for WebAssembly"
},
"Container": {
"type": "parameter",
"dataType": "choice",
"defaultValue": "DryIoc",
"choices": [
{
"choice": "DryIoc",
"description": "Uses DryIoc as the Dependency Injection Container"
},
{
"choice": "Unity",
"description": "Uses Unity as the Dependency Injection Container"
}
],
"description": "The Dependency Injection Container to use"
},
"DryIocContainer": {
"type": "computed",
"value": "(Container == \"DryIoc\")"
},
"UnityContainer": {
"type": "computed",
"value": "(Container == \"Unity\")"
}
},
"primaryOutputs": [
{
"path": "BlankApp.Shared\\BlankApp.Shared.shproj"
},
{
"condition": "Android",
"path": "BlankApp.Droid\\BlankApp.Droid.csproj"
},
{
"condition": "iOS",
"path": "BlankApp.iOS\\BlankApp.iOS.csproj"
},
{
"condition": "UWP",
"path": "BlankApp.UWP\\BlankApp.Uwp.csproj"
},
{
"condition": "Wasm",
"path": "BlankApp.Wasm\\BlankApp.Wasm.csproj"
},
{
"condition": "macOS",
"path": "BlankApp.macOS\\BlankApp.macOS.csproj"
}
],
"sources": [
{
"modifiers": [
{
"condition": "(!Android)",
"exclude": [ "BlankApp/BlankApp.Android/**/*" ]
},
{
"condition": "(!iOS)",
"exclude": [ "BlankApp/BlankApp.iOS/**/*" ]
},
{
"condition": "(!UWP)",
"exclude": [ "BlankApp/BlankApp.UWP/**/*" ]
},
{
"condition": "(!WebAsembly)",
"exclude": [ "BlankApp/BlankApp.Wasm/**/*" ]
},
{
"condition": "(!macOS)",
"exclude": [ "BlankApp/BlankApp.macOS/**/*" ]
},
{
"condition": "(!vscodeWasm)",
"exclude": [
".vscode/**/*"
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (Uno Platform App)",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": [ "run" ],
"cwd": "${workspaceFolder}/UnoQuickStart.Wasm",
"env": {
}
},
{
"name": ".NET Core Debug Uno Platform WebAssembly in Chrome",
"type": "pwa-chrome",
"request": "launch",
"timeout": 30000,
// If you have changed the default port / launch URL make sure to update the expectation below
"url": "http://localhost:5000",
"webRoot": "${workspaceFolder}/UnoQuickStart.Wasm",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/UnoQuickStart.Wasm/UnoQuickStart.Wasm.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/UnoQuickStart.Wasm/UnoQuickStart.Wasm.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"options": { "cwd": "${workspaceFolder}/UnoQuickStart.Wasm" },
"isBackground": true,
"args": [
"watch",
"run",
"${workspaceFolder}/UnoQuickStart.Wasm/UnoQuickStart.Wasm.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
Loading

0 comments on commit 18cccbb

Please sign in to comment.