Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,741
Community Members
 
Community Events
184
Community Groups

MSBuild PreBuild event failing to copy file

We have a few projects in our VS 2019 Solution that take their config files from other projects and then perform various config transforms on them.

In the PreBuild event I have the following,

xcopy "$(SolutionDir)$(TargetName)\web.config" "$(ProjectDir)" /Y /F

When Bamboo runs the MSBuild command it fails with,

error MSB3073: The command "xcopy "..\Project1\web.config" "D:\bamboo\build-dir\50954242\WS-PROD2-COMPILERELEASE\SolutionFolder\Project2\" /Y /F" exited with code 4. 

If I copy the command from the error message and execute it at a command prompt it completes successfully.

 

Hoping someone has some suggestions on resolving this issue.

 

Cheers

Phil

 

2 answers

1 accepted

1 vote
Answer accepted

Ok, after beating my head around sideways with this, I couldn't getting anything to work from within Bamboo. All the different permutations of "copy" commands worked when executed from the command prompt. They even worked when I ran MSBuild from the command prompt.

Ended up re-wiring this as a BeforeBuild Target in the project file.

<Target Name="BeforeBuild">
<ItemGroup>
<ConfigToBeCopied Include="$(SolutionDir)$(TargetName)\web.config" />
</ItemGroup>
<Copy SourceFiles="@(ConfigToBeCopied)" DestinationFolder="$(ProjectDir)" />
</Target>

With that setup and the PreBuild event removed everything built successfully within Bamboo.

 

Cheers

Phil

Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 02, 2020

Hey Phil,

I'm sorry I wasn't able to help you solve what you were trying to do, but I'm glad you found another way to get the results you were looking for.

-Jimmy

0 votes
Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 01, 2020

Hi @Phil Carter,

Looking up what exit code 4 is, I think it's complaining about the path you are passing to the command.

When a Bamboo agent runs a build plan it puts everything into a working directory and runs command from the root of the working directory, unless you specify a sub-directory in the GUI build plan task editor.

I would make sure that that path you are trying to execute the command from is the same as the directory structure from within the agent working directory.

I hope that helps!

-Jimmy

Thanks for the reply Jimmy

When I run the copy from the command prompt, I'm running it from the Bamboo build directory and it works without any issues.

Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 01, 2020

That's a really weird one.  Looking at some of the solutions posted here:

https://stackoverflow.com/questions/5626557/what-is-going-wrong-when-visual-studio-tells-me-xcopy-exited-with-code-4

One of the solutions is talking about the dependency order where something is trying to write to the directory at the same time that you are trying to copy the files that could cause this type of issue.

I'm pulling at strings here but it might be something to check out?

I hope that helps!

-Jimmy

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events