Home > C#, Visual Studio > Post-Build Event: Copy files and TFS Build Service

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

image

… 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 Light bulb

  • Open .csproj with an xml editor manually or with context menu (VSCommands 2010 Add-In for Visual Studio 2010 http://bit.ly/gnEAgb)

image

  • 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
  1. Non c'è ancora nessun commento.
  1. No trackbacks yet.

Lascia un Commento

Fill in your details below or click an icon to log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Log Out / Modifica )

Foto Twitter

You are commenting using your Twitter account. Log Out / Modifica )

Foto di Facebook

You are commenting using your Facebook account. Log Out / Modifica )

Connecting to %s

Follow

Get every new post delivered to your Inbox.