Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity: Type or namespace cannot be found, but the reference exists and my project compiles locally

I have an ASP.net MVC 3 project. We're using TeamCity, and up until now everything has checked in fine. All of a sudden today, I did a checkin, and the TeamCity build failed. It said I was missing a using directive or assembly reference and threw a compilation error.

The project on my local machine builds successfully. I rebuilt it several times to make sure. I checked the reference and it's there. I checked the .csproj file and it has the reference there too. I checked bin; it's there. I even RDPed into the server where our site is deployed and checked the bin there, and the dll file is there too.

I don't understand why it's not working, I haven't changed anything in the particular files it says are missing the assembly reference in weeks, I had a successful checkin on TeamCity yesterday, the dll file exists everywhere it's supposed to, and my project builds. I even did a hard reset to the last commit I made that checked in successfully, added my changes back in (which had nothing to do with the reference problem, all my changes were in a .js file), and checked that in, but I got the same compilation error.

Does anyone have any idea what's going wrong, or at least what I might try to resolve this?

edit: There are no path files being used here, the file in question is a .dll file, which I added by clicking "Add reference" on the project. I checked the Github repository and the .dll file is in the bin folder

like image 383
Erica Stockwell-Alpert Avatar asked Aug 15 '14 19:08

Erica Stockwell-Alpert


2 Answers

iamkrillin got me thinking that maybe it was a path issue, so I opened up the csproj file and noticed that the format of the reference to "missing" file was different from all the others around it:

<Reference Include="Ektron.Newtonsoft.json">
  <HintPath>..\..\Custom\bin\Ektron.Newtonsoft.json.dll</HintPath>
</Reference>

// THE "MISSING" FILE
<Reference Include="Smdg.Utils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\NEHGS\bin\Smdg.Utils.dll</HintPath>
</Reference>

I checked the Custom\bin folder and sure enough the .dll file was there (though it also existed in NEHGS\bin), so I got rid of the SpecificVersion tag and changed the path to the Custom folder. TeamCity was able to check it in.

Why it suddenly broke when it's been working for the past 2 months, I have no idea.

like image 91
Erica Stockwell-Alpert Avatar answered Oct 24 '22 15:10

Erica Stockwell-Alpert


I had this just because of not storing NUGET packages at VCS (GIT).

So there is the need to do the restoration of NUGET packages, just before a build step.

https://blog.jetbrains.com/teamcity/2013/08/nuget-package-restore-with-teamcity/

like image 29
Motlicek Petr Avatar answered Oct 24 '22 15:10

Motlicek Petr