1

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:

  1. Create an Asp.Net Core Web Application->.NET Core and Asp.net Core 2.0-> Web Application(Model-View-Controller)
  2. Create an xUnit Test Project(.NET Core)
  3. Follow this link Integration testing in ASP.NET Core
  4. Add true to Test.csproj which is pointed at above link.
  5. 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.

0

1 Answer 1

1

A bit late, but I ran in to the same problem today and managed to fix the "Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration ..." error by adding the following reference to my integration test project:

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" PrivateAssets="All" />

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.