SlowCheetah executes after post-build events

后端 未结 4 526
孤独总比滥情好
孤独总比滥情好 2021-01-19 03:47

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 el

相关标签:
4条回答
  • 2021-01-19 03:54

    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>
    
    0 讨论(0)
  • 2021-01-19 03:57

    I have bumped into this problem too... decided to update to latest version of SlowCheetah (current 2.5.8), and this problem appears to have been fixed! No more problems using post-build events to deploy a project with transformed XML!

    After the NuGet package upgrade process, I had a strange issue, though... transforms were no longer happening. Editing the project like Naeem Sarfraz suggested, I have found that the SlowCheetah's PropertyGroup section was placed at the end of the .csproj.

    It was just a matter of moving it to the top, near the other PropertyGroup sections, and now it works like a charm!

    0 讨论(0)
  • 2021-01-19 03:59

    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"

    0 讨论(0)
  • 2021-01-19 04:11

    If you need to copy/move other .config files (other than web.config) around after the build before publishing here is how it can be done with Visual Studio 2013 (I didn't test it on earlier versions). This section can be added at the end of the .csproj file right before the closing tag </Project> and it'll be fired just before MSDeploy starts the Publishing process.

    <Target Name="MoveConfigFile" BeforeTargets="MSDeployPublish">
        <Move
            SourceFiles="$(IntermediateOutputPath)Package\PackageTmp\ThirdPartyApp.config"
            DestinationFolder="$(IntermediateOutputPath)Package\PackageTmp\bin"
            OverwriteReadOnlyFiles="true"
        />
    </Target>
    

    The company I work for purchased a third party product that needs to have a .config files in the bin folder along with its assembly in order to work.

    At the same time we need to process the product's .config file and be able to move it to the bin folder after transformations.

    The $(IntermediateOutputPath)Package\PackageTmp folder contains the whole application that will be copied over the target server.

    0 讨论(0)
提交回复
热议问题