Workaround for Nuget Update on BizTalk projects

As mentioned BizTalk and Nuget aren’t a match made in heaven. However until nuget.exe is “fixed” to extend it’s white list to include include btproj files here’s the process I have been following at work to get, update, build and deploy BizTalk solutions on my development machine.

It’s a little unusual maybe but we like to update all our nuget packages (internal and external) continuously whilst we are in the development phase of the project rather than have many different versions of assemblies in the GAC.  Some of our solutions haven’t been touched for a few months as their development is complete however we don’t want them to get old and out of date, especially as some of the internal packages change frequently.

We obviously run our test suite often to check that the update of the packages hasn’t broken anything.

So anyway here are the steps we perform per solution -

  1. Perform a Nuget restore on the solution
  2. Loop through all projects in the solution and rename BizTalk project files (.btproj) to  C# Project files (.csproj)
  3. Perform a Nuget Update on each BizTalk project
  4. Rename the projects back
  5. Perform a Nuget update on the solution (as this will update all non-BizTalk projects)

Step 3 is important. Due to the project file now having a csproj extension it is no longer the file being referenced in your solution file so if you want the package.config file and the project files hint path to be updated correctly you will need to perform a nuget update specifying the project name.

We’re not that sophisticated on our dev machines and just have a command file which has developed over time.  Below is the actual script we call for each solution, called NugetUpdateBTProjects.cmd.

Before this script we un-deploy all our BizTalk applications, clear the GAC/bin/obj & Nuget package directories. After this script we deploy all of our BizTalk apps using the BizTalk Deployment Framework which re-GACs our assemblies including the nuget package assemblies.

We call this script from a larger script like this -

call NugetUpdateBTProjects.cmd NameOfYourSolutiuon

@echo off

..\..\nuget.exe restore %1

for /R %%f in (*.btproj) do CALL:renameAndUpdate %%f %%~nf %%~df%%~pf

goto end

:renameAndUpdate

SET FROMFILE=%1

SET TOFILE=%2.csproj

@echo rename from %FROMFILE% to %TOFILE% so Nuget update works for Biztalk projects

rename  %FROMFILE%  %TOFILE%

@echo Perform Nuget Update

..\..\nuget.exe update %3%TOFILE%

@echo rename back from %3%TOFILE%  to %2.btproj

rename  %3%TOFILE%  %2.btproj

:end

Not rocket science but it seems to be a quick way round the problem with btproj files. Invoking the powershell script as if you we’re in Visual Studio may be another solution but this suited our needs best

This article is part of the GWB Archives. Original Author: Paul Nichols

New on Geeks with Blogs