-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET]
dotnet new
project and item templates
Context: https://docs.microsoft.com/dotnet/core/tutorials/cli-templates-create-template-pack Context: https://github.com/dotnet/templating/wiki This implements basic Android templates that are contained in a `Microsoft.Android.Templates.nupkg` file. This is included in the .NET 6 Workload installers and installed to: C:\Program Files\dotnet\templates /usr/local/share/dotnet/templates A `postinstall` action in the installers runs `dotnet new --install`, as there does not currently appear to be any extra template functionality for [.NET Workloads][0]. Some example project templates: dotnet new android --output MyAndroidApp --packageName com.mycompany.myandroidapp dotnet new androidlib --output MyAndroidLibrary dotnet new android-bindinglib --output MyJavaBinding And item templates: dotnet new android-activity --name LoginActivity --namespace MyAndroidApp dotnet new android-layout --name MyLayout --output Resources/layout Note that the `android-bindinglib` template is not a special project type. It has additional help files for writing bindings as we have in the current Xamarin.Android templates. I also updated the `XASdkTests` to `dotnet new` each template and `dotnet build` the resulting output. [0]: https://github.com/dotnet/designs/blob/bc5d2c1664299a4a640e3185e87a6b99426b6b89/accepted/2020/workloads/workloads.md
- Loading branch information
1 parent
113ffcc
commit 8710b25
Showing
48 changed files
with
538 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
INSTALLATION_ROOT=/usr/local/share/dotnet | ||
NUPKG=$(find $INSTALLATION_ROOT/templates -name 'Microsoft.Android.Templates.*.nupkg') | ||
|
||
$INSTALLATION_ROOT/dotnet new --install $NUPKG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project> | ||
<Import Project="..\..\build-tools\scripts\XAVersionInfo.targets" /> | ||
<PropertyGroup> | ||
<BeforePack> | ||
_GetDefaultPackageVersion; | ||
$(BeforePack); | ||
</BeforePack> | ||
</PropertyGroup> | ||
<Target Name="_GetDefaultPackageVersion" | ||
DependsOnTargets="GetXAVersionInfo" > | ||
<PropertyGroup> | ||
<PackageVersion>$(AndroidPackVersionLong)+sha.$(XAVersionHash)</PackageVersion> | ||
</PropertyGroup> | ||
</Target> | ||
</Project> |
25 changes: 25 additions & 0 deletions
25
src/templates/android-activity/.template.config/template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": [ "Android" ], | ||
"name": "Android Activity template", | ||
"description": "An Android Activity class", | ||
"tags": { | ||
"language": "C#", | ||
"type": "item" | ||
}, | ||
"identity": "Microsoft.Android.AndroidActivity", | ||
"shortName": "android-activity", | ||
"sourceName": "Activity1", | ||
"primaryOutputs": [ | ||
{ "path": "Activity1.cs" } | ||
], | ||
"defaultName": "Activity1", | ||
"symbols": { | ||
"namespace": { | ||
"description": "namespace for the generated code", | ||
"replaces": "AndroidApp1", | ||
"type": "parameter" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Android.App; | ||
using Android.OS; | ||
using Android.Runtime; | ||
using Android.Widget; | ||
|
||
namespace AndroidApp1 | ||
{ | ||
[Activity(Label = "@string/app_name", MainLauncher = true)] | ||
public class Activity1 : Activity | ||
{ | ||
protected override void OnCreate(Bundle savedInstanceState) | ||
{ | ||
base.OnCreate(savedInstanceState); | ||
|
||
// Create your application here | ||
} | ||
} | ||
} |
Oops, something went wrong.