Suppose we have a solution with three projects:
DownloadDataBase
is a console application that downloads data from web and creates a sqlite
db fileTest
is the main windows from application that uses the downloaded sqlite
database.TestLibrary
is a class library that is referenced by the Test project.I know How I can reorder the build of these three projects using Configuration Manager
from build menu. But The main question is : How can I customize build process of the solution so that:
DownloadDataBase
DownloadDataBase
sqlite
file from the last step to the resource directory of the Test
ProjectTest
project using the updated sqlite
file?Therefore every time that I build the new release I will have the latest data needed by my application.
Thanks for any help
You'll need to customize your MSBuild project files (i.e. .csproj
files).
For example, in your DownloadDatabase project, add at the bottom of the XML file, inside the <project>
element:
<Target AfterTargets="AfterBuild">
<Exec Command="$(ProjectDir)$(OutputPath)$(AssemblyName).$(OutputType)" />
<Copy SourceFiles="$(ProjectDir)$(OutputPath)file.db" DestinationFolder="$(SolutionDir)Test" />
</Target>
Maybe there's some mistake, but at the end of the day, you need to use MSBuild tasks to perform these actions.
See Exec and Copy MSBuild task documentation pages to get further details.