dotnet ef core list never completes - c#

After submitting a build though Azure Dev Ops, we noticed that the command to build the migration steps timed out after an hour of inactivity. It only happened on this branch and we've completed others before and since successfully. The solution builds and runs successfully.
Upon investigating, I narrowed down the issue to happening on the following command:
dotnet ef migrations list --configuration Release --project <repo_project_name> --startup-project <startup_project_name> --no-build --context <fully_qualified_context_class_name>
When I run the above command in Powershell,it after spitting out the list of migrations in the project, it just hangs and never returns to a prompt.
I've seen other discussions of similar issues suggesting to delete the obj folder, but when I do that in the startup project folder, I get a message that it's missing the project.assets.json. (When I do it in the repo project folder, it hangs as before. But even if that did resolve it locally, how could I implement that on the ADO server?
To make matters weirder, this particular branch didn't even update the repo project.
Any thoughts as to how I should proceed? Thanks.
UPDATE: I've been able to narrow down that we're waiting for a thread to end. This is the call stack at the point where it's hanging:
System.Private.CoreLib.dll!System.Threading.WaitHandle.WaitOneNoCheck(int millisecondsTimeout)
System.Private.CoreLib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout)
System.Diagnostics.Process.dll!System.Diagnostics.Process.WaitForExitCore(int milliseconds)
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.Exe.Run(string executable, System.Collections.Generic.IReadOnlyList<string> args, string workingDirectory, bool interceptOutput)
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.Configure.AnonymousMethod__0()
dotnet-ef.dll!Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(string[] args)
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.Program.Main(string[] args)

The issue turned out to be a process we developed was not shutting down properly after script generation. The reason for that seems to be that "dotnet ef migrations" only does a partial startup of the website. It calls Startup.ConfigureServices but not Startup.Configure, which is where web shutdown functions are configured, so I'm theorizing that Dispose methods don't get called properly, resulting in our process not shutting down correctly.
I worked around that by implementing the suggestion found in this answer to another question.

Related

remote rejected master -> master (pre-receive hook declined) error: failed to push some refs to

