1
votes

I am currently working with TFS2012 and VS2012 technology to Build and Deploy Web Application and Non Web Application.

Research carried out:
- Read the Inside the Microsoft Build Engine, Using MSBuild and Team Foundation Build book.
- Read Stackoverflow, msdn, and other forums for help on my problem.

Unfortunately I'm still faced with the issue.

Current setup:

I have a:

  • Solution called ClassLib1.sln
  • Build.proj file within the solution
  • 2 Project within the Solution:
    • ClassLib1.csproj - Non Web Application
    • MvcApp1.csproj - Web Application
  • Build server that performs the builds
  • Build Definition (DefaultTemplate.11.1.xaml) that builds Build.proj file.

The Build.proj file contains following configuration:

<?xml version="1.0" encoding="utf-8" ?>  
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
  <ItemGroup>  
    <DirectoriesToDelete Include="\\server\build\test\MvcApp1" />  
    <DirectoriesToDelete Include="\\server\build\test\ClassLib1" />  
    <SolutionsToBuild Include="ClassLib1.sln" />  
    <ProjectsToPublish Include="MvcApp1\MvcApp1.csproj">  
      <Properties>  
        OutputPath=$(MSBuildProjectDirectory)\build\test\ClassLib1\MvcApp1\; 
        UseWPP_CopyWebApplication=true;  
        PipelineDependsOnBuild=false;  
        SkipInvalidConfigurations=true;  
        DeployOnBuild=true;  
        DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;  
        AutoParameterizationWebConfigConnectionStrings=false;  
        _PackageTempDir=\\server\build\test\MvcApp1  
      </Properties>  
    </ProjectsToPublish>  
    <ProjectsToPublish Include="ClassLib1\ClassLib1.csproj">  
      <Properties>  
        OutputPath=\\server\build\test\ClassLib1\  
      </Properties>  
    </ProjectsToPublish>  
  </ItemGroup>  
  <Target Name="Build">  
    <RemoveDir Directories="@(DirectoriesToDelete)" />  
    <MSBuild Projects="@(SolutionsToBuild)" />  
    <MSBuild Projects="@(ProjectsToPublish)" />  
  </Target>  
</Project>  

What works:

When executing the msbuild locally (e.g. msbuild Build.proj /t:Build), everything works. Both projects are built and output to the specified PackageTempDir or OutPutPath.

Problem at hand:

However, once I try to perform the build via Build definition then only the MvcApp1.csproj files are output in the specified place. The ClassLib1.csproj files are missing.

I've tried number of things, nothing worked so far (apart from doing it manually).

Please note I am somewhat new to this, so may have easily miss understood or missed something.

1
More information about this case can be found at social.msdn.microsoft.com/Forums/vstudio/en-US/…Alex

1 Answers

0
votes

I've managed to resolve the issue after a bit of trial and error.

For the non web app I had modified the ItemGroup to contain:

<ProjectsToPublish Include="..\Solution\FolderName\Project\ProjectName.csproj">
  <Properties>OutputPath=$(MSBuildProjectDirectory)\Environmen\Solution.FolderName.ProjectName;OutDir=C:\CustomBinariesOutDir\Environment\App\</Properties>
</ProjectsToPublish>

I've created a Copy Target

<Target Name="Copy" AfterTargets="Build">
<CreateItem Include="C:\CustomBinariesOutDir\environment\**\*.*" >
  <Output TaskParameter="Include" ItemName="FilesToCopy"/>
</CreateItem>
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="\\serverip\TestBuild\environment\%(FilesToCopy.RecursiveDir)" />

It seems the issue was that msbuild didn't allow me directly copy from where the binaries were being built, so I output them into another folder on the same server and then using copy target move them to right place.

Hope this helps others.