Problem with "File copy" and Post-Build-scripts

I have some files in the project (so they’re in the repo) that need to be copied to the output directory.

I’d like to be able to use subdirectories, but the files are all written to the same directory as the compiled file.

Whatever I enter under “Copy Destination” doesn’t seem to have any effect.

(VS 2022, 17.13.6 - Elements 12.0.0.2981) (Doesn’t work as expected in Water either.)

Do you have a small test case that shows how you have this set up and expect work?

In general the Elements build (EBuild) acts on files based on their build action and file name; their file location relative to the project has no relevance to what is or isn’t done to the files, ie if you have

<Compile Include="Foo.pas"/>
<Compile Include="x/Bar.pas"/>
<Content Include="Foo.txt"/>
<Content Include="x/Bar.txt"/>

Foo and Bar will be acted upon in the same way, no matter their relative or absolute path; Bar.txt would not be copies into a subfolder called “x”, just because that’s where art happens to originale.

That is the expected behavior, currently.

“Copy Destination” looks to maybe be a VS thing, but its not a value that EBuild (currently) handles or honors in any way.

Application1.7z (20.9 KB)

Hi Marc,

i attached the testcase from the screenshot above.

Expected outcome is: Textfile1.txt is copied to $OutputDir and Textfile2.txt should be copied to $OutputDir\Sub\

Or is there another way to handle files (like images, html-documents…) that should reside in the project/repo, which should later end up in the output directory?

Tried to copy the files with a post-build-script, but i couldn’t get this to work either. (Exception for unknown Platform attribute for example, had no time to investigate further.)

Okay, that may be the Internet tin but it’;s now his this works :wink:

Tis might be the best option. What exactly did not work here?

It works this way in pure Microsoft-Solutions.

Post-Build-Stuff:

If there is no other chance, i have to get this running. For my first try, i wrote this “script” into the textbox in the “Post-Build Event Command Line”-dialog.

echo $(ConfigurationName) >> text.txt

This added the following to the elements-file:

<PropertyGroup>
   <PostBuild Condition="'$(Platform)' == 'Echoes'" Platform="Echoes">echo $(ConfigurationName) &gt;&gt; text.txt</PostBuild>
</PropertyGroup>

Building the solution failes…

1>------ Build started: Project: Application2, Configuration: Debug ------
1>Unhandled Exception:The attribute "Platform" in element <PostBuild> is unrecognized.  D:\Entwicklung\PoC\Application2\Application2.elements
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

If i remove the “Platform” attribute, the build succeeds and the script seem to be executed, but the Macros doesn’t seem to work.

|1>||         -> Task RemObjects.EBuild.Elements.ElementsProjectPostBuildTask started for Application2.|
|1>||            |
|1>||            D:\Entwicklung\PoC\Application2>echo   1>>text.txt |
|1>||         <- Task RemObjects.EBuild.Elements.ElementsProjectPostBuildTask finished for Application2, took 0,0356s (0.035s).|

Also, the Post-build Event dialog (invoked via the button at the Project-properties isn’t populated with the script content any longer. And i am not sure about the drop-down-list in this dialog…

(The drop-down seems to be correctly populated if i readd the Platform attribute - the whole dialog isn’t working properly if the attribute is removed. The options seem to have no effect, changes are not reflected in the elements file…)

Conclusion: If the “Platform Attribute” is included, the dialog seems to work, but the build doesn’t. If you delete it, it’s the other way around - but then the macros don’t work.

Sorry for the messy post, i edited it along testing. :wink:

EBuild is not MSBuild. It’s currently working the way we intend it to work.

Hmm, tis error seems to be coming from the MSBuild wrapper, when building in VS :(. Its can be picky with syntax <SBuild dense know, and the Platform= is EBuild specific… It should work without the platform filter, assuming you did not need your project to build n Wndows and Mac, that shuiod be fine.

$(ConfigurationName) is not a kn own variable. yo probably want $(Configuration)?

Oops. that seems to be a VS bug. Can you send me the project as-is that shows this, so I can log a ticket for the VS team…

thanx,
marc

But you should consider that… Why supporting “CopyFiles” when the folder-information is omitted? Haven’t tried out what happens when two files have the same name… like index.html or whatever. (Meanwhile i tried out what happens with two files with same name - the first file will be overwritten by the second one.)
As for now, i didn’t take a look at “ebuilds” - because there was no need for me to do so. I was not aware, what is done by MSBuild and what not.

I picked the macro from the dialog for testing… Maybe you create a ticket to check that, too. :wink:

Any fresh solution will do it. After creating a project → Properties → Post-Build Event (Pre-build not tested) - the dropdown is populated as seen in my previous screenshot. Always.
After entering a script, and entering the dialog again, the dropdown is populated correctly.
After deleting it, the dropdown is shredded again.

After opening a solution with a script in it, the dialog is also empty.

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">

Thats the one that matters. I don’t know why VS shows the other one, it probably just sows all variables MSBuild knows…

Okay, I’ll with this info.

Logged as bugs://E27166.