Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature allowing creation of missing folders on the target. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ param(
[string]$WsPassword,
[string]$UseVerbose,
[string]$OverrideExisting,
[string]$AddResourceExtension
[string]$AddResourceExtension,
[string]$CreateMissingFolders
)
function Verbose-WriteLine{
[cmdletbinding()]
Expand All @@ -40,6 +41,43 @@ param(
#$Host.UI.RawUI.BackgroundColor = $oldBackColor;
}
}


function Create-MissingFolders{
[cmdletbinding()]
param(
[Parameter(Position=1)]$uploadRootPath
)

$uploadRootPathItem = $ssrs.ListChildren("/", $true) | Where-Object {$_.Path -eq $uploadRootPath -and $_.TypeName -eq "Folder"}

if($uploadRootPathItem -eq $null)
{
$rootFolder = '/'

$uploadRootPath.Split('/') | Where-Object {$_.Length -gt 0} | ForEach-Object {
$folderName = $_
$existingFolder = $ssrs.ListChildren($rootFolder, $true) | Where-Object {$_.TypeName -eq "Folder" -and $_.Name -eq $folderName}

if($existingFolder -eq $null)
{
Write-Host "Creating $folderName in $rootFolder"
$ssrs.CreateFolder($folderName, $rootFolder, $null)
}
if($rootFolder -eq '/')
{
$rootFolder += $folderName
}
else
{
$rootFolder += "/$folderName"
}
}
}
}



##########################################################
# SETUP OF CODE #
##########################################################
Expand Down Expand Up @@ -134,8 +172,15 @@ param(

$rdsFiles = @(Get-ChildItem $DataSourceLocalPath);
$rdsFileCount = $rdsFiles.Length;
if($IncludeDataSource -eq $true){ #Update the datasources
Write-Host "Updating $rdsFileCount datasource files to $WebserviceUrl ($ReportUploadRootPath)...";
if($IncludeDataSource -eq $true){

if($CreateMissingFolders -eq $true)
{
Create-MissingFolders $DataSourceRootPath
}

#Update the datasources
Write-Host "Updating $rdsFileCount datasource files to $WebserviceUrl ($DataSourceRootPath)...";
$rdsFiles | ForEach-Object{
$datasourceName = $_.FullName;
Write-Host "Uploading datasource $datasourceName to $DataSourceRootPath...";
Expand Down Expand Up @@ -173,6 +218,12 @@ param(
$rsdFiles = @(Get-ChildItem $DataSetLocalPath);
$rsdFileCount = $rsdFiles.Length;
if($IncludeDataSet -eq $true){

if($CreateMissingFolders -eq $true)
{
Create-MissingFolders $DataSetRootPath
}

Write-Host "Uploading $rsdFileCount Dataset files";
$rsdFiles | ForEach-Object {
$datasetName = $_.FullName;
Expand Down Expand Up @@ -216,6 +267,12 @@ param(
##########################################################

if($IncludeResources -eq $true){

if($CreateMissingFolders -eq $true)
{
Create-MissingFolders $ResourceRootPath
}

Add-Type -AssemblyName "System.Web";
ForEach($item in @($ResourcePatterns.Split("`n"))){
Write-Warning $item;
Expand Down Expand Up @@ -272,6 +329,11 @@ param(
$fileCount = $files.Length;
Verbose-WriteLine "Found $fileCount items in $ReportFiles";

if($CreateMissingFolders -eq $true)
{
Create-MissingFolders $ReportUploadRootPath
}

Write-Host "Uploading $fileCount files to $WebserviceUrl ($ReportUploadRootPath)...";
#Itterate over all files and append them to a catalogitem
$files | ForEach-Object{
Expand Down
11 changes: 10 additions & 1 deletion SqlReportingServices/SqlReportingServicesDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"version": {
"Major": "1",
"Minor": "4",
"Patch": "3"
"Patch": "4"
},
"minimumAgentVersion": "1.95.0",
"instanceNameFormat": "Deploy SQL Server reporting files",
Expand Down Expand Up @@ -228,6 +228,15 @@
"defaultValue": false,
"groupName": "advanced",
"helpMarkDown": "Enable or disable verbose logging"
},
{
"name": "CreateMissingFolders",
"type": "boolean",
"label": "Create Missing Folders",
"required": false,
"defaultValue": false,
"groupName": "advanced",
"helpMarkDown": "Enable or disable creation of missing folders on the target"
}

],
Expand Down
2 changes: 1 addition & 1 deletion SqlReportingServices/vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "SqlReportngServices",
"name": "SQL Server Reporting Services Deployment",
"version": "1.5.3",
"version": "1.5.4",
"publisher": "tobania",
"targets": [
{
Expand Down