This will automate a Nuget update for any projects you build as “Release” This is useful for any libraries you maintain. This basically automates the process here:
Directions around how to get this set up are at the top of the script.
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 Then 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 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 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 Whenever you want to publish to NuGet, just build the Release version.
REM DO NOT FORGET TO INCREASE TEH ASSEMBLY VERSION ON ANY NEW PUBLISHING
echo ====== PUBLISHING TO NUGET =====
echo Attempting to pack project...
nuget pack -Prop Configuration=Release -OutputFileNamesWithoutVersion
echo Successfully Packed.
echo Attempting to push package...
nuget push %TargetName%.nupkg [API KEY HERE] -Source https://api.nuget.org/v3/index.json
IF %errorlevel% NEQ 0 (
echo ERROR whilst trying to push file. Likely you forgot to increase the version number. Do this in: Project Properties>Application>Assembly Information>Assembly Version
) else (
echo File successfully pushed. Process successfull.