From a20bf90e8bc19b874a2dc18f704d12034faf2d43 Mon Sep 17 00:00:00 2001 From: Chad Liu Date: Tue, 11 Jun 2019 10:29:55 +1000 Subject: [PATCH 1/4] fix the glitch when there's only one RDS or RDL file in the folder --- .../SSRS/Publish-SSRSProject.ps1 | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 index 77d64ef..8b1a93c 100644 --- a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 +++ b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 @@ -140,7 +140,7 @@ New-SSRSFolder -Proxy $Proxy -Name $DataSetFolder $DataSourcePaths = @{} - for($i = 0; $i -lt $Project.Project.ItemGroup[0].DataSource.Count; $i++) { + for($i = 0; $i -lt ([array]$Project.Project.ItemGroup[0].DataSource).Count; $i++) { $RdsPath = $ProjectRoot | Join-Path -ChildPath $Project.Project.ItemGroup[0].DataSource[$i].Include $DataSource = New-SSRSDataSource -Proxy $Proxy -RdsPath $RdsPath -Folder $DataSourceFolder -Overwrite $OverwriteDataSources @@ -157,14 +157,16 @@ $DataSetPaths.Add($DataSet.Name, $DataSet.Path) } } + + $ReportsArray = [array] $Project.Project.ItemGroup[1].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 +181,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 } } From 0f044e960f79d4cc4903ae6b49b76404cf13c31e Mon Sep 17 00:00:00 2001 From: Chad Liu Date: Tue, 11 Jun 2019 10:39:05 +1000 Subject: [PATCH 2/4] fix the RDS iteration too --- ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 index 8b1a93c..e75d0b0 100644 --- a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 +++ b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 @@ -139,9 +139,11 @@ New-SSRSFolder -Proxy $Proxy -Name $DataSourceFolder New-SSRSFolder -Proxy $Proxy -Name $DataSetFolder + $DataSourceArray = [array] $Project.Project.ItemGroup[0].Report + $DataSourcePaths = @{} - for($i = 0; $i -lt ([array]$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) From 752850c0713f5a2e7447782b048201e6449311bd Mon Sep 17 00:00:00 2001 From: Chad Liu Date: Tue, 11 Jun 2019 10:41:49 +1000 Subject: [PATCH 3/4] fix glitch --- ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 index e75d0b0..4d1b458 100644 --- a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 +++ b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 @@ -139,7 +139,7 @@ New-SSRSFolder -Proxy $Proxy -Name $DataSourceFolder New-SSRSFolder -Proxy $Proxy -Name $DataSetFolder - $DataSourceArray = [array] $Project.Project.ItemGroup[0].Report + $DataSourceArray = [array] $Project.Project.ItemGroup[0].DataSource $DataSourcePaths = @{} for($i = 0; $i -lt $DataSourceArray.Count; $i++) { From 2aee5cf13e1d5ee1e077e12ed59a229f748fe6c1 Mon Sep 17 00:00:00 2001 From: Chad Liu Date: Fri, 14 Jun 2019 14:57:46 +1000 Subject: [PATCH 4/4] fix itemgroup order and overwrite flag --- .../SSRS/Get-SSRSProjectConfiguration.ps1 | 5 +++-- ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) 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 4d1b458..63f3882 100644 --- a/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 +++ b/ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1 @@ -138,8 +138,13 @@ 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[0].DataSource + $DataSourceArray = [array] $Project.Project.ItemGroup[$DataSourceIndex].DataSource $DataSourcePaths = @{} for($i = 0; $i -lt $DataSourceArray.Count; $i++) { @@ -150,9 +155,9 @@ } $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)) { @@ -160,7 +165,7 @@ } } - $ReportsArray = [array] $Project.Project.ItemGroup[1].Report + $ReportsArray = [array] $Project.Project.ItemGroup[$reportIndex].Report for($i = 0; $i -lt $ReportsArray.Count; $i++) {