build-new.ps1 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  4. $msbuild = Get-ItemProperty "hklm:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0"
  5. # TODO: if not found, bail out
  6. $msbuildExe = Join-Path $msbuild.MSBuildToolsPath "msbuild.exe"
  7. # get version
  8. .\nuget.exe install -excludeversion -pre gitversion.commandline -outputdirectory packages
  9. .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver /updateassemblyinfo
  10. $versionObj = .\packages\gitversion.commandline\tools\gitversion.exe | ConvertFrom-Json
  11. $version = $versionObj.NuGetVersionV2
  12. Write-Host "Version: $version"
  13. Write-Host "Restoring packages" -Foreground Green
  14. dotnet restore $scriptPath | out-null
  15. Write-Host "Building projects" -Foreground Green
  16. $projects = gci $scriptPath -Directory `
  17. | Where-Object { Test-Path (Join-Path $_.FullName "project.json") } `
  18. | Select -ExpandProperty FullName
  19. foreach ($project in $projects) {
  20. dotnet build -c "$configuration" $project
  21. }
  22. $nuspecDir = Join-Path $scriptPath "NuSpecs"
  23. Write-Host "Building Packages" -Foreground Green
  24. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  25. New-Item -ItemType Directory -Force -Path .\artifacts
  26. foreach ($nuspec in $nuspecs) {
  27. .\nuget pack $nuspec -Version $version -Properties "Configuration=$configuration" -MinClientVersion 3.4 -outputdirectory .\artifacts
  28. }
  29. Write-Host "Running tests" -Foreground Green
  30. $testDirectory = Join-Path $scriptPath "Tests"
  31. dotnet test $testDirectory -c $configuration