Skip to content

Commit

Permalink
Feat: Support for Dotnet Cli template (#6)
Browse files Browse the repository at this point in the history
* feat: add template and nuget conf

* chore: renaming , split readme

* docs: Update readme and comment

* style: renaming

* docs: update readme
  • Loading branch information
DamienLaffond authored Nov 7, 2024
1 parent 766a1e6 commit b8ea03c
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 144 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#name: Publish
#on:
# push:
# tags:
# - v*
#
#jobs:
# build:
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
#
# - name: Build NuGet Package
# run: nuget pack . -Version ${GITHUB_REF#refs/tags/v} -OutputDirectory ./artifacts
#
# - name: Publish NuGet package
# run: nuget push ./artifacts/nventive.Templates.Aspire.*.nupkg ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json
4 changes: 2 additions & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ queue_rules:
- name: default
conditions:
# Conditions to get out of the queue (= merged)
- check-success=nventive.UnoApplicationTemplate # Replace this with your CI pipeline name
- check-success= # Add your CI pipeline name

pull_request_rules:

Expand All @@ -12,7 +12,7 @@ pull_request_rules:
- base=main

# All Azure builds should be green:
- status-success=nventive.UnoApplicationTemplate # Replace this with your CI pipeline name
- status-success= # Add with your CI pipeline name

# CLA check must pass:
#- "status-success=license/cla"
Expand Down
23 changes: 23 additions & 0 deletions CloudTemplate.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>1.0</PackageVersion>
<PackageId>nventive.Templates.Aspire</PackageId>
<Title>Aspire Template c#</Title>
<Authors>LaffondDamien</Authors>
<Description>Template to use when creating project with dotnet cli.</Description>
<PackageTags>dotnet-new;templates;nventive</PackageTags>
<TargetFramework>net9.0</TargetFramework>

<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
</PropertyGroup>

<ItemGroup>
<Content Include="template\**\*" Exclude="template\**\bin\**;template\**\obj\**" />
<Compile Remove="**\*" />
</ItemGroup>

</Project>
158 changes: 17 additions & 141 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Open Source Project Template

This repository contains a template to seed a repository for an Open Source
This repository contains a template to seed a repository for an Aspire Open Source
project.

Prior to submitting your request for publication, make sure to review the
Expand All @@ -11,152 +11,28 @@ Prior to submitting your request for publication, make sure to review the

The following is the template for the final README.md file:

---
### Usage

# Project Title
#### Install template from nuget.org (Not yet available)

{Project tag line}
- execute : ``` dotnet new install <NUGET_PACKAGE_ID> ```

{Small description of the purpose of the project}
#### Install template from source

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
- git clone the template project
- go to root folder

## Getting Started
If you want to install the template from source directly :

The main prerequisites for a developer setup are:
- either Linux (including WSL) or macOS as OS;
- the Nix package manager with flakes enabled;
- direnv and nix-direnv;
- Docker;
- Visual Studio Code with the C# DevKit extension for debugging;
- an Azure account to deploy and run in the cloud.
- execute ``` dotnet new install .\template\ ```
- you can uninstall with the command ``` dotnet new uninstall .\template\ ```

Precise installations instructions are as follow:
If you want to install the template from local nuget (just to confirm the end to end creation):
- execute ``` dotnet pack ```
- execute ```dotnet new install ./bin/release/nventive.Template.1.0.0.nupkg```
- uninstall command : ```dotnet new uninstall nventive.Templates.Aspire```

### For WSL Users
- If you’re using Docker Desktop, remember to [enable it in your WSL distro](https://docs.docker.com/desktop/wsl/#enabling-docker-support-in-wsl-2-distros)
- VS Code extensions must be activated in WSL.
- The ASP.NET Core developement certificate installed in WSL must be trusted in your Windows browser.
#### Create new project

Then you need to trust the ASP.NET Core development certificate.

1. Install the .NET SDK in Windows [whichever way you want](https://learn.microsoft.com/en-us/dotnet/core/install/windows).
1. Install and activate the ASP.NET Core development certificate (`[password]` being any password you’ll remember in the next minute). In Windows:
```console
dotnet dev-certs https --clean
dotnet dev-certs https --trust
dotnet dev-certs https -ep https.pfx -p [password]
```
3. Restart your browser to make sure it trusts the new certificate.
3. Import the certificate in WSL and trust it for inter-service communications (`[path]` being the path to the windows directory you executed the previous commands, and `[password]` being the password entered previously):
```console
sudo apt install dotnet-sdk-8.0
dotnet dev-certs https --clean --import /mnt/c/[path]/https.pfx --password [password]
sudo -E dotnet dev-certs https -ep /usr/local/share/ca-certificates/aspnet/https.crt --format PEM
sudo update-ca-certificates
```

### For macOS and straight Linux users

ASP.NET Core development certificate is more simple.

1. [Install a .NET SDK](https://learn.microsoft.com/en-us/dotnet/core/install/).
2. Install and activate the ASP.NET Core development certificate
```console
dotnet dev-certs https --clean
dotnet dev-certs https --trust
```

### For all OSes: install Nix, direnv

Use the [Determinate Nix installer](https://github.com/DeterminateSystems/nix-installer):
```console
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```

Follow any instructions, including those necessary to get nix in path.

1. Install direnv.
```console
nix profile install nixpkgs#nix-direnv
```
2. [Hook direnv into your shell](https://direnv.net/docs/hook.html).

> For bash this means adding the following line in your `~/.bashrc`:
> ```bash
> eval "$(direnv hook bash)"
> ```
> For zsh (macOS), the file is `~/.zshrc` and the line is
> ```zsh
> eval "$(direnv hook zsh)"
> ```
3. Don’t forget to reload your shell
> ```console
> source ~/.bashrc
> ```
>
> or
> ```console
> source ~/.zshrc
> ```
4. Install nix-direnv in your user Nix profile and hook it up to direnv.
> ```console
> nix profile install nixpkgs#nix-direnv
> source $HOME/.nix-profile/share/nix-direnv/direnvrc
> ```
### Start for real
1. Get this repository’s content
```console
git checkout https://github.com/nventive/cloud-template.git
```
2. Copy the template to wherever you want to have it and enable the development shell (you can replace `MyProject` with whatever you want). **Warning:** the last step may take a while, as it’s downloading/building all tools and dependencies.
```console
cp -r cloud-template/template MyProject
cd MyProject
direnv allow
```

3. Rename the project according to your inspirations (`Placeholder` is the actual string to be replaced; `MyProject` can be whatever you want).
```console
fd Placeholder | tac | xargs rnm -rs '/Placeholder/MyProject/g' -y
fd --hidden --type file --exec sd Placeholder MyProject
```

4. Start VS Code. NB: it has to be started this way to ensure the correct .NET frawework is found and debugging works.
```console
just code
```

To get a list of other recipes:
```console
just --list
```

Further instructions are in the `README` of your new project.

## Features

{More details/listing of features of the project}

## Breaking Changes

Please consult [BREAKING_CHANGES.md](BREAKING_CHANGES.md) for more information about version
history and compatibility.

## License

This project is licensed under the Apache 2.0 license - see the
[LICENSE](LICENSE) file for details.

## Contributing

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for
contributing to this project.

Be mindful of our [Code of Conduct](CODE_OF_CONDUCT.md).
- execute ``` dotnet new nv-aspire -n MyApp ```
- follow the project readme.md
18 changes: 18 additions & 0 deletions template/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "LaffondDamien",
"classifications": ["Aspire"],
"identity": "nventive.Templates.Aspire",
"name": "Aspire Template",
"shortName": "nv-aspire",
"sourceName": "Placeholder",
"defaultName": "MyAspireProject",
"tags": {
"language": "C#",
"type": "solution"
},

"symbols": {},

"postActions": []
}
Loading

0 comments on commit b8ea03c

Please sign in to comment.