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 Description Project File Line Suppression State
Error MSB3073 The command "xcopy /y "E:\vs.com\AppSystem\..\common\lib\AnyCPU\*.*" """ exited with code 4. WAP.AppSystem D:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 1330
Seems like wapproj does not like macros in pre build actions because the macro expression disappears. Tried with other macro expressions - each one disappears on build.
Pl advise asap.
Thanks
- scoban
Microsoft
abhisinghal 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?
- abhisinghalCopper 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
- scoban
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>
- Tanaka_Jimha
Microsoft
Hi abhisinghal
Thanks for reporting this. We're following up with the Visual Studio team to see what the issue is with using macros in prebuild actions in the wapproj.
Tanaka