diff options
Diffstat (limited to 'samples/Samples.proj')
-rw-r--r-- | samples/Samples.proj | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/samples/Samples.proj b/samples/Samples.proj new file mode 100644 index 0000000..c79a0a4 --- /dev/null +++ b/samples/Samples.proj @@ -0,0 +1,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> |