Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SlowCheetah executes after post-build events

I use SlowCheetah to transform my app.configs. I have a multi-project solution where one of the projects executes a post-build event where the output of the bin is copied elsewhere. I've found that SlowCheetah does it's transforms after the post-build event, so the app.config I'm copying is the pre-transformed version.

Does anyone have a suggestion of how I can execute my copy after the SlowCheetah transforms? Is this going to require that I write a custom build task?

like image 868
ScottC Avatar asked Sep 14 '12 11:09

ScottC


2 Answers

If you are using msbuild 4.0 for building your projects - you can hook to slowcheetah targets with new AfterTargets BeforeTargets attributes.

I dont know what exactly target name you want to hook after but this code could gave you base concept how to do this

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Some_Target_Name" AfterTargets="TransformAllFiles" >
            <Message Text="= Script here will run after SlowCheetah TransformAllFiles ="/>
    </Target>
<Project>

Edited: I installed SlowCheetah and found that AfterTargets attribute should be "TransformAllFiles". Just set up your target dependency AfterTargets="TransformAllFiles"

like image 106
Alexey Shcherbak Avatar answered Sep 21 '22 01:09

Alexey Shcherbak


Alexey's answer leads to the correct solution but here it is in full:

  • Right-click your project and select Unload Project
  • Now right-click the project and select Edit [your project name].csproj
  • Scroll to the bottom and uncomment the target named AfterBuild and add this attribute AfterTargets="TransformAllFiles"
  • Move your post build actions into this target using the Exec command:

An example:

<Target Name="AfterBuild" AfterTargets="TransformAllFiles">
 <Exec Command="ECHO Hello PostBuild World!" />
</Target>
like image 41
Naeem Sarfraz Avatar answered Sep 21 '22 01:09

Naeem Sarfraz