Create NuGet package to add silverlight apps to web application

Topics: General
Jul 17, 2012 at 5:25 PM

We have a silverlight application that contains a plethora of silverlight plugins; each plugin is its own Solution and Project file. To test the plugin each solution has a web application. We have a common "loader.xap" which is the host silverlight applicaiton that dynamically loads the respective plugin. This means I need to shove the "loader.xap" into each of the plethora of plugin web sites.

This sounds like a natural job for NuGet; I created a package with my loader.xap file in a "content\ClientBin" folder; I enabled "NuGet Package Restore" on each plugin solution.  

I really don't want the loader.xap commited to TFS for each plugin. I would rather have package restore to copy the loader.xap back to ClientBin when the solution is built on a desktop or a build server.

I tried to create a install.ps1, however PowerShell is very new to me; It appears to not be called during a restore

param($installPath, $toolsPath, $package, $project)

$packageClientLibFolder = Join-Path $installPath Content\ClientLib

# Determine the project ClientLib folder path
$projectFolderPath = $project.Properties.Item("FullPath").Value
$projectClientLibFolderPath = Join-Path $projectFolderPath ClientLib

# Copy the MainContent.xaml file to the project from the content ClientLib folder
$mainContentFileSourcePath = Join-Path $projectClientLibFolderPath "MainContent.xaml"
try {
    Copy-Item $mainContentFileSourcePath $projectClientLibFolderPath
}
catch {
    # This will throw if the file already exists, so we need to catch here
}

# Copy the Wam.Framework.Loader.xap file to the project from the content ClientLib folder
$loaderFileSourcePath = Join-Path $projectClientLibFolderPath "Wam.Framework.Loader.xap.js"
try {
    Copy-Item $loaderFileSourcePath $projectClientLibFolderPath
}
catch {
    # This will throw if the file already exists, so we need to catch here
}

Am I expecting too mucy, am I just doing it wrong.
Any help appreciated!
Thanks
Jay
Jul 17, 2012 at 10:16 PM

When package restore executes, all it does it to re-download the package (.nupkg files) and put them under the 'packages' folder. Package restore does NOT re-copy content files into your projects, nor does it execute PS scripts. Therefore, you PS script is NOT called at all.