Feature/revise manifest creation script (#3241)
* Make script PSv5 compatible again, apply some PS best practices * this commit removes PowerShell Core only features that were introduced with #2378 to ensure compatibility with PSv5 * adds comment based help * use consistently cased Cmdlet and variable names * improves input data related error handling * adds PS code regions for automatic code folding * automates the creation of the manifest file at the correct destination path * corrects the use of Write-Host and Write-Output Fixes #3061 * Adhere to YAML formatting conventions * Use cross-platform new line handling Co-authored-by: Sebastian Neumann <sebastian.neumann@experienceone.com>
This commit is contained in:
@@ -1,262 +1,261 @@
|
|||||||
|
#Requires -Version 5
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Winget Manifest creation helper script
|
||||||
|
.DESCRIPTION
|
||||||
|
The intent of this file is to help you generate a manifest for publishing
|
||||||
|
to the Windows Package Manager repository.
|
||||||
|
|
||||||
|
It'll attempt to download an installer from the user-provided URL to calculate
|
||||||
|
a checksum. That checksum and the rest of the input data will be compiled in a
|
||||||
|
.YAML file.
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\Projects\winget-pkgs> Get-Help .\Tools\YamlCreate.ps1 -Full
|
||||||
|
Show this script's help
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\Projects\winget-pkgs> .\Tools\YamlCreate.ps1
|
||||||
|
Run the script to create a manifest file
|
||||||
|
.NOTES
|
||||||
|
Please file an issue if you run into errors with this script:
|
||||||
|
https://github.com/microsoft/winget-pkgs/issues/
|
||||||
|
.LINK
|
||||||
|
https://github.com/microsoft/winget-pkgs/blob/master/Tools/YamlCreate.ps1
|
||||||
|
#>
|
||||||
|
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
$NewLine = [System.Environment]::NewLine
|
||||||
|
|
||||||
# The intent of this file is to help you generate a YAML file for publishing
|
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions?view=powershell-7#filters
|
||||||
# to the Windows Package Manager repository.
|
filter TrimString {
|
||||||
|
$_.Trim()
|
||||||
# define variables
|
|
||||||
$OFS = "`r`n" #linebreak
|
|
||||||
$CurrentDirectory = Get-Location
|
|
||||||
|
|
||||||
# Prompt for URL
|
|
||||||
While ($url.Length -eq 0) {
|
|
||||||
$url = Read-Host -Prompt 'Enter the URL to the installer'
|
|
||||||
}
|
}
|
||||||
$OFS
|
|
||||||
|
|
||||||
write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue
|
##########################################
|
||||||
|
#region checksum
|
||||||
|
while ([string]::IsNullOrWhiteSpace($URL)) {
|
||||||
|
$URL = Read-Host -Prompt 'Enter the URL to the installer' | TrimString
|
||||||
|
}
|
||||||
|
Write-Host $NewLine
|
||||||
|
Write-Host "Downloading URL. This will take awhile..." -ForegroundColor Blue
|
||||||
$WebClient = New-Object System.Net.WebClient
|
$WebClient = New-Object System.Net.WebClient
|
||||||
# This downloads the installer
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stream = $WebClient.OpenRead($URL)
|
$Stream = $WebClient.OpenRead($URL)
|
||||||
|
$Hash = (Get-FileHash -InputStream $Stream -Algorithm SHA256).Hash
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
write-host "Error downloading file. Please run the script again." -ForeGroundColor red
|
Write-Host "Error downloading file. Please run the script again." -ForegroundColor Red
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
$Stream.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Url: $URL"
|
||||||
|
Write-Host "Sha256: $Hash"
|
||||||
|
|
||||||
# This command will get the sha256 hash
|
Write-Host $NewLine
|
||||||
$Hash = get-filehash -InputStream $stream
|
Write-Host "File downloaded. Please Fill out required fields."
|
||||||
$stream.Close()
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
$string = "Url: " + $URL ;
|
|
||||||
Write-Output $string
|
|
||||||
$string = "Sha256: " + $Hash.Hash
|
|
||||||
$string
|
|
||||||
$OFS
|
|
||||||
write-host "File downloaded. Please Fill out required fields. "
|
|
||||||
|
|
||||||
##########################################
|
|
||||||
# Read in metadata
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
While ($id.Length -lt 4 -or $id.length -ge 255) {
|
##########################################
|
||||||
write-host 'Enter the package Id, in the following format <Publisher.Appname>'
|
#region Read in metadata
|
||||||
$id = Read-Host -Prompt 'For example: Microsoft.Excel'
|
|
||||||
|
while ($ID.Length -lt 4 -or $ID.Length -ge 255) {
|
||||||
|
Write-Host 'Enter the package Id, in the following format <Publisher.Appname>'
|
||||||
|
$ID = Read-Host -Prompt 'For example: Microsoft.Excel' | TrimString
|
||||||
}
|
}
|
||||||
|
|
||||||
$host.UI.RawUI.ForegroundColor = "White"
|
$host.UI.RawUI.ForegroundColor = "White"
|
||||||
While ($publisher.Length -eq 0 -or $publisher.length -ge 128) {
|
while ([string]::IsNullOrWhiteSpace($Publisher) -or $Publisher.Length -ge 128) {
|
||||||
$publisher = Read-Host -Prompt 'Enter the publisher'
|
$Publisher = Read-Host -Prompt 'Enter the publisher' | TrimString
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($AppName.Length -eq 0 -or $AppName.length -ge 128) {
|
while ([string]::IsNullOrWhiteSpace($AppName) -or $AppName.Length -ge 128) {
|
||||||
$AppName = Read-Host -Prompt 'Enter the application name'
|
$AppName = Read-Host -Prompt 'Enter the application name' | TrimString
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($version.Length -eq 0) {
|
while ([string]::IsNullOrWhiteSpace($version)) {
|
||||||
$version = Read-Host -Prompt 'Enter the version. For example: 1.0, 1.0.0.0'
|
$version = Read-Host -Prompt 'Enter the version. For example: 1.0.0, 1.0.0.0, 1.0' | TrimString
|
||||||
$filename = $version + ".yaml"
|
$ManifestName = $version + ".yaml"
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($License.Length -eq 0 -or $License.length -ge 40) {
|
while ([string]::IsNullOrWhiteSpace($License) -or $License.Length -ge 40) {
|
||||||
$License = Read-Host -Prompt 'Enter the License, For example: MIT, or Copyright (c) Microsoft Corporation'
|
$License = Read-Host -Prompt 'Enter the License, For example: MIT, or Copyright (c) Microsoft Corporation' | TrimString
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($InstallerType -notin ("exe", "msi", "msix", "inno", "nullsoft", "appx", "wix", "zip")) {
|
while ($InstallerType -notin @("exe", "msi", "msix", "inno", "nullsoft", "appx", "wix", "zip")) {
|
||||||
$InstallerType = Read-Host -Prompt 'Enter the InstallerType. For example: exe, msi, msix, inno, nullsoft'
|
$InstallerType = Read-Host -Prompt 'Enter the InstallerType. For example: exe, msi, msix, inno, nullsoft'
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($architecture -notin ("x86", "x64", "arm", "arm64", "neutral")) {
|
while ($architecture -notin @("x86", "x64", "arm", "arm64", "neutral")) {
|
||||||
$architecture = Read-Host -Prompt 'Enter the architecture (x86, x64, arm, arm64, Neutral)'
|
$architecture = Read-Host -Prompt 'Enter the architecture (x86, x64, arm, arm64, Neutral)'
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$LicenseUrl = Read-Host -Prompt '[OPTIONAL] Enter the license URL'
|
$LicenseUrl = Read-Host -Prompt '[OPTIONAL] Enter the license URL' | TrimString
|
||||||
} while ($LicenseUrl.Length -ge 1 -AND ($LicenseUrl.Length -lt 10 -or $LicenseUrl.Length -gt 2000))
|
} while (-not [string]::IsNullOrWhiteSpace($LicenseUrl) -and ($LicenseUrl.Length -lt 10 -or $LicenseUrl.Length -gt 2000))
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$AppMoniker = Read-Host -Prompt '[OPTIONAL] Enter the AppMoniker (friendly name). For example: vscode'
|
$AppMoniker = Read-Host -Prompt '[OPTIONAL] Enter the AppMoniker (friendly name/alias). For example: vscode' | TrimString
|
||||||
} while ($AppMoniker.Length -gt 40)
|
} while ($AppMoniker.Length -gt 40)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$Tags = Read-Host -Prompt '[OPTIONAL] Enter any tags that would be useful to discover this tool. For example: zip, c++'
|
$Tags = Read-Host -Prompt '[OPTIONAL] Enter any tags that would be useful to discover this tool. For example: zip, c++' | TrimString
|
||||||
} while ($Tags.length -gt 40)
|
} while ($Tags.Length -gt 40)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$Homepage = Read-Host -Prompt '[OPTIONAL] Enter the Url to the homepage of the application'
|
$Homepage = Read-Host -Prompt '[OPTIONAL] Enter the Url to the homepage of the application' | TrimString
|
||||||
} while ($Homepage.length -ge 1 -AND ($Homepage.Length -lt 10 -or $Homepage.Length -gt 2000))
|
} while (-not [string]::IsNullOrWhiteSpace($LicenseUrl) -and ($Homepage.Length -lt 10 -or $Homepage.Length -gt 2000))
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$Description = Read-Host -Prompt '[OPTIONAL] Enter a description of the application'
|
$Description = Read-Host -Prompt '[OPTIONAL] Enter a description of the application' | TrimString
|
||||||
} while ($Description.length -gt 500)
|
} while ($Description.Length -gt 500)
|
||||||
|
|
||||||
# Only prompt for silent switches if $InstallerType is "exe"
|
# Only prompt for silent switches if $InstallerType is "exe"
|
||||||
if ($InstallerType.ToLower() -eq "exe") {
|
if ($InstallerType -ieq "exe") {
|
||||||
$Silent = Read-Host -Prompt '[OPTIONAL] Enter the silent install switch'
|
$Silent = Read-Host -Prompt '[OPTIONAL] Enter the silent install switch'| TrimString
|
||||||
$SilentWithProgress = Read-Host -Prompt '[OPTIONAL] Enter the silent (with progress) install switch'
|
$SilentWithProgress = Read-Host -Prompt '[OPTIONAL] Enter the silent (with progress) install switch'| TrimString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
##########################################
|
|
||||||
# Write metadata
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
$OFS
|
##########################################
|
||||||
$string = "Id: " + $id
|
#region Write metadata
|
||||||
write-output $string | out-file $filename
|
|
||||||
write-host "Id: " -ForeGroundColor Blue -NoNewLine
|
|
||||||
write-host $id -ForeGroundColor White
|
|
||||||
|
|
||||||
$string = "Version: " + $Version
|
# YAML files should always start with the document start separator "---"
|
||||||
write-output $string | out-file $filename -append
|
# https://yaml.org/spec/1.2/spec.html#id2760395
|
||||||
write-host "Version: " -ForeGroundColor Blue -NoNewLine
|
$string = "---$NewLine"
|
||||||
write-host $Version -ForeGroundColor White
|
Write-Output $string | Out-File $ManifestName
|
||||||
|
|
||||||
|
Write-Host $NewLine
|
||||||
|
$string = "Id: $ID"
|
||||||
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
|
Write-Host "Id: " -ForegroundColor Blue -NoNewline
|
||||||
|
Write-Host $ID -ForegroundColor White
|
||||||
|
|
||||||
$string = "Name: " + $AppName
|
$string = "Version: $Version"
|
||||||
write-output $string | out-file $filename -append
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-host "Name: " -ForeGroundColor Blue -NoNewLine
|
Write-Host "Version: " -ForegroundColor Blue -NoNewline
|
||||||
write-host $AppName -ForeGroundColor White
|
Write-Host $Version -ForegroundColor White
|
||||||
|
|
||||||
$string = "Publisher: " + $Publisher
|
$string = "Name: $AppName"
|
||||||
write-output $string | out-file $filename -append
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-host "Publisher: " -ForeGroundColor Blue -NoNewLine
|
Write-Host "Name: " -ForegroundColor Blue -NoNewline
|
||||||
write-host $Publisher -ForeGroundColor White
|
Write-Host $AppName -ForegroundColor White
|
||||||
|
|
||||||
$string = "License: " + $License
|
$string = "Publisher: $Publisher"
|
||||||
write-output $string | out-file $filename -append
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-host "License: " -ForeGroundColor Blue -NoNewLine
|
Write-Host "Publisher: " -ForegroundColor Blue -NoNewline
|
||||||
write-host $License -ForeGroundColor White
|
Write-Host $Publisher -ForegroundColor White
|
||||||
|
|
||||||
if (!($LicenseUrl.length -eq 0)) {
|
$string = "License: $License"
|
||||||
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
$string = "LicenseUrl: " + $LicenseUrl
|
Write-Host "License: " -ForegroundColor Blue -NoNewline
|
||||||
write-output $string | out-file $filename -append
|
Write-Host $License -ForegroundColor White
|
||||||
write-host "LicenseUrl: " -ForeGroundColor Blue -NoNewLine
|
|
||||||
write-host $LicenseUrl -ForeGroundColor White
|
|
||||||
|
|
||||||
|
if (-not [string]::IsNullOrWhiteSpace($LicenseUrl)) {
|
||||||
|
$string = "LicenseUrl: $LicenseUrl"
|
||||||
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
|
Write-Host "LicenseUrl: " -ForegroundColor Blue -NoNewline
|
||||||
|
Write-Host $LicenseUrl -ForegroundColor White
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($AppMoniker.length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($AppMoniker)) {
|
||||||
|
$string = "AppMoniker: $AppMoniker"
|
||||||
$string = "AppMoniker: " + $AppMoniker
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "AppMoniker: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "AppMoniker: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $AppMoniker -ForegroundColor White
|
||||||
write-host $AppMoniker -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Commands.length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($Commands)) {
|
||||||
|
$string = "Commands: $Commands"
|
||||||
$string = "Commands: " + $Commands
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "Commands: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "Commands: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $Commands -ForegroundColor White
|
||||||
write-host $Commands -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Tags.length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($Tags)) {
|
||||||
|
$string = "Tags: $Tags"
|
||||||
$string = "Tags: " + $Tags
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "Tags: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "Tags: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $Tags -ForegroundColor White
|
||||||
write-host $Tags -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Description.length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($Description)) {
|
||||||
|
$string = "Description: $Description"
|
||||||
$string = "Description: " + $Description
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "Description: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "Description: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $Description -ForegroundColor White
|
||||||
write-host $Description -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Homepage.Length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($Homepage)) {
|
||||||
|
$string = "Homepage: $Homepage"
|
||||||
$string = "Homepage: " + $Homepage
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "Homepage: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "Homepage: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $Homepage -ForegroundColor White
|
||||||
write-host $Homepage -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Output "Installers:" | Out-File $ManifestName -Append
|
||||||
|
|
||||||
write-output "Installers:" | out-file $filename -append
|
$string = " - Arch: $architecture"
|
||||||
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
|
Write-Host "Arch: " -ForegroundColor Blue -NoNewline
|
||||||
|
Write-Host $architecture -ForegroundColor White
|
||||||
|
|
||||||
|
$string = " Url: $URL"
|
||||||
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
|
Write-Host "Url: " -ForegroundColor Blue -NoNewline
|
||||||
|
Write-Host $URL -ForegroundColor White
|
||||||
|
|
||||||
$string = " - Arch: " + $architecture
|
$string = " Sha256: $Hash"
|
||||||
write-output $string | out-file $filename -append
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-host "Arch: " -ForeGroundColor Blue -NoNewLine
|
Write-Host "Sha256: " -ForegroundColor Blue -NoNewline
|
||||||
write-host $architecture -ForeGroundColor White
|
Write-Host $Hash -ForegroundColor White
|
||||||
|
|
||||||
$string = " Url: " + $Url
|
$string = " InstallerType: $InstallerType"
|
||||||
write-output $string | out-file $filename -append
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-host "Url: " -ForeGroundColor Blue -NoNewLine
|
Write-Host "InstallerType: " -ForegroundColor Blue -NoNewline
|
||||||
write-host $Url -ForeGroundColor White
|
Write-Host $InstallerType -ForegroundColor White
|
||||||
|
|
||||||
$string = " Sha256: " + $Hash.Hash
|
|
||||||
write-output $string | out-file $filename -append
|
|
||||||
write-host "Sha256: " -ForeGroundColor Blue -NoNewLine
|
|
||||||
write-host $Hash.Hash -ForeGroundColor White
|
|
||||||
|
|
||||||
$string = " InstallerType: " + $InstallerType
|
|
||||||
write-output $string | out-file $filename -append
|
|
||||||
write-host "InstallerType: " -ForeGroundColor Blue -NoNewLine
|
|
||||||
write-host $InstallerType -ForeGroundColor White
|
|
||||||
|
|
||||||
if (!($Silent.Length) -eq 0 -Or !($SilentWithProgress.Length -eq 0)) {
|
|
||||||
|
|
||||||
|
if ((-not [string]::IsNullOrWhiteSpace($Silent)) -or
|
||||||
|
(-not [string]::IsNullOrWhiteSpace($SilentWithProgress))) {
|
||||||
$string = " Switches:"
|
$string = " Switches:"
|
||||||
write-output $string | out-file $filename -append
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-host "Switches: " -ForeGroundColor Blue -NoNewLine
|
Write-Host "Switches: " -ForegroundColor Blue -NoNewline
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Silent.Length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($Silent)) {
|
||||||
|
$string = " Silent: $Silent"
|
||||||
$string = " Silent: " + $Silent
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "Silent: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "Silent: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $Silent -ForegroundColor White
|
||||||
write-host $Silent -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($SilentWithProgress.Length -eq 0)) {
|
if (-not [string]::IsNullOrWhiteSpace($SilentWithProgress)) {
|
||||||
|
$string = " SilentWithProgress: $SilentWithProgress"
|
||||||
$string = " SilentWithProgress: " + $SilentWithProgress
|
Write-Output $string | Out-File $ManifestName -Append
|
||||||
write-output $string | out-file $filename -append
|
Write-Host "SilentWithProgress: " -ForegroundColor Blue -NoNewline
|
||||||
write-host "SilentWithProgress: " -ForeGroundColor Blue -NoNewLine
|
Write-Host $SilentWithProgress -ForegroundColor White
|
||||||
write-host $SilentWithProgress -ForeGroundColor White
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($CurrentDirectory -match "winget-pkgs\\manifests\\(?<publisher>.+?)\\(?<appname>.+?)$") {
|
$ManifestsFolder = (Resolve-Path "$PSScriptRoot\..\manifests").Path
|
||||||
$FileLocation = Join-Path "\" "manifests" $Matches.publisher $Matches.appname
|
$PublisherFolder = Join-Path $ManifestsFolder $Publisher
|
||||||
$AbsoluteFileLocation = $CurrentDirectory
|
$AppFolder = Join-Path $PublisherFolder $AppName
|
||||||
} elseif ($CurrentDirectory -match "winget-pkgs\\manifests\\(?<publisher>.+?)$") {
|
New-Item -ItemType "Directory" -Force -Path $AppFolder | Out-Null
|
||||||
$appNameDirectory = $id.Split('.')[1]
|
|
||||||
$FileLocation = Join-Path "\" "manifests" $Matches.publisher $appNameDirectory
|
$FileOldEncoding = Get-Content -Raw $ManifestName
|
||||||
$AbsoluteFileLocation = Join-Path $CurrentDirectory $appNameDirectory
|
Remove-Item -Path $ManifestName
|
||||||
} else {
|
$ManifestPath = Join-Path $AppFolder $ManifestName
|
||||||
$RepositoryRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Source)
|
|
||||||
$FileLocation = Join-Path "\" "manifests" $id.Split('.')[0..1]
|
|
||||||
$AbsoluteFileLocation = Join-Path $RepositoryRoot $FileLocation
|
|
||||||
}
|
|
||||||
if (-not (Test-Path $AbsoluteFileLocation)) {
|
|
||||||
New-Item $AbsoluteFileLocation -ItemType Directory | Out-Null
|
|
||||||
}
|
|
||||||
$FileOldEnconding = Get-Content -Raw $filename
|
|
||||||
Remove-Item -Path $filename
|
|
||||||
$filename = Join-Path $AbsoluteFileLocation $filename
|
|
||||||
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
||||||
[System.IO.File]::WriteAllLines($filename, $FileOldEnconding, $Utf8NoBomEncoding)
|
[System.IO.File]::WriteAllLines($ManifestPath, $FileOldEncoding, $Utf8NoBomEncoding)
|
||||||
|
|
||||||
$string = "Yaml file created: " + $filename
|
Write-Host $NewLine
|
||||||
write-output $string
|
Write-Host "Yaml file created: $ManifestPath"
|
||||||
|
|
||||||
write-host "Now place this file in the following location: $FileLocation "
|
#endregion
|
||||||
|
##########################################
|
||||||
|
Reference in New Issue
Block a user