none
TFS 2010, Web Site Projects (WSP) + Web Deployment Projects (WDP)

    Question

  • I'm trying to use TFS 2010 to create a Deployment package (MSDeploy/WebDeploy) for a Web Site Project (not a Web Application Project) targeted to the 3.5 Framework.  For this Website, I've already downloaded the latest Web Deployment Project add on for VS2010 and added it to my solution.

    When I'm in Visual Studio, I can right click the Web Deployment Project and select "Build Deployment Package", and create the Deployment package.  However, I can't seem to get TFS 2010 Builds to create the Deployment package.  Does anyone have any ideas on how to do this? 

    I can't seem to find any documentation for TFS 2010, Web Site Projects + Web Deployment Projects.

    Thanks,

    Felix

    Monday, January 31, 2011 7:24 PM

Answers

  • Hi All!

    I'm the original poster and after a lot of tweaking and trial & error, I am FINALLY able to get TFS Build working with a WSP + WDP.  However, this solution is quite long and required some significant amount of tweaking to the *.wdproj file.  So if you feel uncomfortable teaking and understanding MSBuild, then this solution might not be for you.  I had to do some analysis of the Publishing .targets files to get this to work.

    I also caught some bugs in the WDProj implementation and this hopefully fixes some of those issues.  The nice thing is that I was also able to put in a hack to get the web.config transformations working.

    And Finally, THIS SOLUTION IS SPECIFIC TO MY ORGANIZATION'S REQUIREMENTS.  For example, if you were to customize and tweak the Build Outputs, I can't guarantee that this solution will work for you!  But hopefully it will give you a good enough start.  There may also be some bugs in my tweaks, but again, this works for my organization.


    So here were my requirements:
      -Take an existing "Web Site" project (WSP) and incorporate it into TFS Build and have it create an MSDeploy Package.  If possible, also use web.config transformations for the different Project Configurations.
     
      -At our organization, we choose to Build all the Project Configurations at the same time so the packages match (except for configs and other lame things like File Timestamps - since TFS modifies the file timestamp upon getting latest!  URGH!!!  Source control should NEVER change the file but that's another rant!).  We created and build the following Configurations in TFS - DEV, QA, STG, and PROD.
     
    Solution - (note, this is specifically for VS2010 WSP and WDP)

    1.  Add the 2010 Web Deployment Project to the Web Site Project
    2.  Create new Project Configurations for DEV, QA, STG, and PROD.  Note that this will only create the Project Configuration for the wdproj since Web Site Projects don't support Configurations
    3.  Add the following files to the Web Site Project:
        -web.DEV.config.exclude
        -web.QA.config.exclude
        -web.STG.config.exclude
        -web.PROD.config.exclude
       
       The ".exclude" is to prevent the files from being included in the Web Site Project
    4. Edit the *.wdproj file and put in the following tweaks (here's where the fun begins...)

    aTweak: Add another "Any CPU" condition into the "PropertyGroup" elements for each configuration. 
        Reason: When Building in Visual Studio, the Project Configuration is passed as "DEV|AnyCPU" (with no space).  However, when building with TFS, it passes the Project Configuration as "DEV|Any CPU" (with a space).  Therefore, the PropertyGroups tailored to each Build Configurations weren't being picked up.
        Example:
          Change
            <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DEV|AnyCPU'">
            to
            <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DEV|AnyCPU' Or '$(Configuration)|$(Platform)' == 'DEV|Any CPU'">
           
    bTweak: Add a new PropertyGroup to point to the Build Configuration specific Transformation web.config files
        Reason: These will be called by a custom target to force the web.config transformations
        Example:
           Add
            <PropertyGroup>
              <TransformInputFile>$(SourceWebPhysicalPath)\web.config</TransformInputFile>
              <TransformFile>$(SourceWebPhysicalPath)\web.$(Configuration).config.exclude</TransformFile>
              <StackTraceEnabled>False</StackTraceEnabled>
            </PropertyGroup>
           
    cTweak: Add a new PropertyGroup to extend the "CollectFilesFromProjectFolderDependsOn".
        Reason: I encountered an error when trying to create the package from TFS Build.  The MSBuild Target "CollectFilesFromProjectFolder" has the incorrect Source Location for the Package.  Also the "ParameterizeTransformWebConfigCore" has the incorrect Source Location for the Source Root Path.  It is looking for the output at:
              Sources\MAIN\MyWebSite\MyWebSite_deploy
           but the correct output from TFS is at:
              Sources\MAIN\MyWebSite\MyWebSite_deploy\obj\DEV\TempBuildDir
        Example:
          Add
      <PropertyGroup> <CollectFilesFromProjectFolderDependsOn>SetRootPathFolder;$(CollectFilesFromProjectFolderDependsOn)</CollectFilesFromProjectFolderDependsOn>
      </PropertyGroup>
     
    dTweak:  Add the new "SetRootPathFolder" for c above.  Make sure it's after the "Import" of the Microsoft.WebDeployment.targets
        Reason:  See letter "c" above
        Example:
          Add
      <Target Name="SetRootPathFolder">
        <PropertyGroup>
          <WebPublishPipelineProjectDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineProjectDirectory>
          <WebPublishPipelineSourceRootDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineSourceRootDirectory>
        </PropertyGroup>
      </Target>
       
    eTweak:  After the Microsoft.WebDeployment.targets Import, add the following target to get the customzied web.config transformations to work
        Reason:  Allows us to use web.config transformations for WSP+WDP projects
        Example:
          Add
      <Target Name="TransformWebConfig_MyWebsite" Condition="'$(Configuration)'=='DEV' Or '$(Configuration)'=='QA' Or '$(Configuration)'=='STG' Or '$(Configuration)'=='PROD'">
        <Message Text="WD Target Dir: $(WDTargetDir)" />
        <TransformXml Source="$(TransformInputFile)"
                      Transform="$(TransformFile)"
                      Destination="$(WDTargetDir)web.config"
                      Condition=" '$(Configuration)' != '' "
                      StackTrace="$(StackTraceEnabled)" />

        <!-- Copy the transformed web.config to the MyWebSite_deploy folder -->
        <!-- This is because the Package looks for the transformed web.config in the file below.  If this
             is not added, then the Package picks up the untransformed web.config -->
        <Copy SourceFiles="$(WDTargetDir)web.config"
              DestinationFolder="$(MSBuildProjectDirectory)\$(TempBuildDir)" />
      </Target> 
       
    fTweak:  In the "AfterBuild" target, make the call to custom TransformWebConfig Target
        Reason:  This will call the customized target to transform the web.config
        Example:
          Add
      <Target Name="AfterBuild">
        <CallTarget Targets="TransformWebConfig_MyWebSite" />
      </Target>
     
    gTweak:  In the BeforeBuild Target, explicitly copy the Project References if the Solution File is built.
        Reason:  If you point TFS Build to build the Solution File, it will fail because the Project References aren't copied
        Example:
          In the <Target Name="BeforeBuild"> Add:
         
            <Copy
              SourceFiles="@(References->'%(FullPath)')"
              DestinationFolder="$(_FullSourceWebDir)\Bin\"
              ContinueOnError="true"
              SkipUnchangedFiles="true"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
             
    hTweak:  In the BeforeBuild Target, explicitly copy the Project References if the "*.wdproj" is build directly
        Reason:  I ran into an issue where the Dependencies weren't being copied correctly if pointing TFS build directly to the
                 *.wdproj file. This fixed it
        Example:
          In the <Target Name="BeforeBuild"> Add:
         
            <Copy
              SourceFiles="@(References->'%(FullPath)')"
              DestinationFolder="$(MSBuildProjectDirectory)\$(CopyBeforeBuildTargetPath)\Bin\"
              ContinueOnError="true"
              SkipUnchangedFiles="true"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />

    5.  After the Project File is setup, go to the TFS Build Definition.  In the Process->"Items to Build" section, add the configurations for "DEV|Any CPU", "QA|Any CPU","STG|Any CPU","PROD|Any CPU".

    6.  Point the Projects to build to build the *.wdproj file
    7.  Under "Advanced" add the MSBuild Arguments:
           /t:Package /p:DeployIisAppPath="Default Web Site/MyWebSite"
          
    8.  Kick off the Build, and an MSDeploy Package is created!


    Hope this works for some of you, or at least gets you started in the WDProj tweaks.  Also, if you don't need the web.config transformations, then some tweaks here might not be needed.

    Good luck to all of you!

    Friday, April 20, 2012 12:21 AM

All replies

  • Hello Felix,

    You can out your web application into source control and use TFS to build it. In the TFS2010, you should first create a new build definition, and define build process to build and deploy your web application.

    For more information on web deployment using web deploy in Team Build 2010 in general, see this post:
    http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html

    In addition, the following post discuss the similar issue as yours, please check:

    http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/fcf88965-5b24-4e2e-a524-4ee3ceb5c8e5

    Thanks,


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 01, 2011 4:20 AM
    Moderator
  • Hi Vicky,

    Thanks for replying back to my post.

     

    However, I'm aware of all the blogs and articles that Vishal has posted (as well as Scott Gu & Hanselman).  The problem I'm running into is building a Web Site Project (WSP) - not a Web Application Project (WAP) like those articles refer too.

     

    I've read countless blogs, forum posts, and MSDN articles, but I can't seem to find any resources on Packaging VS 2010 Web Site Projects with the Web Deployment Project add on.  That's when I decided to post to this forum.

     

    It seems that when I create a Web Site Project with a Web Deployment Project, and add the following parameters to the TFS Build:

    /P:CreatePackageOnPublish=true /P:DeployOnBuild=true

    it does not create the zip package as expected.  

     

    If I do the same with a Web Application Project, I have no issues creating the zip package.  However, this site that I'm working with is rather large (we're talking thousands of files) and only contains static files.  So unfortunately, it's going to be a bit of work to clean up all the files to migrate it to a Web Application Project.

    I'm hoping to keep it as a Web Site Project before we migrate it over to a WAP.

     

    Tuesday, February 01, 2011 4:48 AM
  • I'm in pretty much the same boat. We are demoing TFS 2010 at the moment and all our web projects are web site projects not web applications. I was trying to see if there is a way to avoid web application projects but it doesn't appear that Web Deployment Projects integrates into TFS 2010 in a pleasant way.

     

    Monday, February 07, 2011 9:39 PM
  • So nothing more on this?  It seems Web Site Projects are viewed as black sheep or something, because they seem to be completely ignored in a lot of documentation - and, it appears, by MS as well.

    We're in the same boat, trying to figure out how to work a WSP (NOT a WAP) into TFS2010.

    Thursday, May 19, 2011 12:20 PM
  • Sorry haven't notice this thread till someone forward to me.

     

    Open your project file and add the following workaround to it.

       <PropertyGroup>

        <AfterBuildDependsOn>$(AfterBuildDependsOn);$(PrepareForRunDependsOn)</AfterBuildDependsOn>

      </PropertyGroup>

     

      <Target Name="AfterBuild" DependsOnTargets="$(AfterBuildDependsOn)">

      </Target>

     

    Alternativvely, To avoid dirty your project file. 

    You can drop a  WDP ProjectName.wpp.targets  in that WDP project folder have content like the following

     

      <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <AfterBuildDependsOn>$(AfterBuildDependsOn);$(PrepareForRunDependsOn)</AfterBuildDependsOn>
      </PropertyGroup>
     
      <Target Name="AfterBuild" DependsOnTargets="$(AfterBuildDependsOn)">
      </Target>
    </Project>

     

    This is a bug in our WDP targets file. The publish target file assume all projects are coming from Microsoft.common.targets.

    Well, WDP doesn’t  include the Microsoft.Common.targets. We will try to fix the issue in the next release.

     

    Thanks -Ming

     

     

    Wednesday, September 14, 2011 10:02 PM
  • Is this properties page part of a Web Deployment Package?  I'm not sure where to look for this Project file in a website project?  Can you give a few more detailed instructions please.  This would be huge for a lot of us.
    Tuesday, September 20, 2011 8:51 PM
  • I believe Ming is referring to the .wdproj file (from the Web Deployment Package add on).

     

    However, I tried the following suggestions by modifying my wdproj file and even with the parameters:

    /p:CreatePackageOnPublish=true and /p:DeployOnBuild=true

    I still cannot get TFS Build to create a WebDeploy package.

    Tuesday, September 20, 2011 9:01 PM
  • I tried this solution again and unfortunately I still can't get TFS Build to create a package from a wdproj.

     

    It looks like TFS Build will build the WDP Project, but when it gets to the part of creating the package, MSBuild fails on the CollectFilesFromProjectFolder task.   

    CollectFilesFromProjectFolder:
      Gather all files from project folder except in the exclusion list.
    Done Building Project "C:\xxxx.wdproj" (Package target(s)) -- FAILED.

    The "C:\xxxx.wdproj" is a sample to hide sensitive information. 

    I believe that task is actually failing from the CollectFilesInFolder task.  This is the error I get when looking at the Verbose MSBuild log:

    Using "CollectFilesinFolder" task from assembly "C:\Program Files\MSBuild\Microsoft\WebDeployment\v10.0\\..\..\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll".
    Task "CollectFilesinFolder" (TaskId:14)
    Done executing task "CollectFilesinFolder" -- FAILED. (TaskId:14)

     

     

    Monday, October 03, 2011 8:51 PM
  • Exactly the same problem here.  We use Web Site projects because the .net literature indicated they would be best for our needs.  I just watched Visahl's presentation but none of the information is applicable to a web site project.
    Thursday, October 06, 2011 4:04 PM
  • Exactly the same problem here.  We use Web Site projects because the .net literature indicated they would be best for our needs.  I just watched Visahl's presentation but none of the information is applicable to a web site project.

    I too am running into same problem. I have a WebSite Project and I am trying to create a deployment package for that under my build output. I am using WebDeploy on the build server and passing these arguments  in the build definition:

    /P:CreatePackageOnPublish=true /P:DeployOnBuild=true

     

    All the files are present in the build output but the package is just not created. Please let me know if there is a solution for this.

    Friday, October 07, 2011 4:29 PM
  • I was also having the same problems.

    Looking at MSBuild documentation to create a WSP, http://msdn.microsoft.com/en-us/library/ee231588.aspx, it seems that using the /t:package argument only works on .*proj files. Using this argument on a .sln file causes MSBuild to throw an error.

    My first workaround option was to specify all .*proj files in the build definition list of items to build and put the /t:Package as an additional MSBuild Argument. Using this method puts a restriction on only being able to specify proj files in the build definition in Team Build.

    Another option would be to create a batch file to call MSBuild on the projects that need a WSP package to be created. Call the batch file from an InvokeProcess method in the build template.

    You could setup a post build event also to call itself, but you would need to put a condition on the build event so that you don't end up in an endless loop calling MSBuild on itself.
    Example: if $(ConfigurationName) == Release "$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" /t:Package $(ProjectPath) /p:Configuration="Debug"

    Hope this helps.


    • Edited by RBlis Thursday, November 10, 2011 11:34 PM
    Thursday, November 10, 2011 11:33 PM
  • In my case it's not working too. I tested the MSBuild arguments on the build definition for a web application and it worked perfectly fine. But, when I try to do it with the web site it's like MSBuild was completely ignoring the arguments since the build finished successfully but apparently no action is done in order to make the deployment.

     

    Please provide us some guide on this challenge!

     

    Thanks

    Friday, November 25, 2011 2:00 AM
  • DITTO! Please?
    Monday, December 19, 2011 8:19 PM
  • I was also having the same problems.

    Looking at MSBuild documentation to create a WSP, http://msdn.microsoft.com/en-us/library/ee231588.aspx, it seems that using the /t:package argument only works on .*proj files. Using this argument on a .sln file causes MSBuild to throw an error.

    My first workaround option was to specify all .*proj files in the build definition list of items to build and put the /t:Package as an additional MSBuild Argument. Using this method puts a restriction on only being able to specify proj files in the build definition in Team Build.

    Another option would be to create a batch file to call MSBuild on the projects that need a WSP package to be created. Call the batch file from an InvokeProcess method in the build template.

    You could setup a post build event also to call itself, but you would need to put a condition on the build event so that you don't end up in an endless loop calling MSBuild on itself.
    Example: if $(ConfigurationName) == Release "$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" /t:Package $(ProjectPath) /p:Configuration="Debug"

    Hope this helps.


    Thx for posting. I'm in the same boat - going to try one of your suggested workaround.
    Thursday, April 19, 2012 9:05 PM
  • Hi All!

    I'm the original poster and after a lot of tweaking and trial & error, I am FINALLY able to get TFS Build working with a WSP + WDP.  However, this solution is quite long and required some significant amount of tweaking to the *.wdproj file.  So if you feel uncomfortable teaking and understanding MSBuild, then this solution might not be for you.  I had to do some analysis of the Publishing .targets files to get this to work.

    I also caught some bugs in the WDProj implementation and this hopefully fixes some of those issues.  The nice thing is that I was also able to put in a hack to get the web.config transformations working.

    And Finally, THIS SOLUTION IS SPECIFIC TO MY ORGANIZATION'S REQUIREMENTS.  For example, if you were to customize and tweak the Build Outputs, I can't guarantee that this solution will work for you!  But hopefully it will give you a good enough start.  There may also be some bugs in my tweaks, but again, this works for my organization.


    So here were my requirements:
      -Take an existing "Web Site" project (WSP) and incorporate it into TFS Build and have it create an MSDeploy Package.  If possible, also use web.config transformations for the different Project Configurations.
     
      -At our organization, we choose to Build all the Project Configurations at the same time so the packages match (except for configs and other lame things like File Timestamps - since TFS modifies the file timestamp upon getting latest!  URGH!!!  Source control should NEVER change the file but that's another rant!).  We created and build the following Configurations in TFS - DEV, QA, STG, and PROD.
     
    Solution - (note, this is specifically for VS2010 WSP and WDP)

    1.  Add the 2010 Web Deployment Project to the Web Site Project
    2.  Create new Project Configurations for DEV, QA, STG, and PROD.  Note that this will only create the Project Configuration for the wdproj since Web Site Projects don't support Configurations
    3.  Add the following files to the Web Site Project:
        -web.DEV.config.exclude
        -web.QA.config.exclude
        -web.STG.config.exclude
        -web.PROD.config.exclude
       
       The ".exclude" is to prevent the files from being included in the Web Site Project
    4. Edit the *.wdproj file and put in the following tweaks (here's where the fun begins...)

    aTweak: Add another "Any CPU" condition into the "PropertyGroup" elements for each configuration. 
        Reason: When Building in Visual Studio, the Project Configuration is passed as "DEV|AnyCPU" (with no space).  However, when building with TFS, it passes the Project Configuration as "DEV|Any CPU" (with a space).  Therefore, the PropertyGroups tailored to each Build Configurations weren't being picked up.
        Example:
          Change
            <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DEV|AnyCPU'">
            to
            <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DEV|AnyCPU' Or '$(Configuration)|$(Platform)' == 'DEV|Any CPU'">
           
    bTweak: Add a new PropertyGroup to point to the Build Configuration specific Transformation web.config files
        Reason: These will be called by a custom target to force the web.config transformations
        Example:
           Add
            <PropertyGroup>
              <TransformInputFile>$(SourceWebPhysicalPath)\web.config</TransformInputFile>
              <TransformFile>$(SourceWebPhysicalPath)\web.$(Configuration).config.exclude</TransformFile>
              <StackTraceEnabled>False</StackTraceEnabled>
            </PropertyGroup>
           
    cTweak: Add a new PropertyGroup to extend the "CollectFilesFromProjectFolderDependsOn".
        Reason: I encountered an error when trying to create the package from TFS Build.  The MSBuild Target "CollectFilesFromProjectFolder" has the incorrect Source Location for the Package.  Also the "ParameterizeTransformWebConfigCore" has the incorrect Source Location for the Source Root Path.  It is looking for the output at:
              Sources\MAIN\MyWebSite\MyWebSite_deploy
           but the correct output from TFS is at:
              Sources\MAIN\MyWebSite\MyWebSite_deploy\obj\DEV\TempBuildDir
        Example:
          Add
      <PropertyGroup> <CollectFilesFromProjectFolderDependsOn>SetRootPathFolder;$(CollectFilesFromProjectFolderDependsOn)</CollectFilesFromProjectFolderDependsOn>
      </PropertyGroup>
     
    dTweak:  Add the new "SetRootPathFolder" for c above.  Make sure it's after the "Import" of the Microsoft.WebDeployment.targets
        Reason:  See letter "c" above
        Example:
          Add
      <Target Name="SetRootPathFolder">
        <PropertyGroup>
          <WebPublishPipelineProjectDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineProjectDirectory>
          <WebPublishPipelineSourceRootDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineSourceRootDirectory>
        </PropertyGroup>
      </Target>
       
    eTweak:  After the Microsoft.WebDeployment.targets Import, add the following target to get the customzied web.config transformations to work
        Reason:  Allows us to use web.config transformations for WSP+WDP projects
        Example:
          Add
      <Target Name="TransformWebConfig_MyWebsite" Condition="'$(Configuration)'=='DEV' Or '$(Configuration)'=='QA' Or '$(Configuration)'=='STG' Or '$(Configuration)'=='PROD'">
        <Message Text="WD Target Dir: $(WDTargetDir)" />
        <TransformXml Source="$(TransformInputFile)"
                      Transform="$(TransformFile)"
                      Destination="$(WDTargetDir)web.config"
                      Condition=" '$(Configuration)' != '' "
                      StackTrace="$(StackTraceEnabled)" />

        <!-- Copy the transformed web.config to the MyWebSite_deploy folder -->
        <!-- This is because the Package looks for the transformed web.config in the file below.  If this
             is not added, then the Package picks up the untransformed web.config -->
        <Copy SourceFiles="$(WDTargetDir)web.config"
              DestinationFolder="$(MSBuildProjectDirectory)\$(TempBuildDir)" />
      </Target> 
       
    fTweak:  In the "AfterBuild" target, make the call to custom TransformWebConfig Target
        Reason:  This will call the customized target to transform the web.config
        Example:
          Add
      <Target Name="AfterBuild">
        <CallTarget Targets="TransformWebConfig_MyWebSite" />
      </Target>
     
    gTweak:  In the BeforeBuild Target, explicitly copy the Project References if the Solution File is built.
        Reason:  If you point TFS Build to build the Solution File, it will fail because the Project References aren't copied
        Example:
          In the <Target Name="BeforeBuild"> Add:
         
            <Copy
              SourceFiles="@(References->'%(FullPath)')"
              DestinationFolder="$(_FullSourceWebDir)\Bin\"
              ContinueOnError="true"
              SkipUnchangedFiles="true"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
             
    hTweak:  In the BeforeBuild Target, explicitly copy the Project References if the "*.wdproj" is build directly
        Reason:  I ran into an issue where the Dependencies weren't being copied correctly if pointing TFS build directly to the
                 *.wdproj file. This fixed it
        Example:
          In the <Target Name="BeforeBuild"> Add:
         
            <Copy
              SourceFiles="@(References->'%(FullPath)')"
              DestinationFolder="$(MSBuildProjectDirectory)\$(CopyBeforeBuildTargetPath)\Bin\"
              ContinueOnError="true"
              SkipUnchangedFiles="true"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />

    5.  After the Project File is setup, go to the TFS Build Definition.  In the Process->"Items to Build" section, add the configurations for "DEV|Any CPU", "QA|Any CPU","STG|Any CPU","PROD|Any CPU".

    6.  Point the Projects to build to build the *.wdproj file
    7.  Under "Advanced" add the MSBuild Arguments:
           /t:Package /p:DeployIisAppPath="Default Web Site/MyWebSite"
          
    8.  Kick off the Build, and an MSDeploy Package is created!


    Hope this works for some of you, or at least gets you started in the WDProj tweaks.  Also, if you don't need the web.config transformations, then some tweaks here might not be needed.

    Good luck to all of you!

    Friday, April 20, 2012 12:21 AM
  • Hi All!

    I'm the original poster and after a lot of tweaking and trial & error, I am FINALLY able to get TFS Build working with a WSP + WDP.  However, this solution is quite long and required some significant amount of tweaking to the *.wdproj file.  So if you feel uncomfortable teaking and understanding MSBuild, then this solution might not be for you.  I had to do some analysis of the Publishing .targets files to get this to work.

    I also caught some bugs in the WDProj implementation and this hopefully fixes some of those issues.  The nice thing is that I was also able to put in a hack to get the web.config transformations working.

    And Finally, THIS SOLUTION IS SPECIFIC TO MY ORGANIZATION'S REQUIREMENTS.  For example, if you were to customize and tweak the Build Outputs, I can't guarantee that this solution will work for you!  But hopefully it will give you a good enough start.  There may also be some bugs in my tweaks, but again, this works for my organization.


    So here were my requirements:
      -Take an existing "Web Site" project (WSP) and incorporate it into TFS Build and have it create an MSDeploy Package.  If possible, also use web.config transformations for the different Project Configurations.
     
      -At our organization, we choose to Build all the Project Configurations at the same time so the packages match (except for configs and other lame things like File Timestamps - since TFS modifies the file timestamp upon getting latest!  URGH!!!  Source control should NEVER change the file but that's another rant!).  We created and build the following Configurations in TFS - DEV, QA, STG, and PROD.
     
    Solution - (note, this is specifically for VS2010 WSP and WDP)

    1.  Add the 2010 Web Deployment Project to the Web Site Project
    2.  Create new Project Configurations for DEV, QA, STG, and PROD.  Note that this will only create the Project Configuration for the wdproj since Web Site Projects don't support Configurations
    3.  Add the following files to the Web Site Project:
        -web.DEV.config.exclude
        -web.QA.config.exclude
        -web.STG.config.exclude
        -web.PROD.config.exclude
       
       The ".exclude" is to prevent the files from being included in the Web Site Project
    4. Edit the *.wdproj file and put in the following tweaks (here's where the fun begins...)

    aTweak: Add another "Any CPU" condition into the "PropertyGroup" elements for each configuration. 
        Reason: When Building in Visual Studio, the Project Configuration is passed as "DEV|AnyCPU" (with no space).  However, when building with TFS, it passes the Project Configuration as "DEV|Any CPU" (with a space).  Therefore, the PropertyGroups tailored to each Build Configurations weren't being picked up.
        Example:
          Change
            <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DEV|AnyCPU'">
            to
            <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DEV|AnyCPU' Or '$(Configuration)|$(Platform)' == 'DEV|Any CPU'">
           
    bTweak: Add a new PropertyGroup to point to the Build Configuration specific Transformation web.config files
        Reason: These will be called by a custom target to force the web.config transformations
        Example:
           Add
            <PropertyGroup>
              <TransformInputFile>$(SourceWebPhysicalPath)\web.config</TransformInputFile>
              <TransformFile>$(SourceWebPhysicalPath)\web.$(Configuration).config.exclude</TransformFile>
              <StackTraceEnabled>False</StackTraceEnabled>
            </PropertyGroup>
           
    cTweak: Add a new PropertyGroup to extend the "CollectFilesFromProjectFolderDependsOn".
        Reason: I encountered an error when trying to create the package from TFS Build.  The MSBuild Target "CollectFilesFromProjectFolder" has the incorrect Source Location for the Package.  Also the "ParameterizeTransformWebConfigCore" has the incorrect Source Location for the Source Root Path.  It is looking for the output at:
              Sources\MAIN\MyWebSite\MyWebSite_deploy
           but the correct output from TFS is at:
              Sources\MAIN\MyWebSite\MyWebSite_deploy\obj\DEV\TempBuildDir
        Example:
          Add
      <PropertyGroup> <CollectFilesFromProjectFolderDependsOn>SetRootPathFolder;$(CollectFilesFromProjectFolderDependsOn)</CollectFilesFromProjectFolderDependsOn>
      </PropertyGroup>
     
    dTweak:  Add the new "SetRootPathFolder" for c above.  Make sure it's after the "Import" of the Microsoft.WebDeployment.targets
        Reason:  See letter "c" above
        Example:
          Add
      <Target Name="SetRootPathFolder">
        <PropertyGroup>
          <WebPublishPipelineProjectDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineProjectDirectory>
          <WebPublishPipelineSourceRootDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineSourceRootDirectory>
        </PropertyGroup>
      </Target>
       
    eTweak:  After the Microsoft.WebDeployment.targets Import, add the following target to get the customzied web.config transformations to work
        Reason:  Allows us to use web.config transformations for WSP+WDP projects
        Example:
          Add
      <Target Name="TransformWebConfig_MyWebsite" Condition="'$(Configuration)'=='DEV' Or '$(Configuration)'=='QA' Or '$(Configuration)'=='STG' Or '$(Configuration)'=='PROD'">
        <Message Text="WD Target Dir: $(WDTargetDir)" />
        <TransformXml Source="$(TransformInputFile)"
                      Transform="$(TransformFile)"
                      Destination="$(WDTargetDir)web.config"
                      Condition=" '$(Configuration)' != '' "
                      StackTrace="$(StackTraceEnabled)" />

        <!-- Copy the transformed web.config to the MyWebSite_deploy folder -->
        <!-- This is because the Package looks for the transformed web.config in the file below.  If this
             is not added, then the Package picks up the untransformed web.config -->
        <Copy SourceFiles="$(WDTargetDir)web.config"
              DestinationFolder="$(MSBuildProjectDirectory)\$(TempBuildDir)" />
      </Target> 
       
    fTweak:  In the "AfterBuild" target, make the call to custom TransformWebConfig Target
        Reason:  This will call the customized target to transform the web.config
        Example:
          Add
      <Target Name="AfterBuild">
        <CallTarget Targets="TransformWebConfig_MyWebSite" />
      </Target>
     
    gTweak:  In the BeforeBuild Target, explicitly copy the Project References if the Solution File is built.
        Reason:  If you point TFS Build to build the Solution File, it will fail because the Project References aren't copied
        Example:
          In the <Target Name="BeforeBuild"> Add:
         
            <Copy
              SourceFiles="@(References->'%(FullPath)')"
              DestinationFolder="$(_FullSourceWebDir)\Bin\"
              ContinueOnError="true"
              SkipUnchangedFiles="true"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
             
    hTweak:  In the BeforeBuild Target, explicitly copy the Project References if the "*.wdproj" is build directly
        Reason:  I ran into an issue where the Dependencies weren't being copied correctly if pointing TFS build directly to the
                 *.wdproj file. This fixed it
        Example:
          In the <Target Name="BeforeBuild"> Add:
         
            <Copy
              SourceFiles="@(References->'%(FullPath)')"
              DestinationFolder="$(MSBuildProjectDirectory)\$(CopyBeforeBuildTargetPath)\Bin\"
              ContinueOnError="true"
              SkipUnchangedFiles="true"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />

    5.  After the Project File is setup, go to the TFS Build Definition.  In the Process->"Items to Build" section, add the configurations for "DEV|Any CPU", "QA|Any CPU","STG|Any CPU","PROD|Any CPU".

    6.  Point the Projects to build to build the *.wdproj file
    7.  Under "Advanced" add the MSBuild Arguments:
           /t:Package /p:DeployIisAppPath="Default Web Site/MyWebSite"
          
    8.  Kick off the Build, and an MSDeploy Package is created!


    Hope this works for some of you, or at least gets you started in the WDProj tweaks.  Also, if you don't need the web.config transformations, then some tweaks here might not be needed.

    Good luck to all of you!

    Thank you IMaReallyBigFish for posting your solution! After adding step 'C' and 'D' to .wdproj file, I was able to build a web package. This is an obvious bug in WDP that MS should address with a patch!
    Wednesday, April 25, 2012 1:22 PM
  • Thanks IMaReallyBigFish..this was an Oasis in a desert looking for the answer to deployment with websites. This worked wonderfully with the VS and creates the appropriate packages. The only issue is when I am running the Ms Build from TFS. So what happens is that if I run the solution the Build is successful and I get 3 folders at the DROP location for each of my environments ST, UAT and PROD. But I run the Build with Projects to Build pointing to my deployment project as stated in your answer above

    6.  Point the Projects to build to build the *.wdproj file

    I get an error

    BusinessLayer is another project being referenced in the Website.

    C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets (1407): Unable to copy file "C:\Builds\8\xxx\xyz - Continous Integration\Binaries\ST\BusinessLayer.dll" to "C:\Builds\8\xxx\xyz - Continous Integration\Sources\TAX-IT\TaxCentralTFS\bin\BusinessLayer.dll". Could not find file 'C:\Builds\8\TAX-IT\TaxCentralTFS - Continous Integration\Binaries\ST\BusinessLayer.dll'.

    Should I add the DLL to TFS. I dont think it is a good idea. I have added the project. ANd also it is buiding successfuully when I am running from Visual Studio. Also if I point the projects to compile to solution file it works but it does not create the packages only drop folders.

    Have anyone else encountred this? Please let me know struggling with this entire Website deployment for almost a month now.

    Thanks

    Monday, August 06, 2012 2:48 PM
  • Hi Tech_Girl007,

    While it's hard to say what's causing your specific problem it looks like it could also be a Workspace issue on your TFS Build Agent.  Somehow it's not finding the compiled "BusinessLayer.dll" in your build.

    Also, maybe double check the Project References?

    As part of testing, I ran this at the Visual Studio command line on the my local machine to force the project package to be created:

    >msbuild <PROJECTNAME>.wdproj /t:Package /p:Configuration=[PROJECT_CONFIGURATION]

    for example if I had a DEV Build Configuration:

    >msbuild MyWebSite.wdproj /t:Package /p:Configuration=DEV

    I would then check to make sure the packages are built correctly.

    Thanks,

    Felix

    Monday, August 06, 2012 11:25 PM
  • Thanks IMaReallyBigFish.

    So I did started building it from the command line and here is what happened.

    1) I ran as you told me and I got the same error

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9):
    error : The OutputPath property is not set for project 'BusinessLayer.vbproj'.
     Please check to make sure that you have specified a valid combination of Confi
    guration and Platform for this project.  Configuration='ST'  Platform='AnyCPU
    '.  You may be seeing this message because you are trying to build a project wi
    thout a solution file, and have specified a non-default Configuration or Platfo
    rm that doesn't exist for this project. [C:\XYZ\BusinessLayer\BusinessLayer.vbproj]
    Done Building Project "C:\XYZ\BusinessLayer\BusinessLayer.vbproj" (GetTargetPath target(s)) -- FAILED.

    Done Building Project "C:\XYZ\myApplication_deploy1.wdproj" (Package target(s)) -- FAILED.

    Then I created a ST configuration for my BusinessLayer Project.  I did not build it. Just created it and specified a folder.

    2) I got the same error. So I Build my Project locally. This created the dll under the bin\ST folder.

    3) Then ran the above command and it was successful

    4) I check in my changes. And tried to run it from TFS. I still get the same error.

     

    C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets (1407): Unable to copy file "C:\Builds\8\xxx\xyz - Continous Integration\Binaries\ST\BusinessLayer.dll" to "C:\Builds\8\xxx\xyz - Continous Integration\Sources\TAX-IT\TaxCentralTFS\bin\BusinessLayer.dll". Could not find file 'C:\Builds\8\TAX-IT\TaxCentralTFS - Continous Integration\Binaries\ST\BusinessLayer.dll'.

    From this I conclude that the appropriate folders are not getting created on TFS server when a BUILD is invoked. Business Layer is a class library project. Is there a way I can force to Build it before theweb deployment project.

    Or is it an access issue.

    Thanks for your help.

    Tuesday, August 07, 2012 6:21 PM
  • It actually worked..I dont know what happened. But I have made so many changes since morning and it actually created a folder for me right where I wanted it..Soooo happy...yes did it.

    I will post my findings in coming days ..it might help someone..Although a great article written by you. Thanks

    Thanks for your help


    • Edited by Tech_Girl007 Tuesday, August 07, 2012 8:50 PM Added content
    Tuesday, August 07, 2012 8:49 PM
  • Hi Tech Girl,

    When you point TFS directly to the wdproj file, you might be running into the issue I enountered under 4a.  It looks like there's a bug in TFS Build where the "Any CPU" and the "AnyCPU" between TFS and Visual Studio are inconsistent. One has a space and the other does not.

    There are two ways you can fix that issue with the "Any CPU"/"AnyCPU".  If you're comfortable with MSBuild you can manually edit the wdproj file and add the Build Configuration/Platform Configuration for both " 'ST|AnyCPU' And 'ST|Any CPU' ".

    Another option is to open up the TFS Build Definition and under the Platform Configuration just manually remove the space between the "Any" and "CPU".  Although, I personally did not want to do this because I wasn't sure if there were other Build Targets that were expecting the space.

    What might be happening in your scenario is that the "OutputDir" or "OutDir" is not getting picked up because it can't find your $(BuildConfiguration)|$(PlatformConfiguration) combination.  Therefore the variable for "OutputDir" or "OutDir" is not being set causing the libraries to not be dropped in the right location.

    Thanks,

    Felix

    Wednesday, August 08, 2012 7:40 AM
  • Hello Felix,

    I am back to square one. I followed everything you had here and added some.

    So I added couple of things to my web deployment project which led to it working finally. But the when I checked web.config it was not transformed in the Deployment package folder.

    1) 

    <!--<SourceWebPhysicalPath>..\TaxCentralTFS</SourceWebPhysicalPath>--> I replaced this line with this    

    <SourceWebPhysicalPath Condition="!Exists('..\..\Binaries\$(Configuration)\_PublishedWebsites\xyz_deploy1')">..\xyz</SourceWebPhysicalPath> 

    <SourceWebPhysicalPath Condition="Exists('..\..\Binaries\$(Configuration)\_PublishedWebsites\xyz_deploy1')">..\..\Binaries\$(Configuration)\_PublishedWebsites\xyz_deploy1</SourceWebPhysicalPath>

    2) I added copy local for Business Layer

     <ItemGroup>
        <ProjectReference Include="..\BusinessLayer\BusinessLayer.vbproj">
          <Project>{4289D606-B293-422A-80FC-351EA2A26B4D}</Project>
          <Name>BusinessLayer</Name>
          <Private>True</Private>
        </ProjectReference>
      </ItemGroup>

    3) I added this

    <PropertyGroup>    <AfterBuildDependsOn>$(AfterBuildDependsOn);$(PrepareForRunDependsOn)</AfterBuildDependsOn>  </PropertyGroup>  <Target Name="AfterBuild" DependsOnTargets="$(AfterBuildDependsOn)">  </Target

    So in my build definition I added 2 projects to Build. First the Solution and then the Web deployment project.

    This resulted in Building successfully and creating appropriate folders and content.

    But the only issue was that the web.config transformations did not happen.

    This is Problem #1

    Problem #2 . In one of my applications i get this weird error, when I try to run both Solution Web Deployment project.

    ASPNETCOMPILER: This application is already precompiled. If I run only Solution it does not create package. If I run only WDP it givesthe error "Unable to find file" Looks like I am in lot of trouble

    I added few line from my log file. Why is the Transform happening after building the package.

    Package "WAY_deploy1.zip" is successfully created as single file at the following location:
      file:///C:/Builds/7/TAX-IT/WAY-%20Continous%20Integration/Binaries/ST/_PublishedWebsites/WAY_deploy1_Package
      To get the instructions on how to deploy the web package please visit the following link:
      http://go.microsoft.com/fwlink/?LinkId=124618
    GenerateSampleDeployScript:
      Sample script for deploying this package is generated at the following location:
      C:\Builds\7\xxxxxxxxx\Binaries\ST\_PublishedWebsites\xxx_deploy1_Package\xxx_deploy1.deploy.cmd
      For this sample script, you can change the deploy parameters by changing the following file:
      C:\Builds\7xxxxx\Binaries\ST\_PublishedWebsites\xxx_deploy1_Package\xxx_deploy1.SetParameters.xml
    PipelineDeployPhase:
      Publish Pipeline Deploy Phase
    TransformWebConfig_xxx:
      WD Target Dir: C:\Builds\7\xxxx\Binaries\ST\_PublishedWebsites\xxx_deploy1\
      Transforming Source File: ..\xxxY\web.config
        Applying Transform File: ..\xxx\web.ST.config.exclude
        Output File: C:\Builds\7\xxxx\Binaries\ST\_PublishedWebsites\xxx_deploy1\web.config
      Transformation succeeded
      Copying file from "C:\Builds\7\xxxxx\Binaries\ST\_PublishedWebsites\xxxx_deploy1\web.config" to "C:\Builds\7\xxxx\Sources\TAX-IT\WAY_deploy1\obj\ST\TempBuildDir\web.config".
    Done Building Project "C:\Builds\7\xxxxx\Sources\TAX-IT\xxx_deploy1\xxx_deploy1.wdproj" (default targets).

    Build succeeded.

    • Edited by Tech_Girl007 Friday, August 10, 2012 2:36 PM Added log file
    Friday, August 10, 2012 1:39 PM
  • So my problem is down to one thing :

    Why the transformation is not taking place in deployment folder package? It does transform in the main publish folder but the deployment package folder has the development web.config?

    I am not sure what is missing now?

    Please help.

    Thanks

    :(

    Friday, August 10, 2012 6:59 PM
  • Was anyone ever successful in creating a deployment package with the web.configs transformation happening in the packaged zip file. I have manged to get the transformation to be working in _PublishedWebsites folder and TempBuildDir also packagetmp but on TFS server the package is created before the transformation.

    tried everything that I could. I dont want to give up but not sure what else to do.

    Anyone ever successsful in doing it?

    Thanks

    Tuesday, August 14, 2012 4:34 PM
  • Hi Tech Girl,

    When you point TFS directly to the wdproj file, you might be running into the issue I enountered under 4a.  It looks like there's a bug in TFS Build where the "Any CPU" and the "AnyCPU" between TFS and Visual Studio are inconsistent. One has a space and the other does not.

    There are two ways you can fix that issue with the "Any CPU"/"AnyCPU".  If you're comfortable with MSBuild you can manually edit the wdproj file and add the Build Configuration/Platform Configuration for both " 'ST|AnyCPU' And 'ST|Any CPU' ".

    Another option is to open up the TFS Build Definition and under the Platform Configuration just manually remove the space between the "Any" and "CPU".  Although, I personally did not want to do this because I wasn't sure if there were other Build Targets that were expecting the space.

    What might be happening in your scenario is that the "OutputDir" or "OutDir" is not getting picked up because it can't find your $(BuildConfiguration)|$(PlatformConfiguration) combination.  Therefore the variable for "OutputDir" or "OutDir" is not being set causing the libraries to not be dropped in the right location.

    Thanks,

    Felix

    Hello Felix,

    I already made all changes as per your post and I am still getting the same issue.

    I started to look at my deployment project again to see if i missed anything. The only thing that I found was that I was never able to add only web deployment project in my build definition and have a successful build.

    I will get this error :

    C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets (1407): Unable to copy file "C:\Builds\8\xxx\xyz - Continous Integration\Binaries\ST\BusinessLayer.dll" to "C:\Builds\8\xxx\xyz - Continous Integration\Sources\TAX-IT\TaxCentralTFS\bin\BusinessLayer.dll". Could not find file 'C:\Builds\8\TAX-IT\TaxCentralTFS - Continous Integration\Binaries\ST\BusinessLayer.dll'.

    This happens only if i try to put only web deployment project as Projects To Build. If I add my solution file or Businesslayer project to Build befoe webdeployment project., it builds successfully.

    But then I am unable to use /t:Package. I believe this /t:package does the magic somehow to transform web.config before packaging it.

    Any thoughts?

    Thanks


    TechGirl007

    Tuesday, August 21, 2012 7:09 PM
  • techgirl, i am also having same issue . _PublishedWebsites  folder is having transformed web.config but _package is containing original web.config.

    at same time /t:package is not working as TFS build's MSArguments. it is giving error as "The target "Package" does not exist in the project."

    anyone can help me here? i am almost there. having transformed web.config but not inside zip package. any sample code will be really helpful .even following sample didnt work as sample code is not same description. http://code.msdn.microsoft.com/Sample-Website-33032b2d

    Monday, June 17, 2013 9:25 PM
  • Hi AV_av

    Sorry I don't have too much time to investigate and reply, but have you checked the "AnyCPU" vs "Any CPU" issue from tweak #4 above?

    What I found is that sometimes I've had issues when the "Configuration|Platform" was incorrect.

    Also, for you and for anyone else that has run into this article, it's a little bit outdated since the Web Deployment Projects will no longer be supported in the future.  

    When I had these issues there wasn't much support at all from Microsoft about deploying web site projects in an enterprise environment (with TFS 2010).  Documentation & Blogs were limited as well.  However, it now looks like the pattern is to use Web Publishing Profiles (I'm really a developer, not a Build/Release engineer, so viewing patterns interests me :) ):

    http://blogs.msdn.com/b/webdev/archive/2012/06/15/visual-studio-2010-web-publish-updates.aspx

    I haven't had the time to change our Web Site projects to use the new Web Publishing Profiles (WPP), but after reading about it and using it for a small project I would consider that approach.  That also means I haven't integrated it with TFS yet either.

    One item that I did like with WPP is that it builds the web.config transformations as part of the Packaging stage and not the Build stage.  This is important because it always troubled me that before WPP, in order to tweak the config for different environments meant tweaking the Project File.  From an architecture point of view it was tightly coupling the Build & Package process together.  And as a Software Developer/Engineer, anything that is tightly coupled is a bad sign.

    Again, I haven't had much experience with using WPP's in our enterprise environment (and incorporating it with TFS), but hopefully posting this will get you to an approach that works for you.

    Wednesday, June 19, 2013 3:51 PM
  • Hi Av_av,

    Sorry the delay is getting back. But did you try these arguments:

    /p:DeployOnBuild=True  /p:CreatePackageOnPublish=true  

     

    For your reference I have copied my entire deployment project code here:

    <?xml version="1.0" encoding="utf-8"?>
    <!-- 
      Microsoft Visual Studio 2010 Web Deployment Project 
      http://go.microsoft.com/fwlink/?LinkID=104956
    -->
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>10.0.30319</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{53D69DBE-2395-42E5-ABE5-EB940CF1AF10}</ProjectGuid>
        <SourceWebPhysicalPath>..\XYZ</SourceWebPhysicalPath>
        <SourceWebProject>{A99F52FC-13ED-4B9D-ACDD-C99F3EF57DD1}|xxxx\xxxx\xxxx\xxxx</SourceWebProject>
        <SourceWebVirtualPath>/xyz</SourceWebVirtualPath>
        <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
        <SccProjectName>SAK</SccProjectName>
        <SccLocalPath>SAK</SccLocalPath>
        <SccAuxPath>SAK</SccAuxPath>
        <SccProvider>SAK</SccProvider>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <OutputPath>.\Debug</OutputPath>
        <EnableUpdateable>true</EnableUpdateable>
        <UseMerge>true</UseMerge>
        <SingleAssemblyName>XYZ_deploy</SingleAssemblyName>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugSymbols>false</DebugSymbols>
        <OutputPath>.\Release</OutputPath>
        <EnableUpdateable>true</EnableUpdateable>
        <UseMerge>true</UseMerge>
        <SingleAssemblyName>XYZ_deploy</SingleAssemblyName>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ST|AnyCPU'">
        <OutputPath>.\ST</OutputPath>
        <EnableUpdateable>false</EnableUpdateable>
        <UseMerge>true</UseMerge>
        <SingleAssemblyName>XYZ_deploy</SingleAssemblyName>
        <DeployIisAppPath>XYZST</DeployIisAppPath>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'UAT|AnyCPU'">
        <OutputPath>.\UAT</OutputPath>
        <EnableUpdateable>false</EnableUpdateable>
        <UseMerge>true</UseMerge>
        <SingleAssemblyName>XYZ_deploy</SingleAssemblyName>
        <DeployIisAppPath>XYZUAT</DeployIisAppPath>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PROD|AnyCPU'">
        <OutputPath>.\PROD</OutputPath>
        <EnableUpdateable>false</EnableUpdateable>
        <UseMerge>true</UseMerge>
        <SingleAssemblyName>XYZ_deploy</SingleAssemblyName>
        <DeployIisAppPath>XYZPROD</DeployIisAppPath>
        
      </PropertyGroup>
      <ItemGroup>
        <ProjectReference Include="..\BusinessLayer\BusinessLayer.vbproj">
          <Project>{4289D606-B293-422A-80FC-351EA2A26B4D}</Project>
          <Name>BusinessLayer</Name>
        </ProjectReference>
      </ItemGroup>
      <PropertyGroup>
        <TransformInputFile>$(SourceWebPhysicalPath)\web.config</TransformInputFile>
        <TransformFile>$(SourceWebPhysicalPath)\web.$(Configuration).config.exclude</TransformFile>
        <StackTraceEnabled>False</StackTraceEnabled>
      </PropertyGroup>
      <PropertyGroup>
        <CollectFilesFromProjectFolderDependsOn>SetRootPathFolder;$(CollectFilesFromProjectFolderDependsOn)</CollectFilesFromProjectFolderDependsOn>
      </PropertyGroup>
      <Import Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets" />
      <Target Name="SetRootPathFolder">
        <PropertyGroup>
          <WebPublishPipelineProjectDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineProjectDirectory>
          <WebPublishPipelineSourceRootDirectory>$(MSBuildProjectDirectory)\$(TempBuildDir)</WebPublishPipelineSourceRootDirectory>
        </PropertyGroup>
      </Target>
      <Target Name="TransformWebConfig_MyWebsite" Condition="'$(Configuration)'=='ST' Or '$(Configuration)'=='UAT' Or '$(Configuration)'=='PROD'">
        <Message Text="WD Target Dir: $(WDTargetDir)" />
        <TransformXml Source="$(TransformInputFile)" Transform="$(TransformFile)" Destination="$(WDTargetDir)web.config" Condition=" '$(Configuration)' != '' " StackTrace="$(StackTraceEnabled)" />
        <!-- Copy the transformed web.config to the MyWebSite_deploy folder -->
        <!-- This is because the Package looks for the transformed web.config in the file below.  If this 
             is not added, then the Package picks up the untransformed web.config -->
        <Copy SourceFiles="$(WDTargetDir)web.config"
            DestinationFolder="$(PackageTempRootDir)\PackageTmp" />
      </Target>
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.WebDeployment.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="BeforeMerge">
      </Target>
      <Target Name="AfterMerge">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
      <Target Name="AfterBuild" DependsOnTargets="$(AfterBuildDependsOn)">
        <!--<CallTarget Targets="TransformWebConfig_WAY" />-->
      </Target>
      <PropertyGroup>
        <PackageUsingManifestDependsOn>$(PackageUsingManifestDependsOn);TransformWebConfig_MyWebsite;</PackageUsingManifestDependsOn>
      </PropertyGroup>
      <PropertyGroup>
        <AfterBuildDependsOn>$(AfterBuildDependsOn);$(PrepareForRunDependsOn)</AfterBuildDependsOn>
      </PropertyGroup>
    </Project>

    Please try it and let us know if it helps. Also can you show your web deployment project.

    Hope it helps.

    Regards


    TechGirl007

    Wednesday, June 19, 2013 8:35 PM