This is a nuget/paket main scaffold component to create others packages
-
Build and run tests
-
.NET official package manager to generate
.nupkgfile -
Integrated with Nuget to manage dependencies, with more clear files and allow use Git dependencies
1. Install .NET Core
-
Use Chocolatey
choco install dotnetcore-sdk
Or download from https://dotnet.microsoft.com/download
-
Restart your terminal and check if the cli
dotnetis in your$PATHenvironment variable
2. Install Nuget
Use Chocolatey
choco install nuget.commandline2.1 Install Azure Artifacts Credential Provider
Optionally, you can install with Chocolatey too
# Install nuget AUTH PROVIDER
# to push package for feed authenticate
choco install nuget-credentialprovider-vssThis is required to push
.nupkgpackages to Azure Artifacts
3. Install Paket
Use .NET Core tools to install paket command line locally
dotnet tool install -g paketIf you got any error using paket with .NET Core, try install using chocolatey
choco install paketPS: Install globally if you will use paket in others projects. You can use globally also if your project not use .NET Core.
Use Chocolatey
# Install base Azure CLI (command line)
choco install azure-cli
# Install Azure Devops extensions
az extension add --name azure-devopspaket restore
dotnet restore# Build the solution
dotnet build
# Run all tests
dotnet testYour project folders structure should be:
- π ComponentBase
The .NET solution group projects
- π ComponentBase.sln
- π ComponentBase.Tests
The project with Unit and/or Integration tests
- π ComponentBase.Core
The project with your library/component core
-
Make sure that project builds and all tests are passed
# Build the solution dotnet build # Run all tests dotnet test
-
Generate the
.nupkgfile# Pack your component to the path nupkg/*.nupkg dotnet pack --include-symbols --configuration Release --output .\nupkg [your-component-project]
PS: If you not pass the --outputs flag, the
.nupkgfile is generated in:[your-component-project]/bin/Releaseby defaultOr use Visual Studio and right click on your project component under Solution explorer, and click Pack.
If you got a
Pack taskerror with .NET Core CLI or in Visual Studio, usePaket packcommand:paket pack --template [your-component-project]\[your-component-project].csproj.paket.template --build-config Release --symbols .\nupkg
The preferrable option is create a paket.local file in your consumer project/application,
and add the source path of your package. The source property could be a path that contains a .nupkg file. In this case, you need build and pack your component first:
- Build/Pack your component project first
# Use Visual Studio: Build => Build Solution
# or use dotnet core CLI
dotnet build- Create the paket.local file in your consumer root solution project/application
paket.local
nuget [my-component-id] -> source [my-component-solution]\[my-component-project]\[nupkg-folder] version [my-component-version]For more information, see the official documentation: The paket.local file
-
After generated the
.nupkgfile, create a folder accessible to you (local directory or network share) as package repo:Publish the package to local repo using
nuget add:nuget add [my-component.{version-number}].nupkg -source [your/local-repo/directory]
Using Paket
-
Add your local folder like a
sourceto thepaket.dependenciesfile, in a project/application that will use this package like a dependency:source D:\source\nuget_repo source ~/source/nuget_repo source \\server\nuget_repo # Paket supports relative directory to the paket.dependencies too source directory/relative/to/paket.dependencies
PS: Pay attention to avoid commit this file with the
my/local/pathto your CVS repository (like git). This is only to local tests.If you wish add a commit with the hardcoded path, add a common directory for everyone, for example:
C:\Program Files\Microsoft SDK\NuGetLocal -
Add the packageId like a dependency into
paket.dependenciesfile of your application:
Using Nuget
-
If your destiny project/application uses only Nuget like a package manager (without
Paket), you can add the nuget repo folder mentioned above with Visual Studio:For more information, see these tutorials:
-
Restore the project to provide authentication
nuget restore
-
Push to the Azure Artifacts feed
# See the nuget.config file <packageSources> tag nuget push -Source "[your-feed-name]" -ApiKey az [path/to/nupkg-file].nupkg
Using Paket
-
Add your remote feed URL like a
sourceto thepaket.dependenciesfile, in a project/application that will use this package like a dependency:# [organization]: Your organization in Azure Devops # [feed]: Your feed/server name, created in Azure Artifacts source https://pkgs.dev.azure.com/[organization]/_packaging/[feed]/nuget/v3/index.json # Paket supports relative directory to the paket.dependencies too source directory/relative/to/paket.dependencies
-
Add the packageId like a dependency into
paket.dependenciesfile of your application:
# [YourAppProject]: Is project name inside of the solution, that to use this dependency like a reference
## Using dotnet core
paket add --project [YourAppProject]/[YourAppProject].csproj {YourComponent.PackageIdName}
## Using .NET Framework
.\.paket\paket.exe add --project [YourAppProject]/[YourAppProject].csproj {YourComponent.PackageIdName}As result will be added in the paket.dependencies file:
And in the [YourComponent]/paket.references file:
Using Nuget
-
If your destiny project/application uses only Nuget like a package manager (without
Paket), you can add the remote feed URL mentioned above with Visual Studio:Where:
- [my-organization]: The name of the remote feed/server
- [organization]: replace with your organization name defined in Azure Devops
- [feed]: replace with your private feed (by organization or project) where the package that will be used like an dependency was uploaded.
For more information, see this official Microsoft tutorial:
-
Add the packageId like a dependency into
package.configor using the tag<PackageReference>in the[YourComponent]\YourComponent.csprojXML file. You can do this using Visual Studio:
Right clickon References under the componentproject => Manage Nuget Packages
- On the next screen, search by the packageId and click on
Installbutton
See the wiki pages in: CsharpPackagetBase Wiki






