博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Visual Studio Post-Build, Pre-Build Macros
阅读量:5937 次
发布时间:2019-06-19

本文共 1793 字,大约阅读时间需要 5 分钟。

 

You need to use post-build and pre-build macros in 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.

Visual Studio pre-build macro

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

Macros in Visual Studio 2008

This approach offers one automated 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"
DLL (Dynamic Link Library)

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 essentially 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.

 

转载于:https://www.cnblogs.com/RobotTech/archive/2012/03/12/2391338.html

你可能感兴趣的文章
Zabbix3.2.6之通过JMX监控Tomcat
查看>>
重新定义工作站的“边界”
查看>>
第三方推送已死
查看>>
回档|神经网络
查看>>
Apache Spark源码走读之12 -- Hive on Spark运行环境搭建
查看>>
阿里云跨服务器文件拷贝
查看>>
GetWindowRect
查看>>
6.<1>四则运算的研究[栈]
查看>>
java程序员笑不死的经历ส้้้้้้้้้
查看>>
php-fpm配置
查看>>
c++头文件和#include 学习笔记
查看>>
第四天(考试)
查看>>
关于VUE的路由地址问题
查看>>
node-buffer解读
查看>>
Vue 2.x折腾记 - (22) Vue 打包图片在safari不显示的问题
查看>>
ES6中的class
查看>>
iOS - swift项目接入bugly - 报错, 配置符号表,下载Java环境,
查看>>
oracle sql语句实现累加、累减、累乘、累除
查看>>
SCNetworkReachabilityRef监测网络状态
查看>>
3D地图的定时高亮和点击事件(基于echarts)
查看>>