Home > Software design >  Visual Studio: How can I find corresponding CLI command for a GUI build operation?
Visual Studio: How can I find corresponding CLI command for a GUI build operation?

Time:11-02

I've been a linux/make guy and recently I'm learning to build UE5 engine from VS 2022. I need to figure out a CLI way to build it.

For example, I right click on one of the modules (not sure if it's the most proper name) and choose 'Build' then the build will start. I want to automate the procedure using CLI.

How can I find the corresponding CLI command for this manual operation?

enter image description here

CodePudding user response:

I don't have access to the Unreal Engine source code and I don't know if Epic has done anything highly unconventional.

From your start menu launch the "Developer Command Prompt for VS2022". This is a shortcut file for launching the Windows command line with a batch file run to set up the PATH and other environment variables for the Visual Studio development tools.

Visual Studio project files (.csproj for C# and .vcxproj for C for example) are MSBuild files. (MSBuild was inspired by Ant, if that helps.)

Solution files (.sln) are a completely different format but MSBuild can build a solution file.

From the screenshot in the question I can see that the solution is UE5 which will be UE5.sln. I can also see that you want to build a C project. I'm guessing the project may be named BenchmarkTest (BenchmarkTest.vcxproj)?

MSBuild has a notion of targets. A target always has a name and it groups a set of tasks to be performed. (It's like a makefile rule in some respects but it's not the same.)

Solutions and projects created with Visual Studio support some standard targets. The 'Build', 'Rebuild', and 'Clean' menu items map directly to some of these targets.

Visual Studio solutions and projects support Configurations and Platforms. The standard Configurations are Debug and Release. The screenshot shows a non-standard configuration of Develop. The screenshot also shows a platform of Win64.

In the Developer Command Prompt, msbuild should be in the PATH. Try the following command:

msbuild --version

To build the solution with the default target (which is 'build') and the default configuration and platform:

msbuild UE5.sln

To run a 'clean':

msbuild UE5.sln -target:clean

The target switch can be shortened to -t.

The configuration and platform are passed as properties using the -property switch. The short form is -p. Multiple property switches can be provided and multiple properties, delimited by ';', can be provided in one property switch.

msbuild UE5.sln -t:rebuild -p:Configuration=Develop -p:Platform=Win64

or

msbuild UE5.sln -t:rebuild -p:Configuration=Develop;Platform=Win64

To build the BenchmarkTest project, specify the project file:

msbuild BenchmarkTest.vcxproj -t:build -p:Configuration=Develop;Platform=Win64
  • Related