Post-Build Event: Copy files and TFS Build Service
Today I’ve got a problem with a Silverlight project and a custom post-build event. I have a Silverlight project that, on post-build event, must copy the xap inside another project in my solution. Easy I have to add a post build copy command as follow….
… ehm not so easy… It works on my local Visual Studio but when I commit this changes on TFS and TFS Build Service starts, a surprise…. error copy return errors… My aim is to make a copy locally on post build but not make this copy during TFS Build Service compile process. After a lot of searches on web and a lot of tries… a solution ![]()
- Open .csproj with an xml editor manually or with context menu (VSCommands 2010 Add-In for Visual Studio 2010 http://bit.ly/gnEAgb)
- Add <Target> Section as follow
<Target Name="AfterBuild" Condition="'$(BuildingInsideVisualStudio)' == 'true'"> <Copy SourceFile="$(Target)*.xap" DestinationFolder="$(SolutionDir)MyProject\MyFolder"/> </Target>
This works because variable BuildingInsideVisualStudio is true only in Visual Studio Environment.
Categories: C#, Visual Studio