Salman
Salman

Reputation: 1853

Azure DevOps project build returning with log4net error

I'm trying to build a visual studio 2015 dot-net application which has log4net reference in the code.

When I build in Azure DevOps using Nuget restore, Nuget Tool installer, Visual studio build, Publish Build artifacts I am getting an error:

Error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?) Process 'msbuild.exe' exited with code '1'.

Please someone suggest whether I have to add another agent or make some reference to the package/nuget in Azure DevOps. need details since I'm new to Azure DevOps.

Upvotes: 2

Views: 1154

Answers (3)

Kirsten
Kirsten

Reputation: 18066

For some reason I lost ability to see it in

Tools -> Manage Nuget Packages for Solution

However from the docs

I used

Install-Package log4net

in Package Manager Console

That solved the issue.

Previously I had noticed the yellow triangle against log4net In Manage Packages For Solution, and may have tried removing it via Nuget. However it was still showing as a reference

Upvotes: 0

Salman
Salman

Reputation: 1853

Problem was partly solved as there was .gitignore and .gitattribute files in my source directory which i guess had entries to ignore the third party .dlls like log4net and several folders which were not getting checked-in when i did vsts push. But there arose some other errors in vsts build now which i am trying to figure out. I will create a new thread for that.

Thanks.

Upvotes: 0

DanDan
DanDan

Reputation: 1947

The error message suggests that either the using is missing or the assembly could not be found, meaning that probably the nuget restoration has failed.

If you can't figure out the issue by looking at the log, the first step should be to set system.debug to true, then you might get more info about what the issue might be.

My first instinct when I don't know what's going on would alsways be to look into the s folder of an agent but I don't have experience with hosted agents and as far as I know you cannot access the working folder of a hosted agent.

So as a workaround (only if everything else fails) I would suggest to zip the s folder ("$(Build.Sources)") or special parts of it into the a folder ("$(Build.Artefacts)") and publish that zip as an artefact. Then you can download it and look at it in great detail, e.g. look at the packages folder or open the solution and see why it doesn't compile.

Upvotes: 1

Related Questions