MSBuild 使用错误版本的程序集来编译 RDLC 文件
我正在使用 VS 2010 中的 reportviewer 控件来创建客户端报告 (rdlc)。在我的开发机器上一切正常,当我手动编译(通过 VS2010)并手动部署到没有安装开发工具的测试机器时。
为了让测试机正常工作(无需安装 VS2010 或 ReportViewer.exe),我必须在项目中添加对 Microsoft.ReportViewer.Winforms、Microsoft.ReportViewer.Common 和 Microsoft.ReportViewer.ProcessingModel 的引用,并将它们全部添加到“复制本地”。
我已经为构建操作配置了 rdlc 文件 =>嵌入式资源。这是向项目添加新 rdlc 时的默认设置。我愿意配置这个,否则如果这可以解决这个问题(不知道它是否相关)。
问题:自从添加 rdlc 文件后,解决方案不再在构建服务器上构建。我已在生成服务器上安装了 ReportViewer.exe,并验证了 GAC 中是否存在所需的程序集。 .Net 4 框架未安装在构建服务器上——我认为这不是必需的,因为该解决方案针对的是 3.5 运行时。
我认为问题的根源在于构建日志中的以下内容:
目标“RunRdlCompiler”:构建 完全针对“RunRdlCompiler”。 输出文件 “obj\Release\RdlCompile.compiled”确实 不存在。使用“RdlCompile”任务 从装配 “微软.ReportViewer.Common, 版本=9.0.0.0,文化=中立, PublicKeyToken=b03f5f7f11d50a3a”。任务 “Rdl编译”: 报告\RDLC\GreenReport.rdlc (0,0): 错误 rsInvalidReportDefinition: 报告定义无效。 详细信息:报告定义有一个 无效的目标命名空间 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/报告定义' 无法升级。
据我所知,Microsoft.ReportViewer.Common 版本 10.0.0.0 应该用于“编译”rdlc,但 MSBuild 似乎使用 9.0.0.0。我相信,如果我可以强制它使用正确的版本(安装在 GAC 中),解决方案就能编译。
I am using the reportviewer control from VS 2010 to create client side reports (rdlc). Everything is working fine on my development machine, and when I manually compile (via VS2010) and manually deploy to a test machine that doesn't have development tools installed.
In order to get the test machine to work (without installing VS2010 or ReportViewer.exe), I had to add references in my project to Microsoft.ReportViewer.Winforms, Microsoft.ReportViewer.Common and Microsoft.ReportViewer.ProcessingModel and have them all "Copy Local".
I have the rdlc files configured for Build Action => embedded resources. This is the default setting when adding a new rdlc to the project. I am open to configuring this otherwise if this would resolve this problem (no idea if its related).
The problem: since adding the rdlc files, the solution no longer builds on the build server. I have installed ReportViewer.exe on the build server, and have verified that the required assemblies exist in the GAC. The .Net 4 framework is NOT installed on the build server--I don't think this is required because the solution targets the 3.5 runtime.
I believe the root of the problem is the following from the build log:
Target "RunRdlCompiler": Building
target "RunRdlCompiler" completely.
Output file
"obj\Release\RdlCompile.compiled" does
not exist. Using "RdlCompile" task
from assembly
"Microsoft.ReportViewer.Common,
Version=9.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a". Task
"RdlCompile":
Report\RDLC\GreenReport.rdlc (0,0):
error rsInvalidReportDefinition: The
report definition is not valid.
Details: The report definition has an
invalid target namespace
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'
which cannot be upgraded.
From what I can tell, Microsoft.ReportViewer.Common version 10.0.0.0 is what should be used to "compile" the rdlc, but MSBuild appears to be using 9.0.0.0. I believe if I could force it to use the right version (which IS installed in the GAC), the solution would compile.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
这是因为您的 Microsoft.Common.Targets 文件指向 9.0 版本的程序集。
如果您查看 [sysdir]\Microsoft.NET\Framework\v3.5,您会发现
Microsoft.Common.targets
,它驱动了 MSBuild 的许多功能。此版本的通用目标文件指向[Program Files]\MSBuild\Microsoft\VisualStudio\v9.0\ReportingServices\Microsoft.ReportingServices.targets
强制 MSBuild 使用 9.0 版本运行。安装 .NET 4.0 时,您会在 v4.0.x 目录中获得一个新的通用目标文件,该新文件现在指向
[Program Files]\MSBuild\Microsoft\VisualStudio\v10.0\ReportingServices\Microsoft .ReportingServices.targets
指向 ReportViewer 程序集的 10.0 版本。10.0 ReportViewer 是针对 .NET 3.5 编译的,旨在在 3.5 和 4.0 中工作。您很可能摆脱 .NET 4.0 框架,并更改 3.5 通用目标文件以指向新的 ReportingServices 目标文件,并且它应该可以工作。无论如何,从理论上讲,我从未真正尝试过。您可能最好坚持使用 4.0,因为这就是我们为新查看器设计 MSBuild 支持时的意图。
This is because your Microsoft.Common.Targets file is pointing to the 9.0 version of the assembly.
If you look in [sysdir]\Microsoft.NET\Framework\v3.5 you will find
Microsoft.Common.targets
, which is driving a lot of what MSBuild does. This verion of the common targets file points to[Program Files]\MSBuild\Microsoft\VisualStudio\v9.0\ReportingServices\Microsoft.ReportingServices.targets
forcing MSBuild to run with the 9.0 version.When you installed .NET 4.0, you got a new common targets file in the v4.0.x directory, this new one now points to
[Program Files]\MSBuild\Microsoft\VisualStudio\v10.0\ReportingServices\Microsoft.ReportingServices.targets
which points to the 10.0 version of the ReportViewer assemblies.The 10.0 ReportViewer is compiled against .NET 3.5 and intended to work in both 3.5 and 4.0. You could very likely get rid of the .NET 4.0 framework, and alter your 3.5 common targets file to point to the new ReportingServices target file, and it should work. In theory anyway, I've never actually tried it. You may be best off just sticking with 4.0, as that's what we intended when we designed the MSBuild support for the new viewer.
只需安装 Microsoft Report Viewer 2010 SP1。
Just install Microsoft Report Viewer 2010 SP1.
我有一个非常相似的问题。突然之间,我无法再构建包含 .rdlc 文件的 VS2010 项目。我没有转换任何报告或使用报告服务器,一切都是本地的。我尝试创建一个全新的项目并添加一个空的新 rdlc 报告并点击构建,但它不起作用。就在有一天,它停止编译并给出以下错误:
报告定义无效。详细信息:报告定义具有无效的目标命名空间“http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition”,无法升级。
原来问题出在我的“C:\ Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\ReportingServices\Microsoft.ReportingServices.targets”文件已发生某种更改。我的文件顶部是:
它应该是:
<项目 xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
我更改了“使用任务”文件中的行,一切都会重新构建。真的很令人沮丧,它耗尽了我两天的生命。希望发表此评论可以帮助处于类似情况的其他人。
吉姆·拉弗勒
I had a very similar issue. Just all of a sudden I could no longer build a VS2010 project that contained an .rdlc file. I wasn't converting any reports or using a report server, everything was local. I tried creating a brand new project and adding an empty new rdlc report and hit build and it wouldn't work. Just one day it stopped compiling and gave me the following error:
The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' which cannot be upgraded.
Turns out the issue was my "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\ReportingServices\Microsoft.ReportingServices.targets" file had somehow changed. The top of my file was:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Microsoft.Reporting.RdlCompile" AssemblyName="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
And it should have been:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Microsoft.Reporting.RdlCompile" AssemblyName="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
I changed that one "Using Task" line in the file and everything builds again. REALLY frustrating and it ate up two days of my life. Hoping posting this comment may help someone else in a similar situation.
Jim Lafler
我已经尝试全部重新安装,但没有成功。然后,我尝试按照吉姆的帖子更新Microsoft.ReportingServices.targets,但对我来说甚至不起作用。
最后,我只是从其他计算机(运行时没有错误)复制 Microsoft.ReportingServices.targets 。令人惊讶的是,它正在发挥作用。
我在比较时注意到的额外区别是更改 PublicKeyToken 以及 版本。
这可能只是我的情况,但吉姆的帖子非常有用。
旧金山联邦大学
I have tried re-installing all and it didnt work. Then, I tried updating Microsoft.ReportingServices.targets as per Jim's post but even didnt work for me.
At the end, I just copied Microsoft.ReportingServices.targets from other machine (where it was running without error). And surprisingly, it is working.
The additional difference I noticed while comparing, to change PublicKeyToken along with Version.
This may be the case for me only but Jim's post was much useful.
SFUH
我有同样的问题:我们使用 ReportViewer 2012(程序集版本以 11 开头)。在本地计算机和构建计算机上都安装了 ReportViewer 2012 包和 VisualStudio 2013。在本地计算机上 VS 中的编译成功,但在构建计算机上排队构建期间 MSBuild 抛出此类错误:
我尝试从 .NET 3.5 修改 Microsoft.Common.targets文件夹中的方式,这在这篇文章中描述,但没有效果。然后我从.NET 4.0文件夹中打开Microsoft.Common.targets,发现有这样的字符串:
然后我意识到问题可能出在变量$(VisualStudioVersion)的错误值中,所以我在这个MSBuild的“Process”部分添加了构建定义参数:
并且成功了!构建成功完成。
希望这会对某人有所帮助。
I have the same problem: we using ReportViewer 2012 (version of assemblies starts with 11). Both on local machines and on build machine are installed ReportViewer 2012 package and VisualStudio 2013. On local machines compilation in VS succeeds, but on build machine during queued build MSBuild throws such error:
I tried to modify Microsoft.Common.targets from .NET 3.5 folder in way, that is described in this post, but no effect. Then I opened Microsoft.Common.targets from .NET 4.0 folder, and found there such strings:
Then I realized that problem may be in incorrect value of variable $(VisualStudioVersion), so I added to build definition in section "Process" this MSBuild parameter:
And it worked! Build completed successfully.
Hope this will help someone.
结果我确实需要 .Net 4.0 Framework,更具体地说是 4.x 版本的 MSBuild,它使用较新版本的 Microsoft.ReportViewer.Common 库。
因此,即使您的目标是 3.5 框架,如果您使用 VS2010 创建 rdlc,它将期望使用 4.0 工具“编译”。
Turns out I did need the .Net 4.0 Framework, and more specifically the 4.x version of MSBuild, which uses the newer version of the Microsoft.ReportViewer.Common library.
So even if you are targeting the 3.5 framework, if you create the rdlc with VS2010 it will expect to be "compiled" using 4.0 tools.
粘贴文件路径似乎没有经过...这个怎么样:
过去是:
现在是:
詹姆斯
Pasting file paths doesn't seem to be going through... how about this:
Was:
And is now:
James
NetFx40_LegacySecurityPolicy 在我的 devenv.exe.config 中启用,当我注释掉这一行时,项目构建成功。
我们在我们的团队中启用了旧的安全策略,以使我们的团队能够在 Visual Studio 2010 中使用 DevExpress 7.2 控件,但在这种情况下,它表明我们采取的方法并不总是最好的。
The NetFx40_LegacySecurityPolicy was enabled in my devenv.exe.config, and when I commented this line out, the project built successfully.
We had enabled the legacy security policy on our team to enable our team to work with DevExpress 7.2 controls from within Visual Studio 2010, but in this case, it shows that the approach we took is not always the best.
由于类似的问题,我损失了整整 2 天的开发时间。在构建我的项目时它会成功,但在重建时它失败且没有错误。在调查“输出”窗口中的详细构建日志时,它引导我发现了 rdlcompile 函数的问题(因此报告服务本地报告嵌入问题)。在尝试了一切之后,我终于设法解决了问题,但禁用了我的病毒扫描程序。防病毒软件以某种方式干扰了我的重建并导致重建失败。
禁用病毒扫描后,重建工作 100%
I lost 2 full days of development due to a similar issue. On building my project it would succeed, but on rebuild it failed with no errors. On investigating the verbose build log in the Output window it directed me towards a problem with the rdlcompile function (so reporting services local report embedding issue). After trying every thing I finally manage to resolve the issue, but disabling my virus scanner. The Antivirus was somehow interfering with my rebuild and caused the rebuild to fail.
After disabling virus scan, rebuild works 100%
我的 Visual Studio 2013 上也有同样的问题。
我的项目中报告服务的 dll 版本为 Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
当我检查 ReportingServices 目标
C:\Program Files\MSBuild\Microsoft\VisualStudio\v12.0\ReportingServices\Microsoft.ReportingServices 时.targets
我发现任务版本是 11.0.0.0
当我将任务版本更改为 10.0.0.0 对应于我的项目上的 dll 版本时。
它成功了。
I have same problem on my Visual Studio 2013.
The dll version of reporting service on my project is Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
When i checked my ReportingServices targets
C:\Program Files\MSBuild\Microsoft\VisualStudio\v12.0\ReportingServices\Microsoft.ReportingServices.targets
I found the task version is 11.0.0.0
When i changed the task version to 10.0.0.0 corresponding to dll version on my proejct.
It' worked.
我刚刚从我的文件系统中删除了这个文件。报告只需嵌入即可,无需编译。
这对我和我的构建服务器来说效果很好。
I just removed this file from my file system. The reports are simply ambedded no need to be compiled.
this worked fine for me and for my build server.