46

We are upgrading from TFS 2008 to TFS 2012. Majority of our applications are .net 3.5 applications.
We have setup a TFS 2012 environment and went through migration process. When we attempt to build our .net 3.5 applications we are getting the error:

csc error cs0006 metadata file could not be found........

If we take a .net 3.5 application, upgrade it to .net 4.x, then run the build again, it works just fine.

I cannot upgrade every single application I have during this migration. Is there something I might be missing either in the migration or on my build box to support 3.5?

I have VS 2008, 2010, 2012 installed on my build server. I have .net frameworks installed, etc.

Any assistance is helpful.

Max Shmelev
  • 3,774
  • 4
  • 26
  • 26
Kevin Price
  • 461
  • 1
  • 4
  • 3

12 Answers12

18

The project dependencies and project build order can be specified in Visual Studio 2012 by right clicking on the project in the solution explorer and selecting Project Dependencies. By doing this action, your solution file will be fixed. In my case I was able to fix this problem without manually editing the solution files.

Kirill Kobelev
  • 10,252
  • 6
  • 30
  • 51
Vasudevan Kannan
  • 911
  • 2
  • 7
  • 22
  • 3
    I just right clicked on the solution and chose "View Project Dependencies". No idea what it did but when I closed the dialog that came up it worked! – Rob Sedgwick Jul 23 '14 at 14:04
14

We get these problems switching between branches (with significant changes). When it happens I recommend the following:

  • Close Visual Studio
  • Close w3wp.exe instances (paranoid and only if you're hosting via local IIS)
  • Search for and delete all bin and obj folders
  • Clean out all intermediate JIT compiled assemblies from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\

Following this set of will do what "Clean solution" should do, but doesn't. Essentially we're trying to remove any chance whatsoever of anything being cached anywhere (which is the most common cause of these issues).

Of course your mileage may vary, but for us with 120 projects and 1.3 million lines of code refactors regularly throw this issue up and it resolves it reliably.

Paul Carroll
  • 1,523
  • 13
  • 15
7

This seems to be caused by the fact that the Visual Studio solution file does not contain the project dependencies. I found that I had to edit the solution file manually to setup the dependencies using the project GUIDs.

For example, in our solution file we had something like this:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectA", "ProjectA\ProjectA.csproj", "{61C9C7C3-B5B4-4C00-8AE0-B49D21B3D77C}"
EndProject

Note that no dependencies are specified. It needed to be more like this where the additional GUIDs specified are the GUIDs of the project that ProjectA depends on.

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectA", "ProjectA\ProjectA.csproj", "{61C9C7C3-B5B4-4C00-8AE0-B49D21B3D77C}"
    ProjectSection(ProjectDependencies) = postProject
        {EB576061-5081-4ED5-9146-1B20C893E51E} = {EB576061-5081-4ED5-9146-1B20C893E51E}
        {A469F4BA-8BAA-4F14-BFC8-4D49F93C3E40} = {A469F4BA-8BAA-4F14-BFC8-4D49F93C3E40}
        {03FAB21D-C077-499B-9B19-67971791D369} = {03FAB21D-C077-499B-9B19-67971791D369}
        {F5E0C7B8-36AD-46B0-A74D-9C48516E208A} = {F5E0C7B8-36AD-46B0-A74D-9C48516E208A}
    EndProjectSection
EndProject

See this post for more information.

Nicholas Roeder
  • 284
  • 4
  • 7
  • 2
    try the answer (currently below) about project dependencies before going down this route, it's a lot harder to do it this way. – Rob Sedgwick Jul 23 '14 at 14:05
  • Thank you, this worked after trying so many other solutions - in my case, I had added the project references, which was causing the project dependencies screen to show the correct dependencies ticked, but when I looked in the solution file where you said there was no actual dependencies listed. When I manually added them to the solution file, the build started working. I found afterwards if I removed the project references, ticked the dependencies in the GUI as @Vasudevan-Kannan suggested and re-added the project references it worked also (but your method helped me to find the actual issue) – chillNZ Oct 19 '17 at 23:29
6

I also had the same error.

The fix was, to check the path. In my path, one folder has the name abc%20ert. This came from syncing the space from git. Visual Studio has problems with the %20 in the path. Removing this solved the problem.

  • I had a similar issue. I decompressed a solution into a path with spaces in it. Reading the output I could see VS could only see the path starting from the first word after the last space in the path. Removing the spaces fixed the issue – JBourne Jan 04 '18 at 10:55
  • I also had the same issue, after I cloned it from our AzureDevops repo it adds the **%20** for spaces. This was extremely annoying to figure out. – Luther Dec 03 '19 at 17:15
5

In my case one of the projects were not building but there was absolutely no mention of it in the errors. After a couple hours of pulling my hair and dropping some F bombs, I finally looked at the output carefully and noticed there was an error:

enter image description here

And that was it. I fixed it and presto all errors were gone. But I got curious so I changed the code back to the code that was failing compilation. I did a build and now I got the friendly build error. For some reason the error was not being shown. No idea why...

CodingYoshi
  • 25,467
  • 4
  • 62
  • 64
5

Check the target framework version in each project=>properties screen. If it's lower than used in the reference projects or files, you'll get error as the compiler doesn't know how to deal with the higher version of framework.
From what you describe, you have a dependency that has framework v4.0 as target.

Change dependencies target framework one by one until your project builds.

If it's a 3rd party closed source dependency, please ask them to provide it with .net 3.5 target.


There is no workaround.

michal
  • 51
  • 1
  • 1
3

I had a similar problem. In my case I was able to solve it by 2 steps. First, I Cleaned the Solution using the Clean Solution option. Then after the solution was cleaned, the debugger detected that I had installed outdated versions of the Microsoft.Aspnet.Mvc library. So I installed the new ones through the Library console using the lines below: Install-Package Microsoft.Aspnet.Mvc -version 5.2.3.0 -projectname _____________ Install-Package Microsoft.Aspnet.Mvc -version 5.2.3.0 -projectname _____________

AGuler
  • 31
  • 1
1

I got this error when using C# 7 language features in an ASP.NET project, where it didn't have a recent version of NuGet package Microsoft.Net.Compilers, as described in Enabling c# 7 in a asp.net application.

Bart Verkoeijen
  • 16,545
  • 7
  • 52
  • 56
1

I had this problem with a solution involving more that one project. The thing was that there were different Framework versions. My WEB project was 4.5 and there was a PDF Helper using 4.7.2 version. After I aligned all versiones, I cleaned the solution and the compilation went fine.

Best regards.

0

This happened to me after switching between branches in a project which have significant differences between them, I tried every solution from the web but non worked.

Finally, I had to delete my local project files and clone the project from the GitHub repo again, after that when I started the project, the project build worked without errors.

Luka Devic
  • 41
  • 2
0

In my case I had an error in dependent project. That is why the dependent project was not built and DLL was missing. I had to solve other errors in dependent project first, then error CS0006 disappeared.

David Najman
  • 487
  • 4
  • 7
0

Cleaning projects by dotnet clean helped me:

dotnet clean
vladimir
  • 13,428
  • 2
  • 44
  • 70