VS2019 Report Designer 問題排除

前言

同事回報Vs2019的報表檔案無法建置。相關訊息如下:
Severity    Code    Description    Project    File    Line    Suppression State
Error        The "RdlCompile" task was not found. Check the following:
1.) The name of the task in the project file is the same as the name of the task class.
2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface.
3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin" directory.    
WebApplication5            


Severity    Code    Description    Project    File    Line    Suppression State
Error        The "Microsoft.Reporting.RdlCompile" task could not be loaded from the assembly Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91. Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.    WebApplication5        


  C:\Program Files (x86)\Microsoft Visual  Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\ReportingServices\Microsoft.ReportingServices.targets(24,2): error MSB4036: The "RdlCompile" task was  not found. Check the following: 1.) The name of the task in the project file is  the same as the name of the task class. 2.) The task class is "public" and  implements the Microsoft.Build.Framework.ITask interface. 3.) The task is  correctly declared with <UsingTask> in the project file, or in the *.tasks files  located in the "C:\Program Files (x86)\Microsoft Visual  Studio\2019\Enterprise\MSBuild\Current\Bin" directory.    

原因
由於VS2019內建不支援報表編輯,要先安裝Microsoft RDLC Report Designer才可以。裝完後,雖然可以編輯報表了,但建置時會出現上方的錯誤訊息。

解決方法
在經過一連番的測試後,最後找到可行的作法為,將Microsoft.ReportingServices.Targets移除即可。雖不是最佳解法,但先應急吧....路徑如下:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\ReportingServices\Microsoft.ReportingServices.Targets
Ps:移除後,專案要重啟才有效。


此檔案是在安裝了Microsoft RDLC Report Designer才有的,由於在錯誤訊息有提示到此檔案缺少了相關檔案,所以先試著將它移除,來試試。沒想到,竟然可以...XD。

相關測試
  • Microsoft RDLC Report Designer移除後,回復正常。
  • 將dll放在\v16.0\ReportingServices\目錄:fail

這個網誌中的熱門文章

IIS 設定只允許特定IP進入