For this error, I have tried multiple solutions which is provided by Github. But, none of them worked. Please help to check whether this issue reopen on new environment like below. Environment: VS 2017 Version 15.4.1 Dotnet Version 2.0.2
Reproduce Steps:
- Create an Asp.Net Core Web Application->.NET Core and Asp.net Core 2.0-> Web Application(Model-View-Controller)
- Create an xUnit Test Project(.NET Core)
- Follow this link Integration testing in ASP.NET Core
- Add true to Test.csproj which is pointed at above link.
- Run test method will return below error.
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException : One or more compilation failures occurred: ewiqttdv.z4g(4,62): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Update: After following this suggestion , this error gone, but, it produce below new error.
Message: System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
What is the possible way to resolve "Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException"?
Any help would be appreciated.