BuildNuget.ps1 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. $location = Get-Location;
  2. $zebusLocation = [System.IO.Path]::Combine($location, ".\src\Abc.Zebus");
  3. $outputLocation = [System.IO.Path]::Combine($location, "output\nuget");
  4. $msbuild = 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe';
  5. # clean output
  6. if((Test-Path $outputLocation) -eq $true)
  7. {
  8. Remove-Item -Recurse -Force $outputLocation;
  9. }
  10. $dir = New-Item -ItemType directory $outputLocation;
  11. # Compile solution in release
  12. & '.\tools\nuget\NuGet.exe' restore .\src\Abc.Zebus.sln
  13. & $msbuild .\src\Abc.Zebus.sln /t:rebuild /p:Configuration=Release
  14. # Get metadata (without locking file)
  15. $fileStream = ([System.IO.FileInfo] (Get-Item ([System.IO.Path]::Combine($zebusLocation,"bin\Release\Abc.Zebus.dll")))).OpenRead();
  16. $assemblyBytes = new-object byte[] $fileStream.Length
  17. $fileStream.Read($assemblyBytes, 0, $fileStream.Length);
  18. $fileStream.Close();
  19. $assembly = [System.Reflection.Assembly]::Load($assemblyBytes);
  20. $attributes = $assembly.GetCustomAttributesData();
  21. $description = ($attributes | ? { $_.AttributeType.Name -eq "AssemblyDescriptionAttribute" })[0].ConstructorArguments;
  22. $product = ($attributes | ? { $_.AttributeType.Name -eq "AssemblyProductAttribute" })[0].ConstructorArguments;
  23. $company = ($attributes | ? { $_.AttributeType.Name -eq "AssemblyCompanyAttribute" })[0].ConstructorArguments;
  24. $copyright = ($attributes | ? { $_.AttributeType.Name -eq "AssemblyCopyrightAttribute" })[0].ConstructorArguments;
  25. $configuration = ($attributes | ? { $_.AttributeType.Name -eq "AssemblyConfigurationAttribute" })[0].ConstructorArguments;
  26. $version = ($attributes | ? { $_.AttributeType.Name -eq "AssemblyInformationalVersionAttribute" })[0].ConstructorArguments;
  27. $properties = "`"version="+$version.Value+";author="+$company.Value+";description="+$description.Value+";copyright="+$copyright.Value+";configuration="+$configuration.Value+"`"";
  28. # Build nuget for Zebus
  29. Write-Host "############# Building Zebus package #############" -ForegroundColor Green
  30. & '.\tools\nuget\NuGet.exe' pack .\build\nuget\nuspecs\Abc.Zebus.nuspec -BasePath $location -OutputDirectory $outputLocation -Properties $properties -sym;
  31. # Build nuget for Zebus.Testing
  32. Write-Host
  33. Write-Host "############# Building Zebus.Testing package #############" -ForegroundColor Green
  34. & '.\tools\nuget\NuGet.exe' pack .\build\nuget\nuspecs\Abc.Zebus.Testing.nuspec -BasePath $location -OutputDirectory $outputLocation -Properties $properties -sym;