The Build Events in Visual Studio makes life much easier. I use them primarily to copy the files around after building the projects, but we can use them to run any command that we want. We have two types of build events.
Let's have a look at the options.Go to Solution Explorer and right-click on the project then select Properties then go to the Build Events tab.If you click on the Edit Pre/Post build event command line button the following dialog will open.But, when we click the "Macros", we can see how Visual Studio can really help us out:The following I will explain how I use them.First ScenarioI have a requirement to maintain three different configurations (web.config) files for Web.LocalDev.config, Web.QA.config and Web.Production.config. When I build the project based upon the Configuration name selection the main web.config file must be updated. Assume we select the Production configuration name then the main Web.config file will be updated with Web.Production.config.The following is the procedure to do that.
Second ScenarioI have two js (JavaScript) files, Omniture.qa.js and Omniture.Prod.js. When building the project Omniture.Prod.js must be updated with Omniture.qa.js.Paste the following script in the Pre/Post build event command line:
xcopy "$(ProjectDir)..\Lib\*" "$(TargetDir)" /y /r"$(ProjectDir)copyifnewer.bat" "$(ProjectDir)\Scripts\Omniture.qa.js" "$(ProjectDir)\Scripts\Omniture.Prod.js"
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: