File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
src/PostSharp.Engineering.BuildTools/Build Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -97,15 +97,16 @@ public static bool TryCreate(
9797 buildContext = null ;
9898
9999 // Use the repo directory from environment variable if provided, otherwise search from current directory
100- var searchDirectory = Environment . GetEnvironmentVariable ( EnvironmentVariableNames . RepoDirectory )
101- ?? Environment . CurrentDirectory ;
100+ var repoDirectory = FindRepoDirectory ( Environment . GetEnvironmentVariable ( EnvironmentVariableNames . RepoDirectory ) )
101+ ?? FindRepoDirectory ( Environment . CurrentDirectory )
102+ ?? FindRepoDirectory ( AppContext . BaseDirectory ) ;
102103
103- var repoDirectory = FindRepoDirectory ( searchDirectory ) ;
104104 var console = new ConsoleHelper ( ) ;
105105
106106 if ( repoDirectory == null )
107107 {
108- console . WriteError ( "This tool must be called from a git repository." ) ;
108+ console . WriteError (
109+ "This tool must be called from a git repository, or the environment variable REPO_DIRECTORY must be set to the root directory of the repository." ) ;
109110
110111 return false ;
111112 }
@@ -128,8 +129,13 @@ public static bool TryCreate(
128129 return true ;
129130 }
130131
131- private static string ? FindRepoDirectory ( string directory )
132+ private static string ? FindRepoDirectory ( string ? directory )
132133 {
134+ if ( string . IsNullOrEmpty ( directory ) )
135+ {
136+ return null ;
137+ }
138+
133139 if ( Directory . Exists ( Path . Combine ( directory , ".git" ) ) )
134140 {
135141 var gitIgnorePath = Path . Combine ( directory , ".gitignore" ) ;
You can’t perform that action at this time.
0 commit comments