I've been stuck in this problem for almost all day now and haven't found any appropriate solution though there are some out there. No matter what I do the error is always the same for me. So, I created this project to learn ASP.NET Core MVC which already had git init and posted it here: https://github.com/thechaudharysab/IBJOffice
Now today I decided to take this project online and see if it works or not or how I can make it LIVE on the cloud using Heroku (because it's free & I didn't want to use Azure yet).
I installed Microsoft.Extensions.Configuration.CommandLine and added using Microsoft.Extensions.Configuration; in my program.cs class and then in it's main method I added:
public static void Main(string[] args)
{
var config = new ConfigurationBuilder().AddCommandLine(args).Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseConfiguration(config)
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
If right now I check git status there is nothing to commit as my branch is up to date with 'origin/master' on GitHub. So now I want to push the code to Heroku and for that I'm doing this:
git add .
git commit -m "heroku update'
heroku create --buildpack https://github.com/noliar/dotnet-buildpack.git -a ibjoffice
heroku git:remote -a ibjoffice
git push heroku master
Every single time I get this error:
If I write git remote -v I get these four:
Since I'm new to .NET Core so I might have made a mistake or missed something that is why to the best of my knowledge I've added everything let me know if there is any information that is missing I'll add it.
Here is why I think (to my limited basic knowledge) can be the reason:
The build pack I'm using https://github.com/noliar/dotnet-buildpack is too old and might not be feasible with a .NET project created a couple of weeks ago.
The code I wrote in program.cs might be wrong as I was unable to run the project after I updated the main method it just keeps on loading and loading when I run it locally.
git remote -v shows four may be they just have to be two and its making a confusion and causing the error.
There are some solution that are talking about a file named app.json and I don't have any such file my my project as you can see full project here: https://github.com/thechaudharysab/IBJOffice
So these are my guesses. Would really appropriate any help.
heroku create --buildpack https://github.com/noliar/dotnet-buildpack.git -a ibjoffice
--> https://github.com/noliar/dotnet-buildpack/blob/master/bin/detect
It checks for a presence of project.json.
Your project is lacking a project.json and thus is not compatible with the buildpack. Hence the Push rejected.
This check is extremely basic. So even if you now add this file to your project there may be other issues you are going to run into.

Gitlab CI - test project hangs on DbConnection.CreateCommand()

I just started using docker and wanted to also use gitlab-ci for builds and tests. After painfully long and numerous attempts I finally managed to prep my images and gitlab-ci.yml. My project consists of WebApi, database project and test project.
My current flow is (using docker/compose and dind in gitlab-ci):
Build stage:
build webapi and load it to container registry
build database and load it to container registry (image mcr.microsoft.com/mssql/server:2017-latest)
Test stage:
run docker-compose on compose file that prepares testing:
start database container from image in container registry build in build stage
build test project and start the container
docer execute on test container "dotnet test 'Tests.csproj'"
One more important piece of information - the test project is using Respawn to reset the database to clean state for integration tests. It basically goes through the object graph and deletes data before each tests (also handles nicely the relationships). For sql server it uses SqlConnection (abstracted to DbConnection in later stages of the code) to connect to the database.
If I run this on my local machine (manually create the database image and then run docker-compose from 2a, and manually run docker-compose -f Tests/docker-compose.ci.yml -p dockercomposeForTests --no-ansi up -d) the tests are running fine.
However from gitlab.com, tests are hanging on the Respawn. They stop exactly on DbConnection.CreateCommand(). At this stage it seems to me, that there is some kind of a problem either in my setup or in the container, but afters days of trying to resolve this issue, I do not have any more ideas.
I know the database is up and the tests are connecting to it. First, Respawn is opening a working connection. Second, I also have a Hangfire starting and connecting to exactly the same database (uses the same connection string as Respawn), and hangfire is reporting connectivity (at first I had some problems with it but I left it because it helps me to diagnose if connection is alive and working; at some point I will probably get rid of it so it won't slow down the tests).

dotnet restore unable to load shared library 'libproc' or one of its dependencies on Mac OS

I am following the tutorial for .NET on
https://www.microsoft.com/net/learn/get-started/macos
I installed the .NET SDK and create an app by using on macOS High Sierra Version 10.13.5:
~$ dotnet new console -o myApp
which gives me an error of:
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on myApp/myApp.csproj...
Unable to load shared library 'libproc' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES
environment variable: dlopen(liblibproc, 1): image not found
I tried to do
export DYLD_PRINT_LIBRARIES=/usr/lib/
before deleting the created folder and files, and I get a lot of printed statements that look like:
dyld: loaded: /usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.1/System.IO.Compression.Native.dylib
as well as the same error:
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on myApp/myApp.csproj...
Unable to load shared library 'libproc' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES
environment variable: dlopen(liblibproc, 1): image not found
I got it to work by using fs-usage to examine where does dotnet try to find libproc.dylib. In my case, I found that dotnet was trying to find libproc.dylib at ~/libproc.dylib, so I copied /usr/lib/libproc.dylib to ~/libproc.dylib and dotnet worked.
I think this is not a satisfactory answer so if anyone knows why dotnet was not looking for libproc.dylib at /usr/lib/libproc.dylib, please help me out. Thank you!
I noticed that my comment only worked when I started pwsh in ~.
I created a symlink in /usr/local/microsoft/powershell/6 that points to libproc.dylib:
/usr/local/microsoft/powershell/6$ sudo ln -s /usr/lib/libproc.dylib libproc.dylib
PowerShell starts correctly in any directory.
This will likely need to be recreated when I upgrade PowerShell Core (via Homebrew Cask).
** edit **
I should have read the question more closely--it was about dotnet, not pwsh.

Asp.Net Core - Error cannot execute binary file on published (Ubuntu 14.04) web application with supervisor

I am not sure if this is the right place to ask, but here it is: I created an ASP.NET Core web application, and copied all the files on my Ubuntu 14.04 server. I can compile and run without a problem, but now I want this application/web site to run permanently.
I followed all the steps described here https://docs.asp.net/en/latest/publishing/linuxproduction.html, installed nginx as reverse proxy to run with apache, and all of this run perfectly well.
BUT, trying to use supervisor and start the app from it, I systematically get an error /usr/bin/dotnet cannot execute binary file. But, if I move to be in the directory where the application is published, and manually type dotnet appname.dll it does start without a glitch.
I am not sure where to look to get this to work with supervisor. Thanks for your help (and if this question should be somewhere else, let me know)
I finally solved my problem, replacing the equivalent of the line command=bash /usr/bin/dotnet /var/aspnetcore/HelloMVC/HelloMVC.dll as described in https://docs.asp.net/en/latest/publishing/linuxproduction.html under "Configuring Supervisor" by a little script, far from perfect as I get a Warning: HOME environment variable not set.
Anyway, here is the script:
#!/bin/bash
cd /var/aspnetcore/foesuivi/
dotnet FoESuivi.dll
cd $HOME
As a windows programmer, I don't know much about bash scripting, but I certainly can see that I would need to give a value to $HOME before the cd command.
Anyway, after doing a chmod +x to the sh file, and replacing the command= with the full name of the sh file, it is now working, I can reboot and my site is immediately available.

Error in running add-migration in Visual Studio for EF6

We seem to have an odd intermittent issue which is causing myself and the 2 other developers in my team a great deal of pain.
Whenever we run add-migration XYZ or update-database we get this:
PM> add-migration AnJo
System.Runtime.Remoting.RemotingException: Object '/82be48a6_6513_4f36_8bd3_140a72c73c41/ajoarmfikkpfnj91phkysfun_21.rem' has been disconnected or does not exist at the server.
at System.Data.Entity.Migrations.Utilities.DomainDispatcher.WriteLine(String text)
at System.Data.Entity.Migrations.MigrationsDomainCommand.WriteLine(String message)
at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object '/82be48a6_6513_4f36_8bd3_140a72c73c41/ajoarmfikkpfnj91phkysfun_21.rem' has been disconnected or does not exist at the server.
Now, a bit of googling suggests its because the temp object is being GC's while its trying to run, however it does this all the time. We reboot our servers, PC's clean code and delete migrations in the solution folder, and it might just work for us, but most of the time it doesn't.
In some cases, it creates the migration file in the solution ok, but then errors while running the update-database.
Its now becoming an issue and wondered if anyone had any ideas or solutions as Microsoft want an example solution to replicate it, however it's not easy to replicate outside our environment. In itself, our environment isn't special, it's VS2013 Pro, EF6.1.1, SQL 2012.

Categories

Resources