How vs2017-MVC project package create automatically with octopack

130 views Asked by At

Actually, the octopus server installed on my local machine, I don't want to use Build Automation tools like TeamCity, TFS, or 3rd party tools like Nant. we use MSBuild.

New in octopus deploy, looking for idea how to get the package version unique number on each vs2017 build. So far know octopus require every package version unique, want to use MS-build command on my vs2017 project that helps me to create a unique number on each successful build.

Recently use following the MSBuild on "Developer Command Prompt for VS2017"

msbuild 
/t:build
/p:RunOctoPack=true
/p:OctoPackPackageVersion=1.0.0-BETA-1 /p:OctoPackReleaseNotesFile=ReleaseNotes.txt 
/p:OctoPackPublishPackageToHttp=http://localhost/nuget/packages /p:OctoPackPublishApiKey=API-9MQWIWVDKR44YSGYROUGPPFBXX

Is there any way to use any variable with /p:OctoPackPackageVersion which increment in every build.

I am looking for help on following

  1. After each successful vs2017 build want to create a package?
  2. How to keep new package not override previous packages?
  3. How to get a unique version number for each successful build?

If have any query please ask.

1

There are 1 answers

0
shamim On

Thanks to octopus support team,

Typically a build number would be supplied from a build server like TFS or Team City. These build numbers are incremented by default, making them a convenient way to provide a new version number with each build.

It sounds like you are building directly from the command line though, and not using a build server. In this scenario, you will have to manage the version numbers manually, and pass them on the command line. This approach is not recommended though as it will not scale well and will be difficult to manage with larger projects. But to get started you could use a date format from Powershell like this. Because the date is guaranteed to increment between builds, it is a quick way to get unique and incrementing version numbers.

msbuild 
/t:build
/p:RunOctoPack=true
/p:OctoPackPackageVersion=$(get-date -Format "yyyy.HH.dd") 
/p:OctoPackReleaseNotesFile=ReleaseNotes.txt 
/p:OctoPackPublishPackageToHttp=http://localhost/nuget/packages 
/p:OctoPackPublishApiKey=API-APIKEYGOESHERE