build-new.ps1 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. $nuspecDir = Join-Path $scriptPath "NuSpecs"
  4. if (!(Test-Path .\nuget.exe)) {
  5. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  6. }
  7. $msbuild = Get-ItemProperty "hklm:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0"
  8. # TODO: if not found, bail out
  9. $msbuildExe = Join-Path $msbuild.MSBuildToolsPath "msbuild.exe"
  10. # get tools
  11. .\nuget.exe install -excludeversion -pre gitversion.commandline -Version 3.5.5-pullrequest0921 -outputdirectory packages
  12. #update version
  13. .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver /updateassemblyinfo
  14. $versionObj = .\packages\gitversion.commandline\tools\gitversion.exe | ConvertFrom-Json
  15. $version = $versionObj.MajorMinorPatch
  16. $tag = $versionObj.PreReleaseLabel
  17. $preRelNum = $versionObj.CommitsSinceVersionSourcePadded
  18. if($tag -ne ""){
  19. $version = "$version-$tag-$preRelNum"
  20. }
  21. Write-Host "Version: $version"
  22. Write-Host "Restoring packages" -Foreground Green
  23. dotnet restore $scriptPath | out-null
  24. Write-Host "Building projects" -Foreground Green
  25. $projects = gci $scriptPath -Directory `
  26. | Where-Object { ($_.Name -notlike "*DeviceRunner") -and (Test-Path (Join-Path $_.FullName "project.json")) } `
  27. foreach ($project in $projects) {
  28. dotnet build -c "$configuration" $project.FullName
  29. }
  30. Write-Host "Building Packages" -Foreground Green
  31. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  32. New-Item -ItemType Directory -Force -Path .\artifacts
  33. foreach ($nuspec in $nuspecs) {
  34. .\nuget pack $nuspec -symbols -Version $version -Properties "Configuration=$configuration" -MinClientVersion 2.12 -outputdirectory .\artifacts
  35. }
  36. Write-Host "Running tests" -Foreground Green
  37. $testDirectory = Join-Path $scriptPath "Tests"
  38. dotnet test $testDirectory -c $configuration
  39. Write-Host "Reverting AssemblyInfo's" -Foreground Green
  40. gci $scriptPath -re -in AssemblyInfo.cs | %{ git checkout $_ }