Showing posts with label MSBuild. Show all posts
Showing posts with label MSBuild. Show all posts

Wednesday, May 02, 2012

Wednesday Quickie - Getting rid of those darned connection string parameters

This quickie relates to the parameters used by MSDeploy to transform your web.config when a web application or site is deployed.

By default the deployment targets (Microsoft.Web.Publishing.targets) used when building a deployment package for a web app will automatically generate entries for connection strings. The problem is that it chooses really awful tag names for the parameters - for example:






This gave me a problem as the configuration system we use at Landmark to deploy our web apps can't have any spaces in its parameter tags. Fortunately, there's a quick solution.


It's easy enough to add a Parameters.xml file to your project to provide custom parameters - and in that file it's trivial to include a duplicate connection string parameter definition (that doesn't have spaces in the name).


The final part of the puzzle is to prevent the deployment targets from creating the default connection string entries on build. This is achieved by passing in the following (memorably-named) MSBuild parameter:
/parameter:AutoParameterizationWebConfigConnectionStrings=False
The deployment targets no longer add the connection string parameters by default, so you have to do so explicitly in your Parameters.xml file - but now YOU control the parameter name. Done.



Wednesday, April 25, 2012

Wednesday Quickie - Building Lightswitch Projects in TFS

So I've been fighting with getting my Lightswitch application to build under TFS as part of our (slow) move towards Continuous Build / Continuous Deployment at work... and for weeks I've been banging my head against the wall with the deaded "UnpackExtensionsToProjectDir" error.

And then came the revelation... looking a couple of lines down I found that the real error was being masked - looking at the detailed logs we can see the real culprit:


C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets(1257,9): error MSB4018: The "UnpackExtensionsToProjectDir" task failed unexpectedly.
<SNIP>
[C:\Builds\4\MyApp\Trunk\Sources\Authentication\MyApp.LightswitchApp\MyApp.LightswitchApp.lsproj]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets(1257,9): error MSB4018:    at Microsoft.LightSwitch.ExtensionsReader.ExtensionInformationService.ExtensionInformation.LSPKGPackage.ExtensionDirectoryDeletionFailedAction(IServiceProvider serviceProvider, String directory) [C:\Builds\4\MyApp\Trunk\Sources\Authentication\MyApp.LightswitchApp\MyApp.LightswitchApp.lsproj]
<SNIP> 
[C:\Builds\4\MyApp\Trunk\Sources\Authentication\MyApp.LightswitchApp\MyApp.LightswitchApp.lsproj]Done Building Project "C:\Builds\4\MyApp\Trunk\Sources\Authentication\MyApp.LightswitchApp\MyApp.LightswitchApp.lsproj" (default targets) -- FAILED.Done Building Project "C:\Builds\4\MyApp\Trunk\Sources\Authentication\MyApp.LightswitchApp\MyApp.LightswitchApp.lsproj.metaproj" (default targets) -- FAILED.
By looking at the Microsoft.Lightswitch.targets file, I found that the actual error was that the build process couldn't delete the _Pvt_Extensions directory.


A quick check showed that that particular directory had been added to TFS source control - removing it and the deaded "UnpackExtensionsToProjectDir" error was finally vanquished. (OK - there were a couple of other build errors, but they were easily fixed).

So now I have a green tick beside my Lightswitch application in TFS Build Explorer - WIN!

Tomorrow, my next challenge - getting the thing packaged for MSDeploy deployment.