﻿<!--
***********************************************************************************************
Microsoft.WebApplication.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your web deploy projects from the command-line or the IDE.

This file defines the steps in the standard build process for web deploy projects.

Copyright (C) 2005 Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

	<PropertyGroup>
		<WebProjectOutputDir Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)_PublishedWebsites\$(MSBuildProjectName)</WebProjectOutputDir>
		<WebProjectOutputDir Condition="'$(OutDir)' == '$(OutputPath)'">$(MSBuildProjectDirectory)</WebProjectOutputDir>
	</PropertyGroup>
	
	<PropertyGroup>
		<PrepareForRunDependsOn>
			$(PrepareForRunDependsOn);
			_CopyWebApplication;
			_BuiltWebOutputGroupOutput
		</PrepareForRunDependsOn>
	</PropertyGroup>

	<!--
	============================================================
	_CopyWebApplication

	This target will copy the build outputs along with the 
	content files into a _PublishedWebsites folder.
	
	This Task is only necessary when $(OutDir) has been redirected
	to a folder other than ~\bin such as is the case with Team Build.
	============================================================
	-->
	<Target Name="_CopyWebApplication" Condition="'$(OutDir)' != '$(OutputPath)'" >
		<!-- Log tasks -->
		<Message Text="Copying Web Application Project Files for $(MSBuildProjectName)" />

		<!-- Create the _PublishedWebsites\app\bin folder -->
		<MakeDir Directories="$(WebProjectOutputDir)\bin" />

		<!-- Copy build outputs to _PublishedWebsites\app\bin folder -->
		<Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
		<Copy SourceFiles="@(AddModules)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
		<Copy SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)" DestinationFolder="$(WebProjectOutputDir)\%(Content.SubFolder)%(Content.RecursiveDir)" SkipUnchangedFiles="true" Condition="'$(_SGenDllCreated)'=='true'" />
		<Copy SourceFiles="$(IntermediateOutputPath)$(TargetName).pdb" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DebugSymbolsProduced)'=='true'" />
		<Copy SourceFiles="@(DocFileItem)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" Condition="'$(_DocumentationFileProduced)'=='true'" />
		<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />
		<Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />

		<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
		<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFolder="$(WebProjectOutputDir)\bin" SkipUnchangedFiles="true" />

		<!-- Copy content files recursively to _PublishedWebsites\app\ folder -->
		<Copy SourceFiles="@(Content)" DestinationFolder="$(WebProjectOutputDir)\%(Content.RelativeDir)" />
		
	</Target>

	<!--
	============================================================
	_BuiltWebOutputGroupOutput

	This target creates and populates BuiltWebOutputGroupOutput
	with contents of bin along with the @(Content) files
	============================================================
	-->
	<Target Name ="_BuiltWebOutputGroupOutput">
		<CreateItem Include="$(WebProjectOutputDir)\bin\**\*.*;@(Content->'%(FullPath)')" Condition="'$(OutDir)' == '$(OutputPath)'">
			<Output ItemName="BuiltWebOutputGroupOutput" TaskParameter="Include"/>
		</CreateItem>
		
		<CreateItem Include="$(WebProjectOutputDir)\**\*.*" Condition="'$(OutDir)' != '$(OutputPath)'">
			<Output ItemName="BuiltWebOutputGroupOutput" TaskParameter="Include"/>
		</CreateItem>
	</Target>

</Project>
