Skip to content

Commit

Permalink
added build, publish and nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
Danijel Peric committed Mar 26, 2023
1 parent 2c1b191 commit 7eb7e58
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
36 changes: 36 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Taken from psake https://github.com/psake/psake

<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}

$artifacts = ".\artifacts"

if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }

exec { & dotnet clean -c Release }

exec { & dotnet build -c Release }

exec { & dotnet test -c Release --no-build -l trx --verbosity=normal }

exec { & dotnet pack .\src\MediatR.ParallelPublisher\MediatR.ParallelPublisher.csproj -c Release -o $artifacts --no-build }

6 changes: 6 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
18 changes: 18 additions & 0 deletions Push.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$scriptName = $MyInvocation.MyCommand.Name
$artifacts = "./artifacts"

if ([string]::IsNullOrEmpty($Env:NUGET_API_KEY)) {
Write-Host "${scriptName}: NUGET_API_KEY is empty or not set. Skipped pushing package(s)."
} else {
Get-ChildItem $artifacts -Filter "*.nupkg" | ForEach-Object {
Write-Host "$($scriptName): Pushing $($_.Name)"
Write-Host "NUGET_URL: $Env:NUGET_URL"
Write-Host "NUGET_API_KEY: $Env:NUGET_API_KEY"
Write-Host "PACKAGE: $_.FullName"

dotnet nuget push $_.FullName --source $Env:NUGET_URL --api-key $Env:NUGET_API_KEY
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class MyCustomExceptionHandler : INotificationExceptionHandler

## License

MediatR.ParallelPublisher is released under the Apache License. See the LICENSE file for details.
MediatR.ParallelPublisher is released under the Apache License. See the [LICENSE](https://github.com/koderi-dp/MediatR.ParallelPublisher/blob/main/LICENSE) file for details.

## Contributing
Contributions are welcome! Feel free to submit issues, feature requests, or pull requests.
Binary file added icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/MediatR.ParallelPublisher/MediatR.ParallelPublisher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,27 @@
<LangVersion>10.0</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\MediatR.ParallelPublisher.snk</AssemblyOriginatorKeyFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>MediatR.ParallelPublisher</Title>
<PackageIcon>icon.jpg</PackageIcon>
<Version>1.0.1</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\icon.jpg" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

0 comments on commit 7eb7e58

Please sign in to comment.