abpframework/abp · error · Exception
There is no solution file (*.sln or *.slnx) and {_buildConfi
Error message
There is no solution file (*.sln or *.slnx) and {_buildConfigName} in the working directory and working directory is not a GIT repository ! What it means
Thrown by GetGitRepositoryUsingDirectory after walking up the directory tree without finding a .git folder. The reader falls back to inferring the repository from the working directory's git context; if no ancestor is a git repository (and there is no .sln/.slnx or abp-build-config.json), it cannot determine the repo and aborts.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Build/FileSystemDotNetProjectBuildConfigReader.cs:90
var directoryInfo = new DirectoryInfo(directoryPath);
do
{
var gitFolderPath = string.Concat(directoryInfo.FullName, @"\.git");
if (Directory.Exists(gitFolderPath))
{
using (var repo = new Repository(string.Concat(directoryInfo.FullName, @"\.git")))
{
var repositoryName = GetRepositoryNameFromRepositoryInfo(repo);
return new GitRepository(repositoryName, repo.Head.FriendlyName, directoryInfo.FullName);
}
}
directoryInfo = directoryInfo.Parent;
} while (directoryInfo?.Parent != null);
throw new Exception("There is no solution file (*.sln or *.slnx) and " + _buildConfigName +
" in the working directory and working directory is not a GIT repository !");
}
private string GetRepositoryNameFromRepositoryInfo(Repository repository)
{
var remote = repository.Network.Remotes.FirstOrDefault(r => r.Name == "origin");
if (remote == null)
{
throw new Exception("Remote origin is null for given repository !");
}
var remoteUrl = remote.Url;
remoteUrl = Regex.Replace(remoteUrl, @"\.git$", "");
remoteUrl = Regex.Replace(remoteUrl, "^git@", "https://");
remoteUrl = Regex.Replace(remoteUrl, "^https:git@", "https://");
remoteUrl = Regex.Replace(remoteUrl, ".com:", ".com/");View on GitHub (pinned to 7ed43b1931)
Solutions
- Run the ABP build command from inside a git working tree (git clone / git init the project first).
- Alternatively, place a .sln/.slnx or an abp-build-config.json in the working directory so the reader does not need git inference.
- If using a CI runner, ensure the checkout step clones the repository (not a shallow copy without .git) into the working directory.
- Verify the working directory path passed to the build command is the repo root or a subdirectory of it.
Example fix
# before: running in a non-git folder abp build # throws: no sln/config/.git # after: initialize git, or add a solution/config file git init abp build # or place a .sln / abp-build-config.json in the directory
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check: a .git ancestor, or a .sln/.slnx, or a build config must exist.
bool HasGitAncestor(string path)
{
for (var d = new DirectoryInfo(path); d != null; d = d.Parent)
if (Directory.Exists(Path.Combine(d.FullName, ".git"))) return true;
return false;
}
var hasSln = Directory.GetFiles(directoryPath, "*.sln").Any() || Directory.GetFiles(directoryPath, "*.slnx").Any();
var hasCfg = Directory.GetFiles(directoryPath, "abp-build-config.json", SearchOption.TopDirectoryOnly).Any();
if (!hasSln && !hasCfg && !HasGitAncestor(directoryPath))
{
throw new InvalidOperationException("No .sln/.slnx, abp-build-config.json, or .git repository found; run inside a git working tree.");
} Type guard
public static bool IsInsideGitRepo(string path)
{
for (var d = new DirectoryInfo(path); d != null; d = d.Parent)
if (Directory.Exists(Path.Combine(d.FullName, ".git"))) return true;
return false;
} Try / catch
try
{
var cfg = reader.Read(directoryPath);
}
catch (Exception ex) when (ex.Message.Contains("no solution file", StringComparison.Ordinal))
{
logger.LogError(ex, "Run 'abp build' inside a git working tree or add a solution/build-config file.");
throw;
} Prevention
- Run ABP build commands from within a cloned git repository.
- Ensure CI checkouts include the .git folder (avoid shallow/detached copies without it).
- Keep a .sln or abp-build-config.json at the repo root.
- Document the expected working directory for the build command.
When it happens
Trigger: Read was called in a directory with no .sln/.slnx, no abp-build-config.json, and no .git folder in any parent directory up to the filesystem root. The do/while loop in GetGitRepositoryUsingDirectory exhausts all parents and throws.
Common situations: Running 'abp build' in a freshly extracted zip that was never git-initialized; running outside any cloned repo; running in a temp/build-output directory detached from the repo; misconfigured CI checkout that did not clone.
Related errors
- There are more than 1 config (abp-build-config.json) file in
- Remote origin is null for given repository !
- Couldn't find repository name using remote origin url !
- Cyclic dependency found! Item: {item}
- Build failed!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/a102cfc969168aa0.
Report an issue: GitHub.