Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-165: Fixing NuGet publishing for repositories without an sln file #30

Merged
merged 6 commits into from
Aug 5, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/actions/publish-nuget/New-NuGetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@

param([array] $Arguments)

foreach ($project in (dotnet sln list | Select-Object -Skip 2 | Get-Item))
if (!(Get-ChildItem *.sln))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick with -not for neqation instead of the undocumented exclamation mark. However if you swap the if-else then you don't need any negation in the first place and save an extra pair of parens too.

Also Test-Path would be more expressive here than Get-ChildItem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the first one something the analyzers should catch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it should. I've opened an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

{
$projects = Get-ChildItem *.csproj
}
else
{
$projects = (dotnet sln list | Select-Object -Skip 2 | Get-Item)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PowerShell statements return a value too. This is so beautiful it brings tears to my eyes.
So you can do

$projects = if ( ... )
{
}
else
{
}

instead of assigning to the variable in each branch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 or 😢 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥲

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like poor man's ternary operator to me! Fortunately, PS 7 has actual ternary operators. I briefly contemplated keeping Windows PowerShell compatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more like a rich man's ternary operator because you can have multiple expressions in each arm so it's more powerful than a ternary. But yes, please use ternary then. This repo is already not compatible with Windows PowerShell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and it's lavish with all the characters. Almost like showing off! :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D


foreach ($project in $projects)
{
Push-Location $project.Directory

Expand Down