Install.ps1 not running for multiple projects.

Topics: General
Feb 8, 2013 at 7:49 AM
Hi all,

Have someone experienced such an issue, that the install.ps1 is running only for one project in the solution, while trying to add the package to multiple projects?

I have created a package and published it in a private repository. The package contains a script updating the configuration file with a version of EntLib installed with it.

When I create a sample solution consisting of a class library and a web app, after installing the package for both projects, the version is updated only for the first project added to the solution (in this case in the class library). If You would start with the web app and then add the class library and install the package for both of them, only the web app would have versions inserted into the config file.

The script looks as follows:
param($installPath, $toolsPath, $package, $project)
function Get-AssemblyVersion ($AssemblyName) { ($assemblies | Where {$_.Name -eq $AssemblyName } | Select-Object Version).Version }
function Set-AssemblyVersion ($AssemblyVersion) { $versionString = " Version=$AssemblyVersion"; $versionString; }
function Set-ElementTypeContent ($TypeValues) { $var = ""; $count = 1; Foreach ($string in $TypeValues) { $var += $string; if($count -lt $TypeValues.Count) { $var += ',' }; $count++; } $var; }
function Manipulate-ConfigurationFileContentNode ($Node, $ParamIndex) { $typeValues = $Node.Node.Attributes.Item($ParamIndex).Value.Split(','); $typeValues[2] = Set-AssemblyVersion (Get-AssemblyVersion $typeValues[1].TrimStart()); $Node.Node.Attributes.Item($ParamIndex).Value = Set-ElementTypeContent $typeValues; }
function Manipulate-ConfigurationFileContent ($XDoc, $XPath, $ParamIndex) { Microsoft.PowerShell.Utility\Select-Xml $XDoc -XPath $XPath | Foreach { Manipulate-ConfigurationFileContentNode $_ $ParamIndex } }
function Manipulate-ConfigurationFile ($XMLPath) { If([System.IO.File]::Exists($XMLPath)) { $XMLDoc = [xml](Get-Content $XMLPath); Manipulate-ConfigurationFileContent $XMLDoc "/configuration/configSections/section" 1; Manipulate-ConfigurationFileContent $XMLDoc "/configuration/loggingConfiguration/listeners/add" 1; Manipulate-ConfigurationFileContent $XMLDoc "/configuration/loggingConfiguration/listeners/add" 2; Manipulate-ConfigurationFileContent $XMLDoc "/configuration/loggingConfiguration/formatters/add" 1; Manipulate-ConfigurationFileContent $XMLDoc "/configuration/exceptionHandling/exceptionPolicies/add/exceptionTypes/add/exceptionHandlers/add" 1; Manipulate-ConfigurationFileContent $XMLDoc "/configuration/exceptionHandling/exceptionPolicies/add/exceptionTypes/add/exceptionHandlers/add" 6; $XMLDoc.Save($XMLPath); } }
$projectItem = (Get-Project).FullName | Get-Item
$assemblies = ((Get-Project).Object.References | Select-Object Name,Version)
$FilePath = $projectItem.DirectoryName + "\app.config"
Manipulate-ConfigurationFile $FilePath
$FilePath = $projectItem.DirectoryName + "\Web.config"
Manipulate-ConfigurationFile $FilePath
I would be grateful for any hints on this case.
Thanks in advance.

Cheers,
Michal