Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I get the current Project Path within the c# build files?

I'm trying to add some compiler definitions that require I get the project directory. More specifically I'm getting the git commit count for my project.

I scoured through some source files to try and find some kind of function or variable to get this information and I found GetUProjectPath. Unfortunately when I try to use it I get this error:

 error CS0103: The name 'GetUProjectPath' does not exist in the current context

I'm using it in my ModuleRules constructor for my project inside <Project Name>.Build.cs. I tried using System.IO.Directory.GetCurrentDirectory() but that just gave me the directory of the engine source.

Any insight would be appreciated!

Edit: Just to cover my basics I also did UnrealBuildTool.GetUProjectPath() and get another error.

 error CS0234: The type or namespace name 'GetUProjectPath' does not exist in the namespace 'UnrealBuildTool' (are you missing an assembly reference?)

I have pretty much never used C# but my impression is that due to using UnrealBuildTool; being at the top that I don't need specify the namespace UnrealBuildTool, but I could be wrong. Either way I'm still getting an error.

Product Version: UE 4.7
more ▼

asked Jun 03 '15 at 03:08 AM in Everything Else

avatar image

676 15 11 127

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Found a solution to my problem!

There is a variable called ModuleDirectory defined in ModuleRules which gives you the source directory of the project. I just used that to get my root project folder.

edit: To provide an example I used this in my projects ModuleRules.

 public string ProjectRoot
            return System.IO.Path.GetFullPath(
                System.IO.Path.Combine(ModuleDirectory, "../../")
more ▼

answered Jun 11 '15 at 05:48 AM

avatar image

676 15 11 127

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question