Skip to content

Instantly share code, notes, and snippets.

@jeroensmink98
Last active March 22, 2023 09:57
Show Gist options
  • Save jeroensmink98/fbcdb9751ba42e518697d9c99ccedb0d to your computer and use it in GitHub Desktop.
Save jeroensmink98/fbcdb9751ba42e518697d9c99ccedb0d to your computer and use it in GitHub Desktop.
# Set the root folder path
$rootFolderPath = (Get-Location).Path
# Set the nugetType variable
$nugetType = "Framework"
# Create the .pipelines folder if it doesn't exist
$pipelinesFolderPath = Join-Path -Path $rootFolderPath -ChildPath ".pipelines"
if (-not (Test-Path -Path $pipelinesFolderPath)) {
New-Item -ItemType Directory -Path $pipelinesFolderPath | Out-Null
}
# Get all directories in the root folder
$directories = Get-ChildItem -Path $rootFolderPath -Directory
# Iterate through each directory and create the corresponding YAML file
foreach ($directory in $directories) {
$parts = $directory.Name.Split('.')
$filename = ($parts -join '-').ToLower() + "-nuget.yml"
$filepath = Join-Path -Path $pipelinesFolderPath -ChildPath $filename
# Find the .csproj file in the directory
$csprojFile = Get-ChildItem -Path $directory.FullName -Filter "*.csproj" | Select-Object -First 1
$relativeCsprojPath = $csprojFile.FullName.Replace($rootFolderPath, '').TrimStart('\')
# Generate the YAML content
$yamlContent = @"
PLACE YAML CONTENT HERE!
"@
# Write the YAML content to the file
Set-Content -Path $filepath -Value $yamlContent
}
@jeroensmink98
Copy link
Author

$rootFolderPath is now the current directory where the script is being executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment