summaryrefslogtreecommitdiffstats
path: root/samples/Samples.proj
blob: df3eb9716a68e7cf62443e6be2f57d23fd53b26b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<!-- Properties that must be set for these targets to function:
	        $(BranchName): The name of the branch being built.  Used to determine the web subdirectory for publishing.
          
          For creating web sites:
          $(PublishSamplesWebSiteName): The name of the web site under which the sample web applications will be created/deleted.

          For creating or publishing to web sites:
          $(SampleWebRoot): the full physical path to where samples should be copied to, excluding $(BranchName)
	-->
	<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " />
	<Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/>

	<ItemGroup>
		<SampleProjects Include="**\*.csproj;**\*.vbproj" />

		<ProjectsToClean Include="@(SampleProjects)" />

		<_SampleWebConfigs Include="$(ProjectRoot)samples\*\web.config" />
		<PublishableWebSamples Include="@(_SampleWebConfigs->'%(RootDir)%(Directory)')" />
	</ItemGroup>

	<Target Name="Build">
		<ItemGroup>
			<SampleProjectsToBuild Include="@(SampleProjects)" />
		</ItemGroup>

		<MSBuild Projects="@(SampleProjectsToBuild)" Targets="%(SampleProjectsToBuild.Targets)" BuildInParallel="$(BuildInParallel)" />
	</Target>

	<Target Name="Prepare">
		<Error Text="The BranchName property must be set." Condition=" '$(BranchName)' == '' " />
		<Error Text="The SampleWebRoot property must be set." Condition=" '$(SampleWebRoot)' == '' " />
		<PropertyGroup>
			<PublishSamplesWebSiteVirtualPath>/$(BranchName)</PublishSamplesWebSiteVirtualPath>
		</PropertyGroup>

		<!-- Trim the trailing slash on the web sample paths so we can just get the leaf directory name. -->
		<Trim
			Inputs="@(PublishableWebSamples)"
			EndCharacters="\">
			<Output TaskParameter="Outputs" ItemName="_PublishableWebSamplesNoTrailingSlash" />
		</Trim>

		<ItemGroup>
			<PublishableWebSamplesVirtualPaths Include="@(_PublishableWebSamplesNoTrailingSlash->'$(PublishSamplesWebSiteVirtualPath)/%(Filename)')" />
			<PublishableWebSamplesPhysicalPaths Include="@(_PublishableWebSamplesNoTrailingSlash->'$(SampleWebRoot)\$(BranchName)\%(Filename)')" />
		</ItemGroup>
	</Target>

	<Target Name="PrepareForPublish" DependsOnTargets="Build">
		<PropertyGroup>
			<SamplesZip>$(DropDirectoryNoSlash)-samples$(ZipFormat)</SamplesZip>
		</PropertyGroup>

		<ItemGroup>
			<SampleSources Include="$(ProjectRoot)samples\**\*" />
		</ItemGroup>

		<FilterItems
			InputItems="@(SampleSources)"
			StartsWithAny="@(PublishableWebSamples)">
			<Output TaskParameter="FilteredItems" ItemName="PublishableWebSampleSources" />
		</FilterItems>
	</Target>

	<Target Name="DeployableArchive"
					DependsOnTargets="PrepareForPublish"
					Inputs="@(PublishableWebSampleSources)"
					Outputs="$(SamplesZip)">
		<Delete Files="$(SamplesZip)" />
		<AddFilesTo7Zip
			Files="@(PublishableWebSampleSources)"
			ZipFileName="$(SamplesZip)"
			WorkingDirectory="$(ProjectRoot)samples\"
			ToolPath="$(Zip7ToolPath)" />
	</Target>

	<Target Name="Publish"
					DependsOnTargets="DeployableArchive" />

	<Target Name="CreateSitesOnIis" DependsOnTargets="Prepare">
		<Error Text="The PublishSamplesWebSiteName property must be set." Condition=" '$(PublishSamplesWebSiteName)' == '' "/>
		<Error Text="The SampleWebRoot property must be set." Condition=" '$(SampleWebRoot)' == '' " />
		<CreateWebApplication
			WebSiteName="$(PublishSamplesWebSiteName)"
			PhysicalPaths="@(PublishableWebSamplesPhysicalPaths)"
			VirtualPaths="@(PublishableWebSamplesVirtualPaths)"
			/>
	</Target>

	<Target Name="DeleteSitesOnIis" DependsOnTargets="Prepare">
		<Error Text="The PublishSamplesWebSiteName property must be set." Condition=" '$(PublishSamplesWebSiteName)' == '' "/>
		<DeleteWebApplication
			WebSiteName="$(PublishSamplesWebSiteName)"
			VirtualPaths="@(PublishableWebSamplesVirtualPaths)"
			/>
	</Target>

	<Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/>
	<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " />
</Project>