0
votes

I have a Visual Studio 2019 project that I made using Report Server Project Wizard. In this project, I import reports (.rdl) files from a different report server project. To add a report, I right click on the project in the solution explorer and do Add > Existing Item and then choose the .rdl file and then it gets included in the project. Is there any way to include the reports (.rdl) files programmatically in the project? For example, can I create a C# console app to copy (.rdl) files from one report server project and then actually add them into a different report server project. Simple copying and pasting .rdl files from one project to another is not working - the file even after it is pasted doesn't show up in the project.

I have tried using EnvDTE to access the solution and project objects, but all the online sources, such as this - https://flylib.com/books/en/3.50.1.50/1/, that provide info on EnvDTE have example code written in VB and it shows you how to create a new solution and project objects and then add a file. What I want is programmatically access the object of the current(existing) report server project and somehow programmatically add .rdl files from another folder into this project. Is that possible?

Thanks

1

1 Answers

0
votes

Unless you have hundreds of projects, I can't see the point of building something that is pretty easy to do anyway. You can select multiple files when you do "Add Existing Item".

Having said that, all you need to do is copy the file to the target project folder and then add an entry into the project file in an item group

e.g.

 <ItemGroup>
    <Report Include="My First Report.rdl" />
    <Report Include="My Second Report.rdl" />
 <ItemGroup> 

You could probably get away with processing this as a simple text file.