-
Notifications
You must be signed in to change notification settings - Fork 4
/
.openpublishing.build.mdproj
109 lines (99 loc) · 7.51 KB
/
.openpublishing.build.mdproj
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
107
108
109
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildTaskPackage>opbuild</BuildTaskPackage>
<BuildTaskProjectPath>build/docfx.msbuild.targets</BuildTaskProjectPath>
<ToolsFolder>$(MSBuildThisFileDirectory)Tools\</ToolsFolder>
<OutputFolder Condition="'$(OutputFolder)' == '' ">$(MSBuildThisFileDirectory)_site</OutputFolder>
<PreviewTemplateName Condition="'$(PreviewTemplateName)' == '' ">msdn.html</PreviewTemplateName>
<LogOutputFolder Condition="'$(LogOutputFolder)' == ''">$(MSBuildThisFileDirectory)\log\</LogOutputFolder>
<LogFile Condition="'$(LogFile)' == ''">$(LogOutputFolder)\report.txt</LogFile>
<LogLevel Condition=" '$(LogLevel)' == '' ">Verbose</LogLevel>
</PropertyGroup>
<!-- nuget Restore Target-->
<Target Name="RestorePackages">
<!-- There are three files manually needed to publish a content repsoitory. This -->
<!-- file, packages.config, and nuget.exe. The rest can be boot strapped by the build process. -->
<Error Condition="EXISTS('$(MSBuildThisFileDirectory)packages.config') != 'True'" Text="packages.config was not found at the expected location: $(MSBuildThisFileDirectory)."/>
<Error Condition="EXISTS('$(ToolsFolder)NuGet\NuGet.exe') != 'True'" Text="Nuget.exe was not found at the expected location: $(ToolsFolder)NuGet."/>
<!-- Get package version from packages.config -->
<XmlPeek Query="//package[@id='$(BuildTaskPackage)']/@version" XmlInputPath=".\packages.config">
<Output PropertyName="PackageVersion" TaskParameter="Result"/>
</XmlPeek>
<Message Text="Original Build PackageVersion=$(PackageVersion)"/>
<!-- Check whether need latest package version -->
<PropertyGroup>
<UseLatestPackage>false</UseLatestPackage>
<UseLatestPackage Condition="'$(PackageVersion)'=='latest'">true</UseLatestPackage>
</PropertyGroup>
<Message Text="Use latest package version: $(UseLatestPackage)"/>
<!-- Get Latest version from nuget server if latest version is needed -->
<XmlPeek Condition="$(UseLatestPackage)" Query="//packageSources/add[@key='op.myget.dev']/@value" XmlInputPath="$(ToolsFolder)NuGet\NuGet.config">
<Output PropertyName="NugetSource" TaskParameter="Result"/>
</XmlPeek>
<Message Condition="$(UseLatestPackage)" Text="NugetSource=$(NugetSource)"/>
<Exec Command=""$(ToolsFolder)NuGet\NuGet.exe" list $(BuildTaskPackage) -Source "$(NugetSource)"" Condition="$(UseLatestPackage)" ConsoleToMSBuild="true">
<Output PropertyName="LatestPackage" TaskParameter="ConsoleOutput"/>
</Exec>
<ItemGroup Condition="$(UseLatestPackage)">
<LatestPackageVersion Include="$(LatestPackage.Split(' ')[1])"/>
</ItemGroup>
<CreateProperty Condition="$(UseLatestPackage)" Value="@(LatestPackageVersion)">
<Output PropertyName="LatestPackageVersion" TaskParameter="Value"/>
</CreateProperty>
<Message Condition="$(UseLatestPackage)" Text="$(BuildTaskPackage) LatestPackageVersion=@(LatestPackageVersion)"/>
<!-- Update packages.config file's version with latest version then do the restore-->
<XmlPoke Condition="$(UseLatestPackage)" Query="//packages/package[@id='$(BuildTaskPackage)']/@version" Value="$(LatestPackageVersion)" XmlInputPath=".\packages.config"/>
<PropertyGroup>
<BuildTaskNugetPackageFolderName>$(BuildTaskPackage).$(PackageVersion)</BuildTaskNugetPackageFolderName>
<BuildTaskNugetPackageFolderName Condition="$(UseLatestPackage)">$(BuildTaskPackage).$(LatestPackageVersion)</BuildTaskNugetPackageFolderName>
<PackageRootFolder>$(MSBuildThisFileDirectory)packages\$(BuildTaskNugetPackageFolderName)\</PackageRootFolder>
<PackageInstalled>True</PackageInstalled>
<BuildProjectPath>$(PackageRootFolder)$(BuildTaskProjectPath)</BuildProjectPath>
<PackageInstalled Condition="EXISTS('$(BuildProjectPath)') != 'True'">False</PackageInstalled>
</PropertyGroup>
<CreateProperty Value="$(OutputPackageRootFolder)">
<Output PropertyName="OutputPackageRootFolder" TaskParameter="Value"/>
</CreateProperty>
<!-- Use NuGet to pull down specific version packages -->
<PropertyGroup>
<NuGetConfigFileArgument Condition="EXISTS('$(ToolsFolder)NuGet\NuGet.config') == 'True'">-ConfigFile "$(ToolsFolder)NuGet\NuGet.config"</NuGetConfigFileArgument>
</PropertyGroup>
<Exec Command=""$(ToolsFolder)NuGet\NuGet.exe" restore ".\packages.config" -PackagesDirectory ".\packages" $(NuGetConfigFileArgument)" Condition="$(PackageInstalled) != 'True'"/>
<!-- Update packages.config file's version back to "latest" string-->
<XmlPoke
Condition="$(UseLatestPackage)"
XmlInputPath=".\packages.config"
Query="//packages/package[@id='$(BuildTaskPackage)']/@version"
Value="$(PackageVersion)" />
</Target>
<ItemGroup>
<DocfxConfigFile Include = "**\docfx.json" Exclude = "packages\**\docfx.json"/>
</ItemGroup>
<!-- Build Target -->
<Target DependsOnTargets="RestorePackages" Name="Build">
<!-- <Target Name="Build"> -->
<PropertyGroup>
<DocfxFolder>$([System.IO.Path]::GetDirectoryName(%(DocfxConfigFile.FullPath)))</DocfxFolder>
<DocfxRelativeFolder>$([MSBuild]::MakeRelative($(MSBuildThisFileDirectory), $(DocfxFolder)))</DocfxRelativeFolder>
<TempOutputFolder>$(DocfxFolder)\obj\_temp_</TempOutputFolder>
<DocParameters Condition="'$(GlobalMetadataFile)' != '' ">--globalMetadataFile "$(GlobalMetadataFile)" </DocParameters>
</PropertyGroup>
<Exec Command="rd /s /q "$(DocfxFolder)\_themes"" IgnoreExitCode="true"/>
<Exec Command="robocopy "$(PackageRootFolder)tools\DocPacker\_themes" "$(DocfxFolder)\_themes" /mir" IgnoreExitCode="true"/>
<MSBuild Projects="$(BuildProjectPath)" Targets="DocBuild" Properties="DocfxConfigFile=%(DocfxConfigFile.FullPath);OutputFolder=$(TempOutputFolder);DocTemplate=$(OPTemplateName);LogFile=$(LogFile);LogLevel=$(LogLevel);DocParameters=$(DocParameters)"/>
<Exec Command=""$(PackageRootFolder)tools\DocPacker\DocPacker.exe" -r "$(TempOutputFolder)" -o "$(OutputFolder)\$(DocfxRelativeFolder)""/>
</Target>
<Target DependsOnTargets="Build" Name="Generate">
<MSBuild Projects="$(BuildProjectPath)" Targets="DocPreview" Properties="DocfxConfigFile=%(DocfxConfigFile.FullPath);OutputFolder=$(OutputFolder);IsServing=False;DocTemplate=$(PreviewTemplateName);LogFile=$(LogFile);LogLevel=$(LogLevel)"/>
</Target>
<Target DependsOnTargets="Generate" Name="Serve">
<Message Text="$(BuildProjectPath)" />
<MSBuild Projects="$(BuildProjectPath)" Targets="DocServe" Properties="DocfxConfigFile=%(DocfxConfigFile.FullPath);OutputFolder=$(OutputFolder);IsServing=True;DocTemplate=$(PreviewTemplateName);LogFile=$(LogFile);LogLevel=$(LogLevel)"/>
</Target>
<Target DependsOnTargets="RestorePackages" Name="Clean">
<MSBuild Projects="$(BuildProjectPath)" Targets="DocClean" Properties="DocfxConfigFile=%(DocfxConfigFile.FullPath);OutputFolder=$(OutputFolder);LogFile=$(LogFile);LogLevel=$(LogLevel)"/>
</Target>
<Target DependsOnTargets="RestorePackages" Name="Rebuild">
<MSBuild Projects="$(BuildProjectPath)" Targets="DocRebuild" Properties="DocfxConfigFile=%(DocfxConfigFile.FullPath);RebuildDoc=True;OutputFolder=$(OutputFolder);DocTemplate=$(OPTemplateName);LogFile=$(LogFile);LogLevel=$(LogLevel)"/>
</Target>
</Project>