DEV Community

Mikey Was Here... AKA Schmidty
Mikey Was Here... AKA Schmidty

Posted on

Automate the authors of a Nuget package during the build process.

It's very simple.

create a get_authors.sh (Mine is in the root but could also be a folder for build scripts. That's probably where I will put it when I create an example to go with this post.

One line of code in get_authors.sh script file - I tried to put the code in the csproj but because of the percent symbol it was easier to put it in a script.

git log --format='%ae' | grep -v noreply | grep -v outlift | sort -u | tr '\n' ', '
Enter fullscreen mode Exit fullscreen mode

then add this fragment to your csproj file somewhere near the top

    <Target Name="SetAuthors" BeforeTargets="InitializeSourceControlInformation">
        <Exec Command="bash ../get_authors.sh" ConsoleToMSBuild="True" IgnoreExitCode="False">
            <Output PropertyName="Authors" TaskParameter="ConsoleOutput" />
        </Exec>
    </Target>
Enter fullscreen mode Exit fullscreen mode

In the section where the Authors tag is change that to

    <PropertyGroup>
        <Authors>$(Authors)</Authors>
Enter fullscreen mode Exit fullscreen mode

Now the Nuget package Authors value is always up to date.

Easy peasy.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay