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

11,423

Solution 1

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.

Solution 2

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/

Solution 3

I had the same issue of my TC build suddenly being unable to find an assembly. I solved it by checking in the paths as well. My assembly did not have a tag. Once I added the tage with the path to the dll, TC was able to build successfully

Share:
11,423
Erica Stockwell-Alpert
Author by

Erica Stockwell-Alpert

merge delete

Updated on June 12, 2022

Comments

  • Erica Stockwell-Alpert
    Erica Stockwell-Alpert almost 2 years

    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

  • tkit
    tkit over 5 years
    TeamCity should restore the missing NuGets on each build. NuGet binaries should not be version controlled.