diff --git a/ssrs-powershell-deploy/SSRS/Get-SSRSProjectConfiguration.ps1 b/ssrs-powershell-deploy/SSRS/Get-SSRSProjectConfiguration.ps1 index 6047d89..8f48fd3 100644 --- a/ssrs-powershell-deploy/SSRS/Get-SSRSProjectConfiguration.ps1 +++ b/ssrs-powershell-deploy/SSRS/Get-SSRSProjectConfiguration.ps1 @@ -41,16 +41,17 @@ $OverwriteDataSources = $false - if ($Config.SelectSingleNode('OverwriteDataSources')) { + if ($Config.OverwriteDataSources -eq "True") { $OverwriteDataSources = [Convert]::ToBoolean($Config.OverwriteDataSources) } $OverwriteDatasets = $false - if ($Config.SelectSingleNode('OverwriteDatasets')) { + if ($Config.OverwriteDatasets -eq "True") { $OverwriteDatasets = [Convert]::ToBoolean($Config.OverwriteDatasets) } + return New-Object -TypeName PSObject -Property @{ ServerUrl = $Config.TargetServerUrl Folder = Normalize-SSRSFolder -Folder $Config.TargetReportFolder diff --git a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 index 77d64ef..63f3882 100644 --- a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 +++ b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 @@ -138,33 +138,42 @@ New-SSRSFolder -Proxy $Proxy -Name $Folder New-SSRSFolder -Proxy $Proxy -Name $DataSourceFolder New-SSRSFolder -Proxy $Proxy -Name $DataSetFolder + + switch ($Project.Project.ItemGroup.Length) { + "3" {$DataSourceIndex=1;$reportIndex=2} + "2" {$DataSourceIndex=0;$reportIndex=1} + } + $DataSourceArray = [array] $Project.Project.ItemGroup[$DataSourceIndex].DataSource + $DataSourcePaths = @{} - for($i = 0; $i -lt $Project.Project.ItemGroup[0].DataSource.Count; $i++) { - $RdsPath = $ProjectRoot | Join-Path -ChildPath $Project.Project.ItemGroup[0].DataSource[$i].Include + for($i = 0; $i -lt $DataSourceArray.Count; $i++) { + $RdsPath = $ProjectRoot | Join-Path -ChildPath $DataSourceArray[$i].Include $DataSource = New-SSRSDataSource -Proxy $Proxy -RdsPath $RdsPath -Folder $DataSourceFolder -Overwrite $OverwriteDataSources $DataSourcePaths.Add($DataSource.Name, $DataSource.Path) } $DataSetPaths = @{} - $Project.SelectNodes('Project/DataSets/ProjectItem') | + $Project.Project.ItemGroup.selectNodes("*") | Where-Object {$_.Include -like "*.rsd"} | ForEach-Object { - $RsdPath = $ProjectRoot | Join-Path -ChildPath $_.FullPath + $RsdPath = $ProjectRoot | Join-Path -ChildPath $_.Include $DataSet = New-SSRSDataSet -Proxy $Proxy -RsdPath $RsdPath -Folder $DataSetFolder -DataSourcePaths $DataSourcePaths -Overwrite $OverwriteDatasets if(-not $DataSetPaths.Contains($DataSet.Name)) { $DataSetPaths.Add($DataSet.Name, $DataSet.Path) } } + + $ReportsArray = [array] $Project.Project.ItemGroup[$reportIndex].Report - for($i = 0; $i -lt $Project.Project.ItemGroup[1].Report.Count; $i++) { + for($i = 0; $i -lt $ReportsArray.Count; $i++) { - $extension = $Project.Project.ItemGroup[1].Report[$i].Include.Substring($Project.Project.ItemGroup[1].Report[$i].Include.length - 3 , 3) + $extension = $ReportsArray[$i].Include.Substring($ReportsArray[$i].Include.length - 3 , 3) if(ImageExtensionValid -ext $extension){ - $PathImage = $ProjectRoot | Join-Path -ChildPath $Project.Project.ItemGroup[1].Report[$i].Include + $PathImage = $ProjectRoot | Join-Path -ChildPath $ReportsArray[$i].Include $RawDefinition = Get-Content -Encoding Byte -Path $PathImage $DescProp = New-Object -TypeName SSRS.ReportingService2010.Property @@ -179,17 +188,17 @@ $Properties = @($DescProp, $HiddenProp, $MimeProp) - $Name = $Project.Project.ItemGroup[1].Report[$i].Include + $Name = $ReportsArray[$i].Include Write-Verbose "Creating resource $Name" $warnings = $null - $Results = $Proxy.CreateCatalogItem("Resource", $Project.Project.ItemGroup[1].Report[$i].Include, $Folder, $true, $RawDefinition, $Properties, [ref]$warnings) + $Results = $Proxy.CreateCatalogItem("Resource", $ReportsArray[$i].Include, $Folder, $true, $RawDefinition, $Properties, [ref]$warnings) } } - for($i = 0; $i -lt $Project.Project.ItemGroup[1].Report.Count; $i++) { - if($Project.Project.ItemGroup[1].Report[$i].Include.EndsWith('.rdl')){ - $CompiledRdlPath = $ProjectRoot | Join-Path -ChildPath $OutputPath | join-path -ChildPath $Project.Project.ItemGroup[1].Report[$i].Include - New-SSRSReport -Proxy $Proxy -RdlPath $CompiledRdlPath -RdlName $Project.Project.ItemGroup[1].Report[$i].Include + for($i = 0; $i -lt $ReportsArray.Count; $i++) { + if($ReportsArray[$i].Include.EndsWith('.rdl')){ + $CompiledRdlPath = $ProjectRoot | Join-Path -ChildPath $OutputPath | join-path -ChildPath $ReportsArray[$i].Include + New-SSRSReport -Proxy $Proxy -RdlPath $CompiledRdlPath -RdlName $ReportsArray[$i].Include } }