Skip to content

Commit

Permalink
Update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Castaner committed Jun 1, 2017
1 parent 10befe9 commit a52f56f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
param([String]$key,[String]$version)

function setProjectVersion([String]$project, [String]$version) {
$fileName = ".\src\$project\project.json"
$content = (Get-Content $fileName) -join "`n" | ConvertFrom-Json
$content.version = $version
$newContent = ConvertTo-Json -Depth 10 $content
Set-Content $fileName $newContent
$fileName = resolve-path ".\src\$project\$project.csproj"
$content = [xml](Get-Content $fileName)
$v = $content.CreateElement("Version")
$v.set_InnerXML($version)
$content.Project.PropertyGroup.AppendChild($v)
$content.Save($fileName)
}

function publishProject([String]$project,[String]$version) {
cd ".\src\$project"
& dotnet pack -c Release
if ($LastExitCode -ne 0) {
throw "Error ($LastExitCode) during dotnet pack"
}
$file = Get-Item "bin\Release\*.$version.nupkg"
nuget push $file.FullName $key -Source https://api.nuget.org/v3/index.json
if ($LastExitCode -ne 0) {
throw "Error ($LastExitCode) during nuget push"
}
cd ..\..
}

if ($version -ne "") {
setProjectVersion "Folke.Core" $version

& dotnet restore
if ($LastExitCode -ne 0) {
throw "Error ($LastExitCode) during dotnet restore"
}

publishProject "Folke.Core" $version
}

0 comments on commit a52f56f

Please sign in to comment.