This article explains how to Upload/Deploy the multiple RDL files from local machine to ReportManager. We can Upload/Deploy multiple RDL files at a time using RS.exe
utility. RS.exe utility is a command line utility that can perform many
scripted operation related to SQL Server Reporting Services (SSRS).
Note: Rs.exe file path will change based on the SQL Server/SSRS version
EXE file is located any one of the below locations (Based on SQL Server/SSRS Version):
For 64 Bit: \Program Files\Microsoft SQL Server\100\Tools\Binn
For 32 Bit:
\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn
OR
For 64 Bit: \Program Files\Microsoft SQL Server\110\Tools\Binn
For 32 Bit: \Program Files (x86)\Microsoft SQL Server\110\Tools\Binn
OR
For 64 Bit: \Program Files\Microsoft SQL Server\120\Tools\Binn
For 32 Bit: \Program Files (x86)\Microsoft SQL Server\120\Tools\Binn
For this process we need to prepare three files
- Script
File (For uploading all RDL Files)
- Configuration file (We need to specify the "Local folder path and ReportManager folder path")
- Batch
file (To execute the RS.exe based on script present in the script file)
1. Script
to prepare ScriptFile (Copy
the below script and past it in text file and save with the name and extension
as “Upload_Multiple_RDL_files.rss”):
'Script Starting Point
' Script to deploy report to report server
' EXECUTE VIA COMMAND LINE
DIM definition As [Byte]() = Nothing
DIM warnings As Warning() = Nothing
Public Sub Main()
' Variable Declaration
Dim TextLine As String = ""
Dim LocalDir As String = ""
Dim ServerDir As String = ""
Dim definition As [Byte]() = Nothing
'Dim warnings As Warning() = Nothing
' Reading Configuration Text file and assigning the values to variables
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
Dim parts As String() = TextLine.Split(New Char() {","c})
'TextLine & objReader.ReadLine() '& vbNewLine
LocalDir = parts(0)
ServerDir = parts(1)
Dim path As String = LocalDir
Dim fileEntries As String() = Directory.GetFiles(path)
Dim fileFullPath As String = ""
For Each fileFullPath In fileEntries
' Deploying the Reports
Try
Dim stream As FileStream = File.OpenRead(fileFullPath)
Dim NameWithExt As String = fileFullPath.Replace(path, "")
Dim NameOnly As String = NameWithExt.Replace(".rdl", "")
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
warnings = rs.CreateReport(NameOnly, ServerDir, True, definition, Nothing)
If Not (warnings Is Nothing) Then
DIM warning As Warning
For Each warning In warnings
Console.WriteLine(warning.Message)
Next warning
Else
Console.WriteLine("Report: {0} PUBLISHED!", NameOnly)
End If
Catch e As IOException
Console.WriteLine(e.Message)
End Try
Next fileFullPath
Loop
Else
Dim MsgBox as String = "File Does Not Exist"
End If
End Sub
'End of the Script
2. Configuration file: In this file we need to specify the source folder path (where the RDL files are located) and Target (ReportServer path, to where we need to upload the RDL files) with comma separate. Please refer the below attached images.
In this example, i have RDL files in two different folders and i want to upload them into different target folders in the report server.
Local Machine Path:
C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Upload_Multiple_RDL_Files\SSRS\SalesReports\
C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Upload_Multiple_RDL_Files\SSRS\Aggregate\
Report Server Path:
/SSRS/SalesReports
/SSRS/Aggregate
3. Command to prepare BatchFile (Copy the below command and past it in text file and save with the name and extension as “UploadRDLFiles.bat”):
Note: Verify the rs.exe file path in your Machine and Update the below path if the file is present in different location.
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\rs.exe" -i C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Upload_Multiple_RDL_Files\Upload_Multiple_RDL_files.rss -s "http://admin-pc:8080/ReportServer" -v FILE_NAME="C:\Kiran\Technology\SQLServer\SSRS\DeploymentScript\Upload_Multiple_RDL_Files\ConfigurationFile.txt"
Pause
After preparing the three files (Script File, Configuration file and Batch File), edit the batch file and update the "Rs.exe file path, .RSS script file path, ReportServer URL, and Configuration file path".
- Rs.exe file path: Update with the Rs.exe file path (file is located at \Program Files\Microsoft SQL Server\110\Tools\Binn)
- .RSS script file path: Update with the .rss script file path (where we placed the ScriptFile "Upload_Multiple_RDL_files.rss" file).
- ReportServer URL: Update with the required ReportServer URL (To where we need to upload the RDL files).
- Configuration file path: Update the file with required source and targets paths.
Sample Screenshot of the files:
After Updating the Script and Batch files, double click on the batch file then execution will start.
Note: We are uploading/Deploying only RDL files, so we may receive
the below message. We can ignore that.
Message:
The dataset “<<Dataset name>>” refers to the
shared data source “<<Dataset name>>”, which is not published on
the report server. The shared data source “<<Dataset name>>” must
be published before this report can run.
Note: If the Reports are referring to share data sources those may not work, if so edit RDL files Data source from report manager and updated with appropriate Data source.
See Also:
Download the all RDL files from ReportManager (Using RS.exe Utility)