|
1 | | -# About component-base |
| 1 | +# ComponentBase Component/Library |
2 | 2 |
|
3 | | -This is a nuget/paket main scaffold component |
| 3 | +[](https://dev.azure.com/opitblast/CsharpComponentBase/_build/latest?definitionId=20&branchName=master) |
4 | 4 |
|
5 | | -[](https://www.nuget.org/packages/nuget-component/) |
6 | | -[](https://www.nuget.org/packages/nuget-component/) |
| 5 | +This is a **nuget/paket** main scaffold component to create others packages |
7 | 6 |
|
8 | | -## Release Process |
| 7 | +## Requirements |
9 | 8 |
|
10 | | -To create a new release: |
| 9 | +* ### [.NET Core](https://dotnet.microsoft.com/download) |
| 10 | + > Build and run tests |
11 | 11 |
|
12 | | -- Make sure the version is correct in the csproj file |
13 | | -- Push changes to master |
14 | | -- Create a tag |
15 | | -- Push the tag |
| 12 | +* ### [Nuget CLI](https://chocolatey.org/packages/NuGet.CommandLine/5.6.0) |
| 13 | + > .NET official package manager to generate **```.nupkg```** file |
| 14 | +
|
| 15 | +* ### [Paket](https://fsprojects.github.io/Paket/index.html) |
| 16 | + > Integrated with [Nuget]() to manage dependencies, with more clear files and allow use **Git** dependencies |
| 17 | +
|
| 18 | + |
| 19 | +## Getting Started |
| 20 | + |
| 21 | +### 1. Install [.NET Core](https://cakebuild.net/docs/tutorials/getting-started) |
| 22 | + |
| 23 | + - Use [Chocolatey](https://chocolatey.org/) |
| 24 | + |
| 25 | + ```bash |
| 26 | + choco install dotnetcore-sdk |
| 27 | + ``` |
| 28 | + Or download from https://dotnet.microsoft.com/download |
| 29 | + |
| 30 | + - Restart your terminal and check if the cli `dotnet` is in your `$PATH` environment variable |
| 31 | + |
| 32 | +### 2. Install [Nuget](https://chocolatey.org/packages/NuGet.CommandLine/5.6.0) |
| 33 | + |
| 34 | +Use [Chocolatey](https://chocolatey.org/) |
| 35 | + |
| 36 | +```bash |
| 37 | + choco install nuget.commandline |
| 38 | +``` |
| 39 | + |
| 40 | +#### 2.1 Install [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider) |
| 41 | + |
| 42 | + Optionally, you can install with [Chocolatey](https://chocolatey.org/) too |
| 43 | + |
| 44 | + ```bash |
| 45 | + # Install nuget AUTH PROVIDER |
| 46 | + # to push package for feed authenticate |
| 47 | + choco install nuget-credentialprovider-vss |
| 48 | + ``` |
| 49 | + > This is required to push ```.nupkg``` packages to **Azure Artifacts** |
| 50 | + |
| 51 | +### 3. Install [Paket](https://fsprojects.github.io/Paket/index.html) |
| 52 | + |
| 53 | +Use [.NET Core tools](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools#install-a-local-tool) to install **paket** command line locally |
| 54 | + |
| 55 | +```bash |
| 56 | + dotnet tool restore |
| 57 | +``` |
| 58 | + |
| 59 | +#### 3.1 Install Azure pipelines CLI (OPTIONAL) |
| 60 | + |
| 61 | +Use [Chocolatey](https://chocolatey.org/) |
| 62 | + |
| 63 | +```bash |
| 64 | + # Install base Azure command line |
| 65 | + choco install azure-cli |
| 66 | +
|
| 67 | + # Install Azure Devops extensions |
| 68 | + az extension add --name azure-devops |
| 69 | +``` |
| 70 | + |
| 71 | +### 4. Install all DEPENDENCIES and restore references |
| 72 | + |
| 73 | +```bash |
| 74 | + dotnet paket restore |
| 75 | + dotnet restore |
| 76 | +``` |
| 77 | + |
| 78 | +### 5. Build and test the solution |
| 79 | + |
| 80 | +```bash |
| 81 | + # Build the solution |
| 82 | + dotnet build |
| 83 | +
|
| 84 | + # Run all tests |
| 85 | + dotnet test |
| 86 | +``` |
| 87 | + |
| 88 | +## Project structure |
| 89 | + |
| 90 | +Your project folders structure should be: |
| 91 | + |
| 92 | +- 📂 __ComponentBase__ |
| 93 | + > The .NET solution group projects |
| 94 | + - 📄 [ComponentBase.sln](ComponentBase.sln) |
| 95 | + - 📂 __ComponentBase.Tests__ |
| 96 | + > The project with Unit and/or Integration tests |
| 97 | + - 📄 [ComponentBase.Tests.csproj](ComponentBase.Tests/ComponentBase.Tests.csproj) |
| 98 | + - 📂 __ComponentBase__ |
| 99 | + > The project with your library/component |
| 100 | + - 📄 [ComponentBaseComponent.csproj](ComponentBaseComponent/ComponentBaseComponent.csproj) |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +## Generating package (```.nupkg```) |
| 106 | + |
| 107 | +1. Make sure that project builds and all tests are passed |
| 108 | + |
| 109 | + ```bash |
| 110 | + # Build the solution |
| 111 | + dotnet build |
| 112 | +
|
| 113 | + # Run all tests |
| 114 | + dotnet test |
| 115 | + ``` |
| 116 | +2. Genarate the ```.nupkg``` file |
| 117 | + |
| 118 | + ```bash |
| 119 | + # Pack your component to the path nugets/*.nupkg |
| 120 | + dotnet pack --include-symbols --configuration Release --output nugets [your-component-project] |
| 121 | + ``` |
| 122 | + > **PS:** If you not pass the **_--outputs_** flag, the ```.nupkg``` file is generated in: ```[your-component-project]/bin/Release``` by default |
| 123 | + |
| 124 | +## Publish to Azure Devops |
| 125 | + |
| 126 | +1. Restore the project to provide authentication |
| 127 | + |
| 128 | + ```bash |
| 129 | + nuget restore |
| 130 | + ``` |
| 131 | + |
| 132 | +2. Push to the **Azure Artifacts** feed |
| 133 | + |
| 134 | + ```bash |
| 135 | + # See the nuget.config file <packageSources> tag |
| 136 | + nuget push -Source "[your-feed-name]" -ApiKey az [path/to/nupkg-file].nupkg |
| 137 | + ``` |
0 commit comments