forked from googleapis/google-api-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneratedLibraries.proj
158 lines (131 loc) · 7.35 KB
/
GeneratedLibraries.proj
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<Project ToolsVersion="12.0" DefaultTargets="Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
This project file requires that 'nuget' and 'python' (version 2)
be in the user's %PATH%.
Targets other than 'Build' support very primitive incrementality: if the
folder they're going to create is already there, they are skipped.
To build libraries and create packages from existing code:
msbuild GeneratedLibraries.proj
To update discovery documents and generate new code:
msbuild GeneratedLibraries.proj /t:GenerateFromScratch
To update discovery documents, code, and packages:
msbuild GeneratedLibraries.proj /t:PackageFromScratch
-->
<PropertyGroup>
<!-- Absolute directory of tools src -->
<ToolsDir>$(MSBuildThisFileDirectory)Src\Tools\</ToolsDir>
<!-- Absolute directory of the JSON discovery documents -->
<DiscoveryDocumentsDir>$(MSBuildThisFileDirectory)DiscoveryJson\</DiscoveryDocumentsDir>
<!-- Absolute directory of the location to put generated code -->
<GeneratedCodeDir>$(MSBuildThisFileDirectory)Src\Generated\</GeneratedCodeDir>
<!-- Absolute directory of the packages repository -->
<PackagesDir>$(MSBuildThisFileDirectory)Src\Generated\packages\</PackagesDir>
<!-- Absolute directory of nupkgs output directory -->
<NuPkgsDir>$(MSBuildThisFileDirectory)NuPkgs\Generated\</NuPkgsDir>
<!-- Absolute directory of the NuGet.Config file -->
<NuGetConfig>$(MSBuildThisFileDirectory)NuGet.Config</NuGetConfig>
</PropertyGroup>
<!-- Download discovery documents used as input to code generation. -->
<Target Name="DownloadDiscoveryDocuments" Condition="!Exists('$(DiscoveryDocumentsDir)')">
<!-- Make DiscoveryJson directory -->
<MakeDir Directories="$(DiscoveryDocumentsDir)" />
<!-- Run python script to download all discovery docs, starting from https://www.googleapis.com/discovery/v1/apis -->
<!-- 'python -u' turns off buffering so status is printed line-by-line. -->
<Exec Command="python -u get_discovery_documents.py --destination_dir $(DiscoveryDocumentsDir)" />
</Target>
<!-- Patch discovery docs that require changes before generation. This process is idempotent. -->
<Target Name="PatchDiscoveryDocuments" DependsOnTargets="DownloadDiscoveryDocuments">
<!-- Build the patcher executable -->
<Exec Command="nuget restore $(ToolsDir)DiscoveryDocPatcher\DiscoveryDocPatcher.sln -ConfigFile $(NuGetConfig)" />
<MSBuild
Projects="$(ToolsDir)DiscoveryDocPatcher\DiscoveryDocPatcher.csproj"
Properties="Configuration=Debug" />
<!-- Execute patcher against the downloaded discovery docs -->
<Exec Command="$(ToolsDir)DiscoveryDocPatcher\bin\Debug\DiscoveryDocPatcher.exe $(DiscoveryDocumentsDir)" />
</Target>
<!-- Generate library projects from discovery documents. -->
<Target Name="Generate" DependsOnTargets="PatchDiscoveryDocuments" Condition="!Exists('$(GeneratedCodeDir)')">
<PropertyGroup>
<_GenerateLibraryTool>ClientGenerator\generate_library.cmd</_GenerateLibraryTool>
</PropertyGroup>
<ItemGroup>
<_DiscoveryDocument Include="$(DiscoveryDocumentsDir)\*.json" />
</ItemGroup>
<MakeDir Directories="$(GeneratedCodeDir)" />
<!-- Execute the code-generated for every JSON discovery document -->
<Exec Command=""$(_GenerateLibraryTool)" --input="%(_DiscoveryDocument.FullPath)" --language=csharp --output_dir=$(GeneratedCodeDir)" />
</Target>
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">ReleaseSigned</Configuration>
</PropertyGroup>
<!-- Warnings to disable -->
<PropertyGroup>
<!-- XML comment on 'construct' has badly formed XML — 'reason' -->
<NoWarn>$(NoWarn),1570</NoWarn>
<!-- XML comment is not placed on a valid language element -->
<NoWarn>$(NoWarn),1587</NoWarn>
<!-- Missing XML comment for publicly visible type or member 'Type_or_Member' -->
<NoWarn>$(NoWarn),1591</NoWarn>
</PropertyGroup>
<Target Name="Broken" DependsOnTargets="Generate">
<!-- Generated libraries that don't compile -->
<!-- In target as these files may not exist until after Generate target has executed -->
<ItemGroup>
<!-- Last released April 2014 (1.8.1.1750) -->
<BrokenProjects Include="$(GeneratedCodeDir)Google.Apis.IdentityToolkit.v3\**" />
<!-- Last released Jan 2015 (1.9.0.860) -->
<BrokenProjects Include="$(GeneratedCodeDir)Google.Apis.Oauth2.v1\**" />
</ItemGroup>
</Target>
<Target Name="NuGetRestore" DependsOnTargets="Generate;Broken">
<!-- nuget restore all packages for non-netstandard builds. All generated libraries have the same dependencies -->
<Exec Command="nuget restore Src\Generated\Google.Apis.Discovery.v1\Profile259\packages.config -PackagesDirectory $(PackagesDir) -ConfigFile $(NuGetConfig)" />
<Exec Command="nuget restore Src\Generated\Google.Apis.Discovery.v1\Profile328\packages.config -PackagesDirectory $(PackagesDir) -ConfigFile $(NuGetConfig)" />
<!-- netstandard projects must be individually restored, creating the project.lock.json files if it doesn't already exist -->
<ItemGroup>
<ProjectJsonAll Include="$(GeneratedCodeDir)**\project.json" Exclude="@(BrokenProjects)" />
<ProjectJson Include="@(ProjectJsonAll)" Condition="!Exists('%(RootDir)%(Directory)project.lock.json')" />
</ItemGroup>
<!-- Only perform restore if anything actually needs restoring -->
<Exec
Condition="'@(ProjectJson)'!=''"
Command="nuget restore %(ProjectJson.Identity) -PackagesDirectory $(PackagesDir) -ConfigFile $(NuGetConfig)" />
</Target>
<!-- Build generated projects. Reply on C#'s incremental build for incrementality -->
<Target Name="Build" DependsOnTargets="Generate;NuGetRestore;Broken">
<!-- Build all projects that are not broken -->
<ItemGroup>
<Projects Include="$(GeneratedCodeDir)**\*.csproj" Exclude="@(BrokenProjects)" />
</ItemGroup>
<MSBuild
Projects="@(Projects)"
BuildInParallel="True"
Targets="Build"
Properties="Configuration=$(Configuration);NugetPackagesDirectory=$(PackagesDir);NoWarn=$(NoWarn)" />
</Target>
<!-- Create NuGet packages with binaries built from generated projects. -->
<Target Name="Package" DependsOnTargets="Build;Broken" Condition="!Exists('$(NuPkgsDir)')">
<!-- Make Nupkgs output directory -->
<MakeDir Directories="$(NuPkgsDir)" />
<ItemGroup>
<NuSpec Include="$(GeneratedCodeDir)*\*.nuspec" Exclude="@(BrokenProjects)" />
</ItemGroup>
<Exec Command="nuget pack "%(NuSpec.FullPath)" -OutputDirectory $(NuPkgsDir)" />
</Target>
<!-- Remove all downloaded and generated artifacts. -->
<Target Name="Reset">
<RemoveDir Directories="$(DiscoveryDocumentsDir);$(GeneratedCodeDir);$(NuPkgsDir)" />
</Target>
<!-- Alias Clean to Reset -->
<Target Name="Clean" DependsOnTargets="Reset" />
<Target Name="CleanGenerated">
<RemoveDir Directories="$(GeneratedCodeDir);$(NuPkgsDir)" />
</Target>
<Target Name="CleanNuGetRestore">
<RemoveDir Directories="$(PackagesDir);$(NuPkgsDir)" />
</Target>
<Target Name="Regenerate" DependsOnTargets="CleanGenerated;Generate" />
<!-- Some common bundled targets. -->
<Target Name="GenerateFromScratch" DependsOnTargets="Reset;Generate" />
<Target Name="PackageFromScratch" DependsOnTargets="Reset;Package" />
</Project>