如何在 Microsoft SQL Server 2005 Reporting Services 中的多个项目之间共享数据源并保持 Visual Studio“预览"?

问题描述:

我有一个包含多个报表项目的解决方案(每个目标部署文件夹一个 - 我认为这是实现这种效果的唯一方法,至少在我放弃 Visual Studio 进行报表部署之前).

I have a solution that contains multiple reporting projects (one per target deployment folder - I think this is the only way to achieve this effect, at least until I abandon Visual Studio for report deployment).

我想为所有这些报告一次且仅一次"指定我的数据源信息.

I want to specify my data source information "once and only once" for all these reports.

到目前为止,我已经创建了一个单独的报告项目,其中包含我的共享数据源.如果我以正确的顺序将事物部署到报告服务器并向适当的神提供足够的祈祷,报告似乎会链接到那里的共享数据源并运行(至少通过 IE 中的报告管理器).

So far, I have created a separate reporting project that contains my shared data source. If I deploy things to a reporting server in the right order and offer sufficient prayers to appropriate gods, the reports seem to link up to the shared data source there and run (at least via the Report Manager in IE).

但是,当我开发报表时,我不能再预览"以在本地试用它 - 我现在必须将它部署到报表服务器以尝试运行它.这很麻烦.

When I am developing a report, though, I can no longer "Preview" to try it out locally - I now must deploy it to a report server to try running it. This is a hassle.

我是否唯一的办法是添加一大堆数据源副本(指向我的开发数据库),在每个项目中添加一个副本,将它们设置为不部署在我的机器上,并且(可能)将它们从源代码控制中排除?

Is my only recourse to add a whole bunch of copies of a data source (pointing at my development database), one in each project, set those not to deploy off my machine, and (probably) exclude them from source control?

我现在玩的一个技巧(肮脏的把戏?)是将我的数据源(.rds)复制到每个项目中,关闭 Visual Studio,然后在基础文件/文件夹中:

A technique (dirty trick?) I am playing with now is to copy my data source (.rds) into each project, close Visual Studio, then in the underlying files/folders:

  • 从我的报表项目中删除复制的.rds(在我的Data Sources 项目中只留下一份)
  • 在每个报表项目的项目文件 (Foo.rptproj) 中,更改 My Shared Data Source 中的 Project.DataSources.ProjectItem.FullPath 元素的文本.rds..\Data Sources\My Shared Data Source.rds
  • Delete the copied .rds from my report projects (leaving only the one copy in my Data Sources project)
  • In each report project's project file (Foo.rptproj), change the text of the Project.DataSources.ProjectItem.FullPath element from My Shared Data Source.rds to ..\Data Sources\My Shared Data Source.rds

通过这种方式,所有报告项目都引用文件系统上相同的底层文件,因此它们共享一个数据源定义,但每个项目也都有一个本地"共享数据源,因此 Visual Studio 很满意.

This way all reporting projects reference the same underlying file on the filesystem, so they share a single data source definition, but each project also kind of has a "local" shared data source, so Visual Studio is kept happy.

关于源代码控制:仍然只有一个 .rds 的副本被签入,所以我们不会用大量令人讨厌的重复项污染代码库;可以检入对 .rptproj 文件的更改,因此我们不会强迫开发人员进行不自然的源代码控制(选择性部分提交等)以维护一个健全的主副本.

Regarding source control: there is still only one copy of the .rds checked in, so we're not polluting the code base with lots of icky duplicates; the changes to the .rptproj files can be checked in, so we're not forcing developers into unnatural source-control gymnastics (selective partial commits etc.) to maintain a sane master copy.

每个报表项目都会尝试部署这个数据源,虽然我已经禁止覆盖服务器上现有的数据源,所以这没什么大不了的...我想如果我打算覆盖服务器的数据源定义,我是否用相同的 .rds 覆盖它一次或十次并不重要.

Each reporting project will try to deploy this data source, though I've forbidden the overwriting of existing data sources on the server, so it's not too big a deal . . . and I suppose if I intended to overwrite the server's data source definition, it wouldn't really matter whether I overwrote it once or ten times with the same .rds.

免责声明:这仍然是一个实验.我还没有在实践中使用这种技术的经验,所以我不能真正推荐它.

Disclaimer: this is still an experiment. I don't have experience using this technique in practice yet, so I can't go so far as to actually recommend it.