Reputation: 4037
Dears
Please help me with VSTS build configuration for linked packages
I have two projects in the solution, like Interfaces and Dto. Interfaces contains several interface definitions, Dto project implements interfaces and has reference to Interfaces. Each project has dedicated nuspec file and is available as dedicated package in the vsts package feed.
To achive this I created nuspec files that contains package dependencies according to project references defined. So Dto package depends from Interfaces like below:
<package >
<metadata>
<id>Dto</id>
<dependencies>
<dependency id="Interfaces" version="0.4.0" />
</dependencies>
Those projects are hosted in the same VSTS git source code repository (but different folders)
Right now I have simple build definition that is triggered by changes in master branch.
It builds solution, than packs and pushes all nuspec files from the solution folder.
How can I configure build definitions for two packages to build Interfaces project only if Interfaces folder content was changed? But to build Dto package if Interfaces or Dto folder content was changed?
I've thought that can create two build definition that triggers by different Path filters. However the problem is that i need to set correct dependency version reference from Dto nuspec file to Interfaces package.
To set package version I use global build definition variable $versionFromFile that contains minor and major part of version number, like 0.4 and vsts revision for third part of package version. It is parameterized in the build number format like:
$(versionFromFile).$(Rev:rr)
each package build automatically increment revision number like 0.4.1, 0.4.2. When I need to change major package version number I update build definition variable value and revision is starting to count from zero. To set package version I configured nuget pack task "Automatic package versioning" parameter to "use the build number" value.
So in case for two build definition I need to reference from Dto package to Interfaces package last version somehow. Unfortunately I have no idea how to reference from Dto package build definition to the latest Interfaces build definition version number. The only one idea that I found is to save Interfaces build version number to a file. Then read it from Dto build definition to the new variable and use it. However it looks a little bit ugly. Is there a better way to reference from one build definition to another build definition $(BUILD.BUILDNUMBER) value?
Thank you
Upvotes: 1
Views: 389
Reputation: 4037
I've implemented solution that was suggested by @starianchen To achieve this I had to
pack Interfaces\Interfaces.nuspec -version $(BUILD.BUILDNUMBER) -properties "releaseNotes=$(releaseNotes)" -Verbosity Detailed -OutputDirectory $(build.artifactstagingdirectory)
and
pack Dro\Dto.csproj -version $(BUILD.BUILDNUMBER) -properties "Configuration=Release;releaseNotes=$(releaseNotes)" -Verbosity Detailed -OutputDirectory $(build.artifactstagingdirectory) -IncludeReferencedProjects
Please note that i've used .csproj file that has corresponding .nuspec for Dto packing command. - modify Dto.nuspec by removing Interfaces from dependency section and Dto.dll from Files (those elements are added by IncludeReferencedProjects option). However there are dto.xml and related assemblies
This allows me to update Interfaces package only when it changes. Dto project when packed takes dependency for the Interfaces package reference that was used when Dto project was built.
Upvotes: 1
Reputation: 33708
The simple way is calling nuget update command through Command line task before build task, then pack the project through Nuget task with Include referenced projects option checked.
Upvotes: 1
Reputation: 39898
I would suggest using the BuildChain extension from the Marketplace. This extension allows you to easily chain builds and pass parameters from one build to the next.
Upvotes: 0