Merge pull request #3 from Microsoft/master
Updated build to latest version
This commit is contained in:
Коммит
36050cab9c
|
@ -5,27 +5,21 @@ It expects as input an ApiKey authorized to publish the module.
|
|||
Insert any build steps you may need to take before publishing it here.
|
||||
#>
|
||||
param (
|
||||
$ApiKey
|
||||
$ApiKey,
|
||||
|
||||
$WorkingDirectory = $env:SYSTEM_DEFAULTWORKINGDIRECTORY
|
||||
)
|
||||
|
||||
# Prepare publish folder
|
||||
Write-PSFMessage -Level Important -Message "Creating and populating publishing directory"
|
||||
$publishDir = New-Item -Path $env:SYSTEM_DEFAULTWORKINGDIRECTORY -Name publish -ItemType Directory
|
||||
Copy-Item -Path "$($env:SYSTEM_DEFAULTWORKINGDIRECTORY)\PAWTools" -Destination $publishDir.FullName -Recurse -Force
|
||||
$publishDir = New-Item -Path $WorkingDirectory -Name publish -ItemType Directory
|
||||
Copy-Item -Path "$($WorkingDirectory)\PAWTools" -Destination $publishDir.FullName -Recurse -Force
|
||||
|
||||
# Create commands.ps1
|
||||
#region Gather text data to compile
|
||||
$text = @()
|
||||
Get-ChildItem -Path "$($publishDir.FullName)\PAWTools\internal\functions\" -Recurse -File -Filter "*.ps1" | ForEach-Object {
|
||||
$text += [System.IO.File]::ReadAllText($_.FullName)
|
||||
}
|
||||
Get-ChildItem -Path "$($publishDir.FullName)\PAWTools\functions\" -Recurse -File -Filter "*.ps1" | ForEach-Object {
|
||||
$text += [System.IO.File]::ReadAllText($_.FullName)
|
||||
}
|
||||
$text -join "`n`n" | Set-Content -Path "$($publishDir.FullName)\PAWTools\commands.ps1"
|
||||
|
||||
# Create resourcesBefore.ps1
|
||||
$processed = @()
|
||||
$text = @()
|
||||
|
||||
# Gather Stuff to run before
|
||||
foreach ($line in (Get-Content "$($PSScriptRoot)\filesBefore.txt" | Where-Object { $_ -notlike "#*" }))
|
||||
{
|
||||
if ([string]::IsNullOrWhiteSpace($line)) { continue }
|
||||
|
@ -40,11 +34,16 @@ foreach ($line in (Get-Content "$($PSScriptRoot)\filesBefore.txt" | Where-Object
|
|||
$processed += $item.FullName
|
||||
}
|
||||
}
|
||||
if ($text) { $text -join "`n`n" | Set-Content -Path "$($publishDir.FullName)\PAWTools\resourcesBefore.ps1" }
|
||||
|
||||
# Create resourcesAfter.ps1
|
||||
$processed = @()
|
||||
$text = @()
|
||||
# Gather commands
|
||||
Get-ChildItem -Path "$($publishDir.FullName)\PAWTools\internal\functions\" -Recurse -File -Filter "*.ps1" | ForEach-Object {
|
||||
$text += [System.IO.File]::ReadAllText($_.FullName)
|
||||
}
|
||||
Get-ChildItem -Path "$($publishDir.FullName)\PAWTools\functions\" -Recurse -File -Filter "*.ps1" | ForEach-Object {
|
||||
$text += [System.IO.File]::ReadAllText($_.FullName)
|
||||
}
|
||||
|
||||
# Gather stuff to run afterwards
|
||||
foreach ($line in (Get-Content "$($PSScriptRoot)\filesAfter.txt" | Where-Object { $_ -notlike "#*" }))
|
||||
{
|
||||
if ([string]::IsNullOrWhiteSpace($line)) { continue }
|
||||
|
@ -59,7 +58,14 @@ foreach ($line in (Get-Content "$($PSScriptRoot)\filesAfter.txt" | Where-Object
|
|||
$processed += $item.FullName
|
||||
}
|
||||
}
|
||||
if ($text) { $text -join "`n`n" | Set-Content -Path "$($publishDir.FullName)\PAWTools\resourcesAfter.ps1" }
|
||||
#endregion Gather text data to compile
|
||||
|
||||
#region Update the psm1 file
|
||||
$fileData = Get-Content -Path "$($publishDir.FullName)\PAWTools\PAWTools.psm1" -Raw
|
||||
$fileData = $fileData.Replace('"<was not compiled>"', '"<was compiled>"')
|
||||
$fileData = $fileData.Replace('"<compile code into here>"', ($text -join "`n`n"))
|
||||
[System.IO.File]::WriteAllText("$($publishDir.FullName)\PAWTools\PAWTools.psm1", $fileData, [System.Text.Encoding]::UTF8)
|
||||
#endregion Update the psm1 file
|
||||
|
||||
# Publish to Gallery
|
||||
Publish-Module -Path "$($publishDir.FullName)\PAWTools" -NuGetApiKey $ApiKey -Force
|
Загрузка…
Ссылка в новой задаче