Category: nuget

  • Services.Add => 2 NuGet

    If you make a NuGet package for ASP.NET Core  and you make an extension method that calls Services.AddWhatever in order to add a Sngleton / Scoped / Transient a IWhatever =>  Whatever implementation,please add IWhatever in a separate Nuget . Why ? Because not all ASP>NET Core projects are made of a single project –…

  • [NuGet]: Transplator

    This is a Nuget that it is what Razor should have been. It is a Roslyn Source Code Generator that transforms template into code. Link: https://www.nuget.org/packages/Transplator  Site: https://github.com/atifaziz/Transplator What it does:  Takes a template and generates source code for outputting anything inside. Usage: Somewhere in the csproj: <ItemGroup>   <CompilerVisibleProperty Include=”DebugTransplator” />   <CompilerVisibleItemMetadata Include=”AdditionalFiles” MetadataName=”SourceItemType” />  …

  • [NuGet]: HealthCheck

    This is a Nuget that I use in all projects when I am making any ASP.NET Core prohect Link: https://www.nuget.org/packages/AspNetCore.HealthChecks.UI/ Site: https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks  What it does:  Implements health checks for your site and/or dependencies Usage: public void ConfigureServices(IServiceCollection services) { //code     services.AddHealthChecks()         .AddSqlServer(myConnectionString)  }

  • [NuGet]: Polly

    This is a Nuget that I use in all projects when I am making HTTP calls.. Link: https://www.nuget.org/packages/polly Site: https://github.com/App-vNext/Polly What it does:  Implements all kind of policies for retrying – see https://github.com/App-vNext/Polly/wiki/Transient-fault-handling-and-proactive-resilience-engineering Usage: – copied from https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy() {     return HttpPolicyExtensions         .HandleTransientHttpError()         .OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)         .WaitAndRetryAsync(6,retryAttempt => TimeSpan.FromSeconds(Math.Pow(2,                                                                     retryAttempt))); }

  • [Nuget]:NPOI

    This is a Nuget that I use in almost every .NET Core project to export files in an Excel format without excel on the PC. Link: https://www.nuget.org/packages/npoi Site: https://github.com/nissl-lab/npoi What it does:  Create real Excel files – not just CSV Usage: var wb = new XSSFWorkbook(); var sheet = wb.CreateSheet(“Contractors”); for (int i = 0;…

  • [NuGet]:Scriban

    This is a Nuget that I use in almost every .NET Core project to get the error details ( 500) Link: https://www.nuget.org/packages/Scriban/ Site: https://github.com/scriban/scriban What it does:  Like Razor –  a template intepreter Usage: var template = Template.Parse(@” <ul id=’products’> {{ for product in products }} <li> <h2>{{ product.name }}</h2> Price: {{ product.price }} {{…

  • [NuGet]:Hellang.Middleware.ProblemDetails

    This is a Nuget that I use in almost every .NET Core project to get the error details ( 500) Link: https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails/ Site: https://github.com/khellang/Middleware What it does:  Gives detailed error when encountering a 500 HTTP Code. Usage: services.AddProblemDetails(c=>             {                 c.IncludeExceptionDetails = (context,ex) => true;                             }); app.UseProblemDetails();

  • [NuGet] : MimeTypeMapOfficial

    This is a Nuget that I use in NetCore2Blockly to know the type of the file embedded: Link: https://www.nuget.org/packages/MimeTypeMapOfficial/ Site: https://github.com/samuelneff/MimeTypeMap What it does: Provides a huge two-way mapping of file extensions to mime types and mime types to file extensions, If no mime type is found then the generic “application/octet-stream” is returned. Usage: static…

  • Using files in a ASP.NET Core nuget package

    To use static (html) files in a NUGET ASP.NET Core package to be displayed I have used the following solution 1. Put the files in a folder ( in my case,blocklyAutomation ) 2. Put in the .csproj to embed the files <ItemGroup>   <EmbeddedResource Include=”BlocklyAutomation\**\*”>     <CopyToOutputDirectory>Never</CopyToOutputDirectory>   </EmbeddedResource> </ItemGroup> 3.  Create an extension to use it ;…

  • .NET Core global tool CD/CI with AzureDevops to Nuget

    I want to can deploy automatically from GitHub  to Nuget a .NET Global ( or local ) tool. It is enough simple; 1. Get an API key from GitHub 2. Goto to your AzureDevops,settings ( down the page ) and connect with a new Service Connection AzureDevops to GitHub ( name: nugetAndrei) 3. Make an…