tfs automated build of wcf ria services solutions that use nuget packages

Aug 26, 2011 at 1:57 AM
Edited Aug 26, 2011 at 1:59 AM

A possibly interesting finding that i'll raise here in case others are trying to also tfs automated build of wcf ria services solutions that use nuget packages.

The wcf ria services file | new | project | silverlight business application project template generates a silverlight project <mybizapp> and a corresponding asp.net <mybizapp>.web project.   In both these projects i had relevant Nuget packages installed.   I'm using the excerpt below in the pre-build event for these projects so that for dev's who sync the tfs source control tree for the first tme when then build it automatically pulls the necessary nuget packages into place.   This also solves the getting the packages pulled and into place during tfs automated build definition processing w/o resorting to the undesirable model of keeping package binaries in source control, see this discusion item [ http://nuget.codeplex.com/discussions/268977 ] for asks on that subject.

On my tfs server during automated build processing things kept failing saying that the silverlight project <mybizapp> couldn't find the nuget packages using the default ..\packages hint path setting.  It turns out this appears to be due to some aspect of the <mybizapp>.web project that tries to build that project when it builds in order to generate the silverlight <mybizapp> code generated client proxy library that is one of the big value props for the whole wcf ria services n-tier application model.

To fix the tfs automated build processing i ended up editing my <mybizapp>.web\packages.config file and added to it the items that were part of my <mybizapp>\pacakges.config file.   Not sure if there is a better solution but this now has me building on my local dev wks and my tfs automated build succeeding as well.

<mybizapp> and <mybizapp>.web pre build event settings
-------------------------------------------------------------------------------------------------------------------
echo processing pre build events for sn=$(SolutionName) pn=$(ProjectName) cn=$(ConfigurationName) bt=$(BuildTarget)
echo relevant properties cn=$(computername) pa=$(processor_architecture) ibmb=$(IsBuildMachineBuild)
echo relevant directories sd=$(SolutionDir) pd=$(ProjectDir)
echo relevant directories td=$(TargetDir) od=$(OutDir)
echo relevant directories cd=%cd% msb=$(MSBuildBinPath) pf=%programfiles% wd=%windir%
for /d %%i in ( . ) do ( set TargetWoSpacesDir=%%~si\)
echo TargetWoSpacesDir=%TargetWoSpacesDir%
rem if /i "$(IsBuildMachineBuild)" == "true" (
  nuget install "$(ProjectDir)packages.config" -o "$(ProjectDir)..\packages" -s https://go.microsoft.com/fwlink/?LinkID=206669;http://mytfs10bm/nuget
  rem nuget install "$(ProjectDir)packages.config" -o "$(ProjectDir)..\packages" -s https://go.microsoft.com/fwlink/?LinkID=206669;http://mytfs10bm/nuget;\\mytfs10bm\NuGetPackages
rem )
rem note1 - this requires setting a < tfs project > | builds | < build definition > | process | advanced | msbuild arguments entry "/p:IsBuildMachineBuild=true"
rem note2 - change "$(IsBuildMachineBuild)" == "true" -> "" to debug this post build event processing using localhost ide build

Aug 29, 2011 at 8:25 PM

Created following issue tracker http://nuget.codeplex.com/workitem/1465 bug for this since silverligth business applications / wcf ria services are now the starting point for many n-tier application efforts.

Aug 31, 2011 at 8:45 AM

You should use the pre-defined property $(BuildingInsideVisualStudio) to distinguish between desktop and team builds.

HTH

Aug 31, 2011 at 5:59 PM
Edited Aug 31, 2011 at 6:11 PM

Thanks for this information.  I don't believe it addresses my primary issue but it does allow me author pre build events w/o having to use the custom $(IsBuildMachineBuild) property.  

Based on what you are saying it appears i could authoring my pre build event if check to contain "if /i "$(BuildingInsideVisualStudio)" == "" (  . . .  ) if i had commands i only wanted executed in the case of tfs automated build, e.g.

<mybizapp> and <mybizapp>.web pre build event settings
-------------------------------------------------------------------------------------------------------------------
echo processing pre build events for sn=$(SolutionName) pn=$(ProjectName) cn=$(ConfigurationName) bt=$(BuildTarget)
echo relevant properties cn=$(computername) pa=$(processor_architecture) bivs=$(BuildingInsideVisualStudio)
echo relevant directories sd=$(SolutionDir) pd=$(ProjectDir)
echo relevant directories td=$(TargetDir) od=$(OutDir)
echo relevant directories cd=%cd% msb=$(MSBuildBinPath) pf=%programfiles% wd=%windir%
for /d %%i in ( . ) do ( set TargetWoSpacesDir=%%~si\)
echo TargetWoSpacesDir=%TargetWoSpacesDir%
rem if /i "$(BuildingInsideVisualStudio)" == "" (
   nuget install "$(ProjectDir)packages.config" -o "$(ProjectDir)..\packages" -s https://go.microsoft.com/fwlink/?LinkID=206669;http://mytfs10bm/nuget
   rem nuget install "$(ProjectDir)packages.config" -o "$(ProjectDir)..\packages" -s https://go.microsoft.com/fwlink/?LinkID=206669;http://mytfs10bm/nuget;\\mytfs10bm\NuGetPackages
rem )
rem note - change "$(BuildingInsideVisualStudio)" == "true" to debug this post build event processing using localhost ide build