Building C++ project using ms build in BitBucket pipeline
Asked by Basavaraj B S:

Hi Team,

I am trying build the C++ project through Bit Bucket Yaml pipeline, i have installed all necessary tools like VS,MSbuild but its throwing me this error.![msbuild error.PNG](/t5/image/serverpage/image-id/300651iEB142D3767D78B84/image-size/large?v=v2&px=999 "msbuild error.PNG")


Answers:
author: Theodora Boudale
body: Hi Basavaraj,

Based on your screenshot, it looks like you are using a Windows Runner for Pipelines. Windows Runners use PowerShell to run pipeline steps on your Windows machine (host device). The error you get indicates that PowerShell does not recognize the MSBuild command.

Can you try running that command outside of a Pipelines build? Try cloning the repo on that machine, then use PowerShell to navigate to the repo directory and run the command that is failing. This is to narrow down if the issue is specific to the Pipelines runner or not.

If you face the same issue outside of the runner, you can check the following StackOverflow question and its answers on how to use MSBuild in PowerShell:

* <https://stackoverflow.com/questions/20655456/executing-msbuild-task-from-powershell>

If you're still experiencing issues, you can also check Microsoft's Q\&A and ask a question about how you can use MSBuild in PowerShell:

* <https://learn.microsoft.com/en-us/answers/>

Kind regards,  
Theodora

comments: author: Basavaraj B S
body: Hello [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086)

I found out that the environment I set up the host machine was insufficient to build (i.e as per my understanding ms build was recognising ,visual studio was not installed efficiently ).

Now I am able to run the pipeline which is recognizing the necessary supportive tools, But I am facing the following challenges.

I am trying to build the bit bucket yaml pipeline written in C++ - MFC .

![Pipeline.yaml.png](https://community.atlassian.com/t5/image/serverpage/image-id/301080iE77CBC86970230CB/image-size/large?v=v2&px=999 "Pipeline.yaml.png")

When I am trying run the pipeline it is throwing the error (image attached).

![error.png](https://community.atlassian.com/t5/image/serverpage/image-id/301082i076DA09BFC9BDBF3/image-size/large?v=v2&px=999 "error.png")

I am running the runners in my host machine environment which is setup with Visual Studio 2019 (installed necessary MFC, C++ build, MS Build).

Based on my online search, the suggestion provided was to ensure correct UNICODE settings, and I have configured them appropriately according to my understanding. When attempting to locally build this project using Visual Studio 2019, it compiles without any issues.

Based on my online search ,the error C2039 occur when the Unicode Character is not Set , But in my host machine setup I have set Unicode Character

Is there a connection between the runner's setup on the host machine and the pipeline? Is it mandatory to have Visual Studio installed on the host machine, or is the MS Build file alone sufficient for pipeline builds? What are the prerequisites necessary for building the pipeline of a C++ project?

![unicode character set.png](https://community.atlassian.com/t5/image/serverpage/image-id/301081i8CF134A523BE2444/image-size/large?v=v2&px=999 "unicode character set.png")

I am seeking guidance on resolving this matter so that I can successfully build the C++ project using the Bitbucket YAML file pipeline.


author: Theodora Boudale
body: Hi Basavaraj,

Windows Runners use PowerShell to run pipeline steps on your Windows machine (host device). The only prerequisite for a build on a Windows runner is that any tools required for the build are installed on the host machine and also that the commands you have in your yml file can run on PowerShell.

The question of which tools need to be installed on the host machine for specific projects and any build-specific errors are outside the scope of our support. The relevant question here is, does this build run on PowerShell outside of the runner?

If it doesn't, then the question is, how do you make this build run on PowerShell? This is something that you can ask at a forum or the support team of the tools you are using.

You can rule out if this is a runner-specific problem by following these steps:

* Clone the repo on that host machine using PowerShell
* Navigate to the repo directory
* Run the commands from your yml file

If the commands fail as well, then this is not a runner-specific issue. You first need to make these commands work in PowerShell, and then they should work with the Windows runner.

If the commands don't fail on PowerShell but fail when using the runner, then we would need to see the commands and full output of the successful command that was run on PowerShell, outside of the runner, and also of the failed command with the runner.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud