I'm not that great with Powershell and I'm facing a simple problem. I'm building an automatic Nuget package publish script and for that I need to push the nuget package with a file name like this "Name.version.nupkg". The version number changes so I would need to find a file that matches the patter with changing version number.
Currently the script is a simple script:
cd $PSScriptRoot
dotnet nuget push ..inDebugMacroFramework.*.nupgk --api-key --source https://api.nuget.org/v3/index.json
$PSScriptRoot is "MacroFrameworkLibrary/Local"
And the output is:
error: File does not exist (..inDebugMacroFramework.*.nupgk).
Image of the directory content here:
Thanks for the help in advance
EDIT: The final working script is as follows:
cd $PSScriptRoot
$files = Get-ChildItem ..inDebugMacroFramework.*.nupkg | Sort-Object LastWriteTime -Descending | Select-Object -First 1
foreach ($pgk in $files)
{
dotnet nuget push $pgk.FullName --api-key --source https://api.nuget.org/v3/index.json
}
question from:
https://stackoverflow.com/questions/66061102/powershell-use-pattern-matching-in-filenames 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…