
This will automate a Nuget update to your personal/company NuGet library for any projects you build as “Release” This is useful for any personal/private libraries you maintain. This basically automates the process here:
Directions around how to get this set up are at the top of the script. an example of a NuGet repo URL is: https://mysite.uk/myNuGet/nuget
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
REM NuGet Auto-publish on Build REM by stigzler, MagoArcade.org REM USAGE: First, install nuget.exe and add it to your Environment Path variable (guide here: https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio-net-framework) REM REM You can OPTIONALLY create a newget manifest for your project by running cmd inside your project directory and running "nuget spec [yourprojectname.vbproj]" REM Do not change the tokens in this manifest file (e.g. "$version$") but you can change the others REM Put this file in your project base directory. Change [MyNuGetAPIKey] to your API Key. REM REM Add the below to your projects Post-Build Events (Project Properties>Compile>Build Events): REM if $(ConfigurationName) == Debug Exit REM $(ProjectDir)\NuGetPublish.bat $(ProjectDir) $(TargetName) REM If seeing ERROR 409 (Conflict), you likely you forgot to increase the version number. Do this in: Project Properties>Application>Assembly Information>Assembly Version REM Include the line above in the post-build event (it doesn't matter that it's invalid syntax). It reminds you of reasons for a build error REM Whenever you want to publish to NuGet, just build the Release version. REM DO NOT FORGET TO INCREASE THE ASSEMBLY VERSION ON ANY NEW PUBLISHING echo ====== PUBLISHING TO NUGET ====== set ProjectDir=%1% set TargetName=%2% cd %ProjectDir% echo Attempting to pack project... nuget pack -Prop Configuration=Release -OutputFileNamesWithoutVersion echo Successfully Packed. echo Attempting to push package... nuget push %TargetName%.nupkg [YourAPIKeyHERE] -Source [Your NuGet repo URL here] |
Leave a Reply