Scenario: We have a VS solution that includes an ASP web service/ASP Application and a deployment project for the ASP web service/ASP Application. The solution is added to source control. We want to build the MSI package only if changes were made to the ASP web service/ASP Application .

Solution: One way to achieve this would be to:

 

1.  Maintain an item group called WebServiceOutputs that includes all of the outputs that should result in the MSI getting generated and then keep it up to date. 

 

<ItemGroup>

    <WebServiceOutput Include="$(OutDir)\foo.dll" />

    <WebServiceOutput Include="$(OutDir)\bar.dll" />

</ItemGroup>

 

 

2.  Customize the AfterCompileConfiguration Team Foundation Build Target

 

<Target Name="AfterCompileConfiguration" Inputs="@(WebServiceOutput)" Outputs="$(OutDir)\MCWSDollar\MCWSDollarSetup\Setup\MCWSDollarSetup.msi;$(OutDir)\MCWSDollar\MCWSDollarSetup\Setup\Setup.exe">

<Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv&quot; &quot;$(SolutionRoot)\MCWSDollar\mcwsdollarsetup\mcwsdollarsetup.vdproj&quot; /Build &quot;Release|Any CPU&quot;"/>

    <Copy SourceFiles="$(SolutionRoot)\MCWSDollar\mcwsdollarsetup\Release\mcwsdollarsetup.msi; $(SolutionRoot)\MCWSDollar\mcwsdollarsetup\Release\Setup.exe" DestinationFolder="$(OutDir)\MCWSDollar\mcwsdollarsetup\Setup\" />

 </Target>

 

Additional Info:   Visual Studio Setup/deployment projects and Team Foundation Server