Michael
Michael

Reputation: 59

Visual Studio 2012 Express - Images don't get compiled/copied

maybe someone here can help me. I'm an amateur programmer having experience mostly in C#.

I started looking into C++ more the last few days and have run into a problem that I can't figure out. I'm using Microsoft Visual Studio 2012 Express for Windows Desktop.

Whenever I add resources, such as images (jpg, png, bmp) to my solution through the solution explorer, they don't get copied into the solution folder on the harddrive. What's even more of a problem is the fact that these images don't get copied/compiled when I compile my project!! As such, the program fails to run. If I manually copy the files to the, in this case, Debug folder, everything works fine. I set the "Content" property in the file properties to True as well as the "Add to project" property.

I can't figure this out for the life of it. :( In MS Visual Studio 2010 Express C# it always worked. Is there something I'm missing in the new version?

Btw, sorry if some of this doesn't make any sense. English is not my native tongue and I'm using Visual Studio in German.

Hope someone can give me an answer!

Best regards,

Michael

Upvotes: 4

Views: 2248

Answers (2)

Greg
Greg

Reputation: 1629

I have the same problem in my C++ Projects in Visual Studio 2013. I wasn't able to find a "copy if newer" or "copy always" option. If there is one in C++ let me know.

For a work around, i edited the [Projectname].vcxproj file.

Look for a line like this:

<None Include="./yourcontentfile.dll" />

or

<Content Include="./yourcontentfile.dll" />

Change that line to the following:

<None Include="./yourcontentfile.dll">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

or

<Content Include="./yourcontentfile.dll">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

This will copy that file to the output directory when you build.

Upvotes: 1

Vilx-
Vilx-

Reputation: 106970

In the solution explorer right-click the files and choose "Properties". Then change "Copy to output directory" to "Always". Possibly also change "Build Action" to "Content".

Upvotes: 2

Related Questions