0

I am trying to automate a job in Jenkins to build and deploy a visual studio solution. We can already get Jenkins to build the project. I have created a batch file that Jenkins runs after the project build that deploys a Squirrel package but I have parameterized the batch file as well as the Jenkins job which means I am still manually typing in the version number each time I run the job. What we need is to extract the version number from the project so it can be used as a parameter in the Squirrel batch file.

Seraph812
  • 397
  • 3
  • 7
  • 17
  • How are you setting the version number in the first place? You should really be setting that as part of your build process. – Rob K May 20 '16 at 15:22
  • We are manually incrementing it in the project properties and then commiting to version control after the change. Adding it to the Jenkins build process would circumvent the commit of the version number bump. – Seraph812 May 20 '16 at 19:47
  • Manularity is evil. Generally, you have something like a simple text file which contains MAJOR MINOR BUILD, and an early step in your build process reads that, then queries your source control for the revision # to use in the REVISION field, and generates your version info file. That same generated version info can then be used to deploy your package. – Rob K May 20 '16 at 20:00

1 Answers1

0

For my purposes, I moved the Squirrel logic to the .csproj file in the "AfterBuild" event. Now, every time a Release build is executed, a package is built and "releasified" along with the accessible version number.

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
    <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
      <Output TaskParameter="Assemblies" ItemName="myAssemblyInfo"/>
    </GetAssemblyIdentity>
    <Exec Command="D:\Squirrel\nuget pack &quot;D:\Squirrel\Nuspec Files\OurApplication.nuspec&quot; -Version %(myAssemblyInfo.Version)" />
    <Exec Command="D:\Squirrel\Squirrel.Windows-1.4.0\squirrel --releasify D:\Jenkins\default\Projects\OurApplication\Windows\OurApplication.%(myAssemblyInfo.Version).nupkg -r D:\Squirrel\Releases\OurApplication" />
  </Target>

See https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/visual-studio-packaging.md

Seraph812
  • 397
  • 3
  • 7
  • 17