maandag 6 mei 2019

push nuget package from vscode

nuget works with csproj file to create nuget package
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
 <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
 <Version>1.0.3</Version>
 </PropertyGroup>

Will create [Assemblyname].1.0.3.nupkg file in configuration folder to build (dotnet build -c "Release")
from commandline
dotnet nuget push -s Source -k personal Tests.1.0.5.nupkg

be sure there is a nuget.config file in the root of your project with the sources you will restore / push the packages from

see: http://patrickvos.blogspot.com/2019/05/package-sources-in-vs-code.html


vrijdag 3 mei 2019

asp.net core service lifetime for DI

Service Lifetimes:


  1. Transient
  2. Scoped
  3. Singleton



Transient
Every request from the service container, it will be recreated.

Not to be confused with every controller request. but if in the pipeline of your request it is provided in multiple constructors and those are called from the service container, it will be instantiated as a new instance

Scoped
The object is instantiated once per client request / per connection

Singleton
The object is instantiated only once for all client calls.


woensdag 1 mei 2019

package sources in vs code

add nuget.config file in root

contents:

 <configuration>
    <packageSources>
        <add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
        <add key="[source name]" value="https://blbla.pkgs.visualstudio.com/_packaging/Core/nuget" />
    </packageSources>
    <packageSourceCredentials>
    <[source name]>
        <add key="Username" value="email account" />
        <add key="ClearTextPassword" value="password" />
    </[source name]>
    </packageSourceCredentials>
    <trustedSigners>
        <author name="microsoft">
            <certificate fingerprint="[fingerprint]" hashAlgorithm="SHA256" allowUntrustedRoot="false" />
        </author>
    </trustedSigners>
</configuration>

https://docs.microsoft.com/nl-nl/nuget/reference/nuget-config-file