Visual Studio post-build, pre-build macros

Source: Internet
Author: User

Http://www.dotnetperls.com/post-pre-build-macros

You need to use post-build and pre-buildMacrosIn Microsoft Visual Studio 2008. You may have two projects that rely on each other but are separate. We can write a macro to copy files from one project to another after the first one is built.

This page provides an example of using build macros with a DLL in Visual Studio.

Macros in Visual Studio 2008

This approach offers one automatic solution to making the two projects work together, at least in a primitive manner. we will copy the compiled DLL to the C # solution's directory. we will use the following command on the Post-build event in Visual Studio.

 
Copy "{path1} dllname. dll" "{path2} dllname. dll"

Syntax notes.The words including the quotes are actual paths, and they are dos paths, so they use that funny "\" character. this code runs whenever you build the DLL project. however, let's look at a slightly different solution that is probably a bit better. here is a command in the pre-build event.

 
Copy "{path1} dllname. dll" $ (projectdir) dllname. dll"

Explanation.Visual Studio 2008 macros are essential environment variables contained within parentheses, preceded by the $ symbol-much like Perl. the green italics in the examples must be replaced by you. you can add a macro to a build command by clicking on its name and clicking insert. next are a couple example tokens.

 
$ (Projectdir) $ (targetfilename)
Summary

We looked at an example post-build event in the Visual Studio integrated development environment. one thing you can use pre-build and post-Build Events for is copying DLLs to different solutions at build time. this can automate some interactions between different projects. here we saw a way to use these macros with a DLL after building a project.

Visual Studio tips

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.