Visual Studio copy file to output directory

Asked

Viewed 1,265 times

0

Hello!

In my project I have an xml file and I want to copy this file to the output directory at the time of compilation so that it stays together with the executable file and other files. For this I created a post-compilation event to copy this file to the output directory. But when compiling it is failing the event. I’m almost sure it must be a related error on the way to the file but I’m not sure.

inserir a descrição da imagem aqui

Here’s the event briefing I’m trying to get:

copy SqlCommands.xml $(OutDir)

Error:

Gravidade Código Descrição Projeto Arquivo Linha Estado de supressão Erro The command "copy SqlCommands.xml ..\bin\Debug\" exited with code 1. FoxVideoManagerBackend C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 4714

2 answers

1

According to this documentation, that I think applies to your case tb, this exited with code 1 is: No files Were found to copy.

This command below is how I copy in a project of mine, it works perfectly here:

powershell -Command "xcopy '$(ProjectDir)Content\a\*' '$(ProjectDir)DIRPARACOPIA\Content\Content\a\' /s /e"

About fixing yours, I really can’t using just the question information, maybe the whole code will help more.

Anyway I’ll guess that this "Sqlcommands.xml" is not in the root directory from where it runs the command, tries to put the whole path to SQL or use the variables $(ProjectDir), etc..

  • Ton Angelo’s answer solved in a simpler way, but it also worked through events using variables ProjecDir and TargetDir. Taking advantage of the hook of the question, why is it necessary to wrap the variables in quotes? I’m a little rusty on DOS, but it will be due to spaces in folder names?

  • His answer took wave, that yes hahaha, in my case I do not use because I give a -replace in the middle of the road there and such. Look at the quotes I’ll confess I was making a mistake in this until a friend here hit his eye, talked about the spaces and had the quotes put. It worked perfectly and I didn’t do any more research than he said.

1


File properties don’t have the option to copy locally? Does what you need automatically

Browser other questions tagged

You are not signed in. Login or sign up in order to post.