Task is to form Visual Studio 2010 project so, that during any build or publish some foo.exe
utility should be copied to output (bin
) directory.
Early I have made PostBuildEvent task in .csproj (MSBuild-file):
<PropertyGroup> <PostBuildEvent> Copy "$(SolutionDir)Tools\foo.exe" "$(ProjectDir)$(OutDir)foo.exe" </PostBuildEvent> </PropertyGroup>
But this is not universal. During publishing (Visual Studio 2010) foo.exe
appears in bin
directory, but is not copied to output publish directory. Maybe I do everything completely wrong and there is standard mechanism to include files in projects to be later, during build or publish, copied to bin
?
"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.
Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.
In Solution Explorer, right-click in your project and choose "Add... Existing Item". Locate the file in question (it can by any type, not just code), and next to the "Add" button, click the drop-down arrow and select "Add As Link".
There is and it is not dependent on post build events.
Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".
See MSDN.
I only have the need to push files during a build, so I just added a Post-build Event Command Line entry like this:
Copy /Y "$(SolutionDir)Third Party\SomeLibrary\*" "$(TargetDir)"
You can set this by right-clicking your Project in the Solution Explorer, then Properties > Build Events
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With