package.ps1 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #-------------------------------------------------------------------------------------------------------
  2. # Copyright (C) Microsoft. All rights reserved.
  3. # Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. #-------------------------------------------------------------------------------------------------------
  5. $root = (split-path -parent $MyInvocation.MyCommand.Definition) + '\..'
  6. $packageRoot = "$root\NuGet"
  7. $packageVersionFile = "$packageRoot\.pack-version"
  8. $packageArtifacts = "$packageRoot\Artifacts"
  9. $targetNugetExe = "$packageRoot\nuget.exe"
  10. If (Test-Path $packageArtifacts)
  11. {
  12. # Delete any existing output.
  13. Remove-Item $packageArtifacts\*.nupkg
  14. }
  15. If (!(Test-Path $targetNugetExe))
  16. {
  17. $sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
  18. Write-Host "NuGet.exe not found - downloading latest from $sourceNugetExe"
  19. $sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
  20. Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
  21. }
  22. $versionStr = (Get-Content $packageVersionFile)
  23. Write-Host "Setting .nuspec version tag to $versionStr"
  24. $compiledNuspec = "$root\nuget\compiled.nuspec"
  25. # Create new packages for any nuspec files that exist in this directory.
  26. Foreach ($nuspec in $(Get-Item $packageRoot\*.nuspec))
  27. {
  28. $content = (Get-Content $nuspec)
  29. $content = $content -replace '\$version\$',$versionStr
  30. $content | Out-File $compiledNuspec
  31. & $targetNugetExe pack $compiledNuspec -outputdirectory $packageArtifacts
  32. }
  33. # Delete compiled temporary nuspec.
  34. If (Test-Path $compiledNuspec)
  35. {
  36. Remove-Item $compiledNuspec
  37. }