How to get MVC4 Project with MiniProfiler to build in TFS 2010? - tfs

I have an ASP.NET MVC4 project which builds in TFS. Since adding the MiniProfiler to the project, the builds fail as follows:
CA0001 : The following error was encountered while reading module 'MiniProfiler':
Assembly reference cannot be resolved: System.Web.Mvc, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35.
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: D:\Builds\...\my.dll,
D:\...\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll.
DotPeek shows me that MiniProfiler does indeed reference System.Web.Mvc Version 3.0.0.0
Has anyone run into this issue? Is there a solution?
I would install MVC3 on the build server, however I don't have admin permission to do it. Someone can do it for me next week but if possible I'd like to avoid that.

The cause of this was actually Code Analysis. We had analysis set to run on build, and the build server was not able to load the needed assemblies during analysis for some reason. I am still not sure of the root cause, but turning off code analysis solved the problem.

Related

Error when trying to build solution in TFS 2015 sp3 - can't figure it out

We are developing with VS2019, managing all code and builds in On-Prem TFS 2015 service pack 3.
Been running into the following TFS build issue and can't figure out what the real problem is. I verified the FxCopAnalyzers in the solution/projects are installed via Nuget and checked into TFS. This all builds fine locally on my sandbox workstation. The TFS warnings claim the file(s) cannot be found, but they are there. Very frustrating.
In the build config > process tab, the solution is using the Default v12 build template (as are ~50ish other builds) and I've set it to run as a CI build.
I'm missing something, but have been fighting this for so long I think I have tunnel vision. What could the real problem be? Any help is much appreciated. Thanks in advance.
CSC: An instance of analyzer Microsoft.CodeAnalysis.VersionCheckAnalyzer.AnalyzerVersionCheckAnalyzer cannot be created from E:\BuildAgentWorking\4\ACTS\ACTS v1.0 SLN (CI)\src\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.8\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
CSC: An instance of analyzer Microsoft.CodeQuality.CSharp.Analyzers.Maintainability.CSharpVariableNamesShouldNotMatchFieldNamesAnalyzer cannot be created from E:\BuildAgentWorking\4\ACTS\ACTS v1.0 SLN (CI)\src\packages\Microsoft.CodeQuality.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
CSC: An instance of analyzer Microsoft.CodeQuality.Analyzers.Maintainability.DoNotIgnoreMethodResultsAnalyzer cannot be created from E:\BuildAgentWorking\4\ACTS\ACTS v1.0 SLN (CI)\src\packages\Microsoft.CodeQuality.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
CSC: An instance of analyzer Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.UriPropertiesShouldNotBeStringsAnalyzer cannot be created from E:\BuildAgentWorking\4\ACTS\ACTS v1.0 SLN (CI)\src\packages\Microsoft.CodeQuality.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
CSC: An instance of analyzer Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.AbstractTypesShouldNotHaveConstructorsAnalyzer cannot be created from E:\BuildAgentWorking\4\ACTS\ACTS v1.0 SLN (CI)\src\packages\Microsoft.CodeQuality.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
If you've referenced the Microsoft.Net.Compilers pacakge, update it to latest version. If not, add reference to its latest version.
If you have a version of Microsoft.CodeAnalysis.FxCopAnalyzers that is too high for your version of Visual Studio you can get this warning:
warning CS8032 ...
To find the max version supported see this documentation: Install FxCop analyzers in Visual Studio -> FxCopAnalyzers package versions

MVCFoolProof does not work with AutoMapper in my Unit test project

While my main application works fine, the unit test project is giving following error, when I try to execute "Mapper.AddProfile" method in initialiation of unit test project.
The type initializer for 'Foolproof.ContingentValidationAttribute' threw an exception.
Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I have not used MVC 2.0.0.0 anywhere in my main project, and test project as well. Both these projects refer to MVC 4.0.0.0
what could be the possible issue?
Looks like the MVCFoolProof project has a reference to MVC2. See here: CodePlex Source Code - you could try pulling the source down and compiling it yourself against MVC4.

MiniProfiler with mvc 3 and ef 4.3

So i've just installed miniprofiler.mvc to my web project and it seems to be working fine.
Except I cant figure out what to do to set up EF Code First and the docs seem to be outdated.
My project has a MyApp.DAL project where the EF stuff lives.
What do I need to do to start profiling EF? please help?
UPDATE:
I have installed MiniProfiler.EF 2.0.2 and now I get
Could not load file or assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Have you made sure to install the EF package from Nuget?
http://nuget.org/packages/MiniProfiler.EF
PM> Install-Package MiniProfiler.EF
i've "fixed" it by simply adding EF to my Web Project
This is not ideal but it will do for now.

Why does my MVC project throw exceptions on production servers after installing WebMatrix 2 Beta?

After installing WebMatrix 2 Beta on my development machine, an MVC project compiled on that machine and deployed to a production server will start throwing a FileNotFoundException looking for System.Web.WebPages.
"...System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.WebPages,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The system cannot find the file specified. File name: 'System.Web.WebPages, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'..."
I couldn't find anything on Google to help with this, so I am asking and answering this here for anyone else that runs into this situation. It is a fairly obscure set of circumstances that lead up to this problem.
If you have a fairly old MVC project that you have been upgrading over the various releases, you may have an unversioned project reference to System.Web.WebPages.
<Reference Include="System.Web.WebPages" />
This works fine as long as the version your project finds where compiled matches the version available where it is deployed.
Installing WebMatrix 2 Beta will add a new version of this DLL. Your MVC project will start pulling v2.0.0.0 for compilation. When you move to a system without WebMatrix 2 Beta installed, it will not be able to find v2 and will throw the above exception.
I spun up a new MVC 3 project and noticed that there are a couple references that are fully qualified in the new project and much more generic in the problem project.
<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
If you switch to these project references instead of the generic ones (<Reference Include="..." />), you will make sure the project is compiled with the expected version of the DLL rather than picking up the latest one available on the system.

ASP.NET MVC 2: Why does my app reference both versions (1 and 2)?

I opened up the DLL for an ASP.NET MVC 2 project of mine in Reflector, and noticed that there are two references to System.Web.Mvc - one for version 1.0.0.0, and one for 2.0.0.0. I don't seem any references to v1 anywhere in the csproj file, nor in my web.config file, but when I try to run the app I get the error Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
Where would the dependency on v1 be coming from?
You probably have an indirect reference to v1 through a different assembly.

Resources