ASP.NET MVC4 solution fails to build after install

2020-06-12 03:04发布

We have an ASP.NET MVC 4 solution with a couple of references that has been building without problems for about 2 years now. However, after installing KB2993928 and KB2993937 this morning, we cannot run FxCop on this solution on our Windows 7 machines anymore.

I have a feeling this is because this update changed the DLL version of the System.Web.Mvc assembly in the GAC. This is because in the GAC I can currently find 3 different System.Web.Mvc DLLs, which are all updated today.

The error we receive in the build is as follows:

6>MSBUILD : error : CA0001 : The following error was encountered while reading module 'FrontEnd.Implementation': Assembly reference cannot be resolved: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. [C:\Project\FrontEnd\02-Implementation\02-Implementation.csproj]
6>MSBUILD : error : CA0058 : The referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be found. This assembly is required for analysis and was referenced by: S:\Deliverables\FrontEnd\bin\FrontEnd.Implementation.dll. [C:\Project\FrontEnd\02-Implementation\02-Implementation.csproj]

Since we use ASP.NET MVC 4, this version 3.0 DLL is referenced indirectly by one of our references. For instance, RazorGenerator references version 3.0.0.0. Possibly others as well. There is no new version of RazorGenerator from what I can tell.

The System.Web.Mvc versions I see in the GAC are: 3.0.50813.1, 4.0.40804.0 and 5.0.20821.0.

I removed the reference to System.Web.Mvc from our projects and added Mvc as a NuGet package instead. This fixes our compilation, but FxCop still doesn't work due to the indirect references.

If any additional information is required please let me know.

6条回答
不美不萌又怎样
2楼-- · 2020-06-12 03:13

I used the following solution and it's work perfectly:

https://stackoverflow.com/a/26490590

(don't forget to select the default project on the Package Manager Console for each project with the build failed)

查看更多
Fickle 薄情
3楼-- · 2020-06-12 03:14

If this issue is caused by references which in turn have dependencies on those specific assemblies, you can remedy this by coercing FxCop to use only the StrongName and ignore the version number. This solution is described here.

Of course the real solution would be to update the referenced assemblies (with the indirect dependencies) to newer versions.

查看更多
▲ chillily
4楼-- · 2020-06-12 03:19

Solution:

  1. Uninstall the MVC Framework via "Programs and Features" (whichever version you're using)
  2. Re-install MVC Framework (http://www.asp.net/mvc/mvc4)

Should fix the problem - no changes to the build/solutions is required.

查看更多
5楼-- · 2020-06-12 03:26

Remove any references to System.Web.MVC and then re-add them by manually browsing to the dll (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_5.1.0.0__31bf3856ad364e35\System.Web.MVC.dll on our machine). A lot faster than re-installing MVC if this has just taken your production server down!

查看更多
We Are One
6楼-- · 2020-06-12 03:26

The security updates update the assembly version of system.web.mvc.dll. You need to update your csproject to correct the version. Check this post: ASP.NET MVC security patch to version 3.0.0.1 breaks build

查看更多
倾城 Initia
7楼-- · 2020-06-12 03:34

This was done by a security update on October 15th from Windows Update. You will need to run the updates on your build servers too.

Link to update: http://www.microsoft.com/en-ie/download/details.aspx?id=44533

This update fixes other versions as well.

You will likely have to update your projects to the newer version, as it changes the version number and removes the older version completely.

查看更多
登录 后发表回答