azurejenkinsdevopsazure-container-instances

Cannot build .NET 8.0 application in Jenkins


I'm running Jenkins in Container Instance in Azure. However when I'm Jenkins starts building, I'm getting the error below. I have read a lot of info and people are suggesting to add this in the project file:

<InvariantGlobalization>true</InvariantGlobalization>

I have already done done that, but still not working. I've tried to install libicu as suggested and as I have read in other articles, but I'm still not able to do that as when I log into the container and type

apt-get install libicu-dev

I'm getting this:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

I have tried with sudo, but sudo is not recognized....

Here is the whole error message from Jenkins:

    Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode+Settings..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.TextInfo..cctor()
   at System.String.ToLowerInvariant()
   at System.Text.EncodingHelper.GetEncodingFromCharset()
   at System.ConsolePal.GetConsoleEncoding()
   at System.Console.get_OutputEncoding()
   at Microsoft.DotNet.Cli.AutomaticEncodingRestorer..ctor()
   at Microsoft.DotNet.Cli.Program.Main(System.String[])
.NET Command Completed - Exit Code: 134

ERROR: Command execution completed with return code 134.
Finished: FAILURE

Solution

  • Finally I was able to solve the issue. The issue was mainly coming because the built-in agent was used. After that I have created a new Agent and when I looked into it - there were a couple of commands to run. After that the Agent is coming online and when he is running the build - I didn't experience the issue. However the problem is that whenever you end the session the agent goes offline again. I have followed this tutorial:

    [How to setup agent in Jenkins][1]

    This has fixed all of my issues with the Agent and building and testing the .net application. [1]: https://www.jenkins.io/blog/2022/12/27/run-jenkins-agent-as-a-service/