Visual Studio Online build fails - Local works - c#

I upgraded to VS2015, and MVC was updated to 5.0.
I am able to build successfully on my local PC, but when I checkin to Visual Studio Online, and my CI build builds, it fails:
"The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)"
I've used nuget manager to remove, and re-install MVC on my project - same results.
Looking at my references in the project, all looks OK.
I also notice in the log before the error happens:
Installing 'Microsoft.AspNet.Razor 3.2.3'.
Installing 'Microsoft.AspNet.Mvc.FixedDisplayModes 5.0.0'.
Successfully installed 'Microsoft.AspNet.Mvc.FixedDisplayModes 5.0.0'.
Successfully installed 'Microsoft.AspNet.Razor 3.2.3'.
All packages listed in packages.config are already installed.
But it seems when it builds, it doesn't know what MVC is. How can I resolve this?

Late to the game here, but I was having a very similar issue: Error CS0246: The type or namespace name 'blank' could not be found (are you missing a using directive or an assembly reference?).
This was building locally but not in VSTS. My solution was to delete the reference under the project's references, and then just add it back in again. The reference was to a namespace in a local project to the solution. For some reason it was being found locally but not found when checked into and built on VSTS.
Deleting the reference and then re-adding it worked for me.

Check the version number mentioned in all web.config files. I mean also those in the view folders; that they match the version 5.2.3.0

Scan all your references and ensure, that all of them related to MVC have Copy Local property set true. Not only Mvc one.

I fixed this by removing all the folders within my Packages folder, leaving only repositories.config. This forces VSOnline to restore all the packages on each build.

Related

"The type or namespace could not be found" error while building a project

I am getting this error while trying to build a solution:
Error CS0246
The type or namespace name 'ClassName' could not be found (are you missing a using directive or an assembly reference?)
The error and the red lines disappear when I open the error list and click on it. I can see the missing dll file is recognized by that class and it is also listed in the references.
I searched many questions here but none of them worked for me. Here is a list of things I tried so far that might help to understand the problem.
I've got the project from TFS and have been never able to build so far. I think the project is not correctly checked in.
I choose 'build only' in the Error list section, after that the errors did not disappear.
All project versions are .Net 4.6, none of them is Client Profile like other in questions here.
I tried to clean, to rebuild, deleting references and adding them again, but none of them worked.
I have changed build output to Diagnostic then inspected errors.
I have found this line and changed all projects target version from 4.6 to 4.6.2 and it worked.
Dll could not be resolved because it was built against the
".NETFramework,Version=v4.6.2" framework. This is a higher version
than the currently targeted framework ".NETFramework,Version=v4.6".

Build succeeds even though the editor shows errors and and installation of NuGet package fails

In Visual Studio 2017, I have a solution with the following projects:
My.Project
My.Project.Commons
Test.My.Project
Test.My.Project.Commons
In one of the test files from Test.My.Project, I have this statement:
using My.Project.Commons;
If I hover over it, it shows this error message:
The type or namespace name 'Commons' does not exist in the namespace
'My.Project'(are you missing an assembly reference?)
However if I Clean and Build(or Clean and Rebuild) the solution, there are no errors.
When I try to install a NuGet package, I get the same error:
The type or namespace name 'Commons' does not exist in the namespace
'My.Project'(are you missing an assembly reference?)
So why does my build succeed?
I believe that my Test projects are not built properly, because I can't run any tests.
On another solution however, I can run tests with no problem, so I doubt there is an issue with Visual Studio as a whole(just with my current project).
I tried:
Restarting Visual Studio.
Removing all projects from the solution and adding them back.
None of these things worked though.
If you are using resharper, suspend and resume resharper and it will refresh the cache
If you go into VS options resharper you will find the the options

"The type or namespace name 'OfficeOpenXml' could not be found" error

We are using EPPlus to generate Excel documents. Code builds successful in my local system but it is failing when we build through TeamCity and getting below error -
error CS0246: The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)
I have tried Google to find the solution but all in vain. My Project target framework is 4.5.2 and I have also added System.Core and WindowsBase. I have also added namespace "using OfficeOpenXml"
EPPlus is added through Nuget Package.
If you have any packages installed using NuGet, then you need to add a NuGet Installer build step in your build configuration before the actual build command, using the solution file which references the NuGet packages you need. This step is what causes TeamCity to download any NuGet packages that are required that it doesn't have installed.
I solved it by removing and add EPPlus reference manually.

The type or namespace name 'Core' does not exist in the namespace

I encounter this kind of error when I debug a project
I already have EntityFramework.dll, System.Core.dll, System.Data.Entity but still Core is not referenced.
Can someone help me?
I'm having error in this Line
using System.Data.Entity.Core.Objects;
This is the error:
The type or namespace name 'Core' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
Enrique, I had this problem crop up when I started opening a project on my desktop that I had normally been opening on my VM. Masoud's answer is not helpful... I don't think he read your original post.
What I did to clear this compile error up was to open NuGet package manager and install the update that was available for EntityFramework. I had version 6.1.1 installed in the project and I upgraded to 6.1.3. I should not have had the error to start with, but upgrading the version appeared to jiggle whatever it was loose because I started compiling fine after that.
Sometimes, when you add references from other sources than nuget manager (example: Local source) you need to verify the HintPath of that reference before moving your application in another environment

'Validation' does not exist in the namespace 'System.Data.Entity' when building on Team City

I have a project that is working perfectly on my computer, but when trying to build it on Team City i get the following build error for source files where i have
using System.Data.Entity;
using System.Data.Entity.Validation;
CS0234: The type or namespace name 'Validation' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
Do I need to install Entity Framework manually on the server running Team City for this to work?
Update after activating Nuget Restore:
This must be some kind of configuration issue.
I can see in the build log that the build process is copying the .dll:
[Copy] Copying file from "D:\TeamCity\agent1\work\541c9f462afc285d\packages\EntityFramework.5.0.0\lib\net45\EntityFr amework.dll" to "bin\Release\EntityFramework.dll".
[16:51:55][Copy] Copying file from "D:\TeamCity\agent1\work\541c9f462afc285d\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.xml" to "bin\Release\EntityFramework.xml".
But shortly after, it is considering a bunch of different locations, but not including the bin\Release\EntityFramework.dll" folder.
Update 2:
Manually copying the .dll to the bin/release folder of my class library helped the build to pass, but obviously this is no viable solution, so will need to keep on finding out how to configure this correctly.
Update 3:
Never did find a satisfying solution for this I am sad to say, so any genius that can solve this are very welcome. :)
As an error suggested you are missing assembly. And as #Shriroop suggested this is in EF packge.
Before your compile step, add Nuget Installer step. There are few options you should set, Path to solution name and I suggest you use nuget 2.7+ and Restore mode: Restore.
To install latest nuget version in teamcity go to Administration > Nuget Settings > NuGet.exe and fetch latest version.
Here is a sample of NuGet Installer step: http://img.hihi.si/Upload/5PUm.png

Categories

Resources