Standard language features missing when running build
Asked by Jay Marvin:

I have a powershell script that runs msbuild just fine to build a .NET application in a stnadard powershell window. When I run the same script from bamboo, C# language features are missing. E.g. "The type or namespace name 'List\<\>' could not be found." What needs to be done to have the script run "normally" from bamboo?

Thanks,  
Jay


Answers:
author: Jeyanthan I
body: Hi Jay,

As you say that you are able to execute the same script from PowerShell, it is possible that you are running the Bamboo agent as a different user in Windows (especially if you are starting the agent as a service, you might be running as LOCAL SYSTEM user and this user account has a different environment and home).

Is it possible for you to switch the user account as which the service is running to run as a local user as which you start via console? The process to switch to a local account [is explained in this page](https://confluence.atlassian.com/bamboo/running-bamboo-as-a-windows-service-as-the-local-user-416580754.html).

If you have recently upgraded Bamboo to 6.10 or above, you may also want to update the agent wrapper. This is stated in the Bamboo 6.10 "Version-specific upgrade notes" section of the [Bamboo upgrade guide](https://confluence.atlassian.com/bamboo/bamboo-upgrade-guide-720411366.html) and it is possible that this might have been missed. I will add the same below for reference:
>
> #### Remote agent wrapper update {#toc-hId--629420167}
>
> To address some knows issues, we updated the Tanuki wrapper used for Bamboo remote agent. Bamboo 6.10 is released with new version of the wrapper. If you're an upgrading user, we strongly recommend that you reinstall the wrapper to benefit from all bug fixes.
>
> To update the wrapper on a remote agent:
>
> 1. Stop the original agent.
> 2. Backup the BAMBOO_AGENT_HOME/conf/wrapper.conf file.
> 3. Remove the BAMBOO_AGENT_HOME/conf directory.
> 4. Download a new Remote Agent JAR from your Bamboo Server: http://\<BAMBOO_URL\>/admin/agent/addRemoteAgent.action.
> 5. Launch the remote agent.
> 6. This will create a new wrapper.conf file. If you want to re-enact your custom configuration in that file, you can do it now.

Hope that helps. Please share the outcome with us.

Cheers,  
Jey

comments: author: Jay Marvin
body: Indeed it was the user that bamboo was running withing Services. You have to make sure Visual Studio will build the project under a user that bamboo is running as.

Thanks!  
Jay


author: Jeyanthan I
body: Thanks for your update, Jay. I'm afraid it isn't clear to me if your Bamboo server is running as a **Local User** instead of **Local System** already and if you are seeing this when running on a remote agent or on a local agent. I wrote an article on the same explaining the need:

* [Run Bamboo service as a Local Service after upgrading to Bamboo 7.x](https://community.atlassian.com/t5/Bamboo-articles/Run-Bamboo-service-as-a-Local-Service-after-upgrading-to-Bamboo/ba-p/1403206)

Also, did you do a Bamboo upgrade recently? If so, you may have to run the agent wrapper update as I pointed earlier.

That being said, as you see that the same command works via console, I'm confident that this issue will not be seen when you start Bamboo via console by running *\<bamboo-install\>\\bin\\start-bamboo.bat* or your agent via *\<`bamboo-agent-home>\bin\`StartBambooAgent-NT.bat*

Cheers,  
Jey


author: Jay Marvin
body: Hi Jey,

We are using a new install of Atlassian Bamboo version 7.0.4 build 70018 - 14 May 20

We have to run as a local user, not local system, in order for the build to work: i.e. to see C# basic features such as Int32 and System, etc.

I found that /t:Restore is perhaps the main missing feature and not having it is the cause of my issue in general. Here is the full list of MSBuild flags/parameters that work for me.

/t:Rebuild /t:Restore /p:Configuration=Release /p:AppxBundle=Always /p:AppxBundlePlatforms="x64" /p:Platform=x64

Jay


author: Jay Marvin
body: P.S., Jey,

I have not tried your suggestions for starting Bamboo. I didn't set it up, our Admin did.


author: Jeyanthan I
body: Thanks for clarifying. I trust the suggestion I have proposed worked for you.

Cheers,  
Jey