summaryrefslogtreecommitdiffstats
path: root/samples/Samples.proj
blob: c79a0a429c806f2bd743eff28a37e3d886789a4d (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
104
105
106
<?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="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/>

	<ItemGroup>
		<SampleProjects Include="**\*.csproj;**\*.vbproj" />
		<SampleSites Include="OAuthConsumer;OAuthServiceProvider;InfoCardRelyingParty" />

		<ProjectsToClean Include="@(SampleProjects)" />
		<ProjectsToClean Include="$(SolutionPath)">
			<Targets>@(SampleSites->'%(Identity):Clean')</Targets>
		</ProjectsToClean>
	</ItemGroup>

	<Target Name="Build" DependsOnTargets="SkipVerification">
		<MSBuild Projects="@(SampleProjects)" BuildInParallel="$(BuildInParallel)" />
		<MSBuild Projects="$(SolutionPath)" Targets="@(SampleSites)" 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>
		<ItemGroup>
			<_SampleWebConfigs Include="$(ProjectRoot)samples\*\web.config" />
			<PublishableWebSamples Include="@(_SampleWebConfigs->'%(RootDir)%(Directory)')" />
		</ItemGroup>

		<!-- 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="Prepare;Build">
		<ItemGroup>
			<SampleSources Include="$(ProjectRoot)samples\**\*" />
			<SampleSources>
				<PublishedLocation>$(SampleWebRoot)\$(BranchName)\%(RecursiveDir)%(Filename)%(Extension)</PublishedLocation>
			</SampleSources>
		</ItemGroup>

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

		<ItemGroup>
			<PublishableWebSampleTargets Include="@(PublishableWebSampleSources->'%(PublishedLocation)')" />
		</ItemGroup>
	</Target>

	<Target Name="Publish"
					DependsOnTargets="PrepareForPublish"
					Inputs="@(PublishableWebSampleSources)"
					Outputs="@(PublishableWebSampleTargets)"
					Condition=" '$(SampleWebRoot)' != '' ">
		<RemoveDir Directories="$(SampleWebRoot)\$(BranchName)" />
		<MakeDir Directories="$(SampleWebRoot)\$(BranchName)" />
		<Copy SourceFiles="@(PublishableWebSampleSources)" DestinationFiles="@(PublishableWebSampleTargets)" SkipUnchangedFiles="true" />
	</Target>

	<Target Name="Unpublish"
					DependsOnTargets="DeleteSitesOnIis"
					Condition=" '$(SampleWebRoot)' != '' ">
	</Target>

	<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"/>
</Project>