Forum Discussion
abhisinghal
Apr 12, 2020Copper Contributor
Pre Build Action in Windows Application Project
Hi Trying to copy files to target folder in a pre build action with this command xcopy /y "$(SolutionDir)..\common\lib\AnyCPU\*.*" "$(TargetDir)" Getting error as follows: Severity Code Des...
scoban
Microsoft
Apr 15, 2020abhisinghal This appears to be an ordering issue, you need to move the <PreBuildEvent> propertygroup in the .wapproj below the import for the .targets at the bottom of the file.
Out of curiosity, what are you using the copy PreBuildEvent for? The Packaging Project will not pick up the files in the output folder to package unless you have another step to add them to the package, so I am not sure why you would want to copy these files there?
- abhisinghalApr 16, 2020Copper Contributor
scoban Thanks - Yes that was going to be the next question.
Even if the files are manually copied, the packager does not pick up files in the output folder to package.
So what is that additional step to do so ?
Thanks
- scobanApr 16, 2020
Microsoft
abhisinghal What is the scenario you are trying to enable that does not work with normal project references?
If you really need this behavior I would suggest using an itemgroup for the files that you want, This is not really recommended as the projects that you reference should be including all the files needed for packaging and they also include additional metadata that we use for other reasons. In other words this could have unintended side effects depending on what you are doing.
<ItemGroup> <None Include="SomeDir\*"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup>
- abhisinghalApr 17, 2020Copper Contributor
scoban Thanks - will try this.
The scenario I am trying to enable is this.
Project has a reference to LibraryA.dll , which is AnyCPU.
This LibraryA uses some platform specific dlls which are dynamically loaded using assembly resolver.
On the pre-build action, we copy files for both platforms to the output folder under sub folders x64 and x86, and then load depending on the platform on which app is running.
Do I need to do anything else to package above ?
Thanks