forked from EvilBeaver/OneScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.csproj
249 lines (197 loc) · 12.3 KB
/
Build.csproj
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<PropertyGroup>
<ReleaseNumber Condition="'$(ReleaseNumber)' == ''">1.1.0</ReleaseNumber>
<BuildNumber Condition="'$(BUILD_NUMBER)' != ''">$(BUILD_NUMBER)</BuildNumber>
<BuildNumber Condition="'$(BUILD_NUMBER)' == ''">0</BuildNumber>
<ArtifactsRoot>$(MSBuildProjectDirectory)/built</ArtifactsRoot>
<Solution>$(MSBuildProjectDirectory)/src/1Script.sln</Solution>
<Configuration>Release</Configuration>
</PropertyGroup>
<ItemGroup>
<PlatformItem Include="x86">
<MSBuildName>x86</MSBuildName>
<BinFolder>bin32</BinFolder>
</PlatformItem>
<PlatformItem Include="x64">
<MSBuildName>Any CPU</MSBuildName>
<BinFolder>bin</BinFolder>
</PlatformItem>
</ItemGroup>
<Target Name="CleanAll">
<ItemGroup>
<TestsResults Include="$(MSBuildProjectDirectory)/tests/*.os.xml" />
</ItemGroup>
<Delete Files="@(TestsResults)" />
<DeleteTree Directories="$(ArtifactsRoot)" Condition="Exists($(ArtifactsRoot))" />
<MSBuild Projects="$(Solution)" Targets="Clean" Properties="ReleaseNumber=$(ReleaseNumber);Configuration=$(Configuration);Platform=%(PlatformItem.MSBuildName)"/>
</Target>
<Target Name="Make">
<MSBuild Projects="$(Solution)" Targets="restore;Build" Properties="ReleaseNumber=$(ReleaseNumber);Configuration=$(Configuration);Platform=%(PlatformItem.MSBuildName);"/>
</Target>
<Target Name="CreateDistributions" DependsOnTargets="CreateInstaller;CreateNuget;CreateZip">
<ItemGroup>
<TempContent Include="$(ArtifactsRoot)/tmp"/>
<TempContent Include="$(MDDocFolder)"/>
</ItemGroup>
<DeleteTree Directories="@(TempContent)"/>
</Target>
<Target Name="PrepareArtifactsRoot">
<PropertyGroup>
<TempFolder>$(ArtifactsRoot)/tmp</TempFolder>
<LibFolder>$(TempFolder)/lib</LibFolder>
<ToolFolder>$(TempFolder)/bin</ToolFolder>
<ExamplesFolder>$(TempFolder)/examples</ExamplesFolder>
<DocFolder>$(TempFolder)/doc</DocFolder>
<DebugDest>$(ArtifactsRoot)\vscode\</DebugDest>
<MDDocFolder>$(ArtifactsRoot)/mddoc</MDDocFolder>
</PropertyGroup>
<MakeDir Directories="$(ArtifactsRoot)" />
<MakeDir Directories="$(TempFolder)" />
</Target>
<Target Name="PrepareDistributionContent">
<CallTarget Targets="GatherBinaries" />
<CallTarget Targets="GatherLibrary" />
<CallTarget Targets="GatherExamples" />
<CallTarget Targets="GatherDocuments" Condition=" '$(OneScriptDocumenter)' != '' "/>
<CallTarget Targets="CleanIntermediates"/>
</Target>
<!-- Собирает отовсюду содержимое папки bin -->
<Target Name="GatherBinaries" DependsOnTargets="Make;PrepareArtifactsRoot">
<ItemGroup>
<BuiltProjects Include="oscript" />
<BuiltProjects Include="TestApp" />
<BinaryFiles Include="$(MSBuildProjectDirectory)/src/%(BuiltProjects.Identity)/bin/$(Configuration)/net452/**">
<Dest>$(TempFolder)/bin</Dest>
</BinaryFiles>
<BinaryFiles Include="$(MSBuildProjectDirectory)/src/%(BuiltProjects.Identity)/bin/x86/$(Configuration)/net452/**">
<Dest>$(TempFolder)/bin32</Dest>
</BinaryFiles>
<AspFiles Include="$(MSBuildProjectDirectory)/src/ASPNETHandler/bin/$(Configuration)/net452/ASPNETHandler.dll"/>
</ItemGroup>
<ItemGroup>
<BuiltProjects Include="ScriptEngine.NativeApi" />
<BinaryFiles Include="$(MSBuildProjectDirectory)/src/%(BuiltProjects.Identity)/bin/$(Configuration)/net452/*.dll">
<Dest>$(TempFolder)/bin</Dest>
</BinaryFiles>
<BinaryFiles Include="$(MSBuildProjectDirectory)/src/%(BuiltProjects.Identity)/bin/x86/$(Configuration)/net452/*.dll">
<Dest>$(TempFolder)/bin32</Dest>
</BinaryFiles>
</ItemGroup>
<Copy SourceFiles="@(BinaryFiles)" DestinationFiles="@(BinaryFiles->'%(Dest)/%(Filename)%(Extension)')" />
<Copy SourceFiles="@(AspFiles)" DestinationFolder="%(BinaryFiles.Dest)"/>
<!-- Копирование скрипта запуска для opm -->
<Copy SourceFiles="$(MSBuildProjectDirectory)\install\opm.bat" DestinationFolder="%(BinaryFiles.Dest)"/>
<PropertyGroup>
<DebugSrc>$(MSBuildProjectDirectory)/src/VSCode.DebugAdapter/bin/$(Configuration)/net452</DebugSrc>
</PropertyGroup>
<ItemGroup>
<DbgBinFiles Include="$(DebugSrc)/*.dll"/>
<DbgBinFiles Include="$(DebugSrc)/*.exe"/>
<DbgBinFiles Include="$(DebugSrc)/*.config"/>
<DbgPackageFiles Include="$(DebugSrc)/README.md"/>
<DbgPackageFiles Include="$(DebugSrc)/package.json"/>
<DbgImageFiles Include="$(DebugSrc)/images/**"/>
</ItemGroup>
<Copy SourceFiles="@(DbgBinFiles)" DestinationFolder="$(DebugDest)/bin"/>
<Copy SourceFiles="@(DbgPackageFiles)" DestinationFolder="$(DebugDest)"/>
<Copy SourceFiles="@(DbgImageFiles)" DestinationFolder="$(DebugDest)/images"/>
<Exec WorkingDirectory="$(TempFolder)" Command=""$(ToolFolder)/oscript.exe" -version > VERSION"/>
</Target>
<!-- Собирает в целевой папке содержимое папки lib -->
<Target Name="GatherLibrary" DependsOnTargets="Make;GatherBinaries">
<MakeDir Directories="$(LibFolder)" />
<CallTarget Targets="InstallStdLib" Condition="'$(StandardLibraryPacks)' != ''"/>
<DeleteTree Directories="$(LibFolder)/opm" />
<Exec Command=""$(ToolFolder)/oscript.exe" "$(MSBuildProjectDirectory)\install\unicode-zipper.os" unpack "$(MSBuildProjectDirectory)\install\opm.ospx" "$(LibFolder)\tmp""/>
<Exec Command=""$(ToolFolder)/oscript.exe" "$(MSBuildProjectDirectory)\install\unicode-zipper.os" unpack "$(LibFolder)\tmp\content.zip" "$(LibFolder)/opm""/>
<Copy SourceFiles="$(MSBuildProjectDirectory)\install\package-loader.os" DestinationFolder="$(LibFolder)"/>
<DeleteTree Directories="$(LibFolder)\tmp"/>
</Target>
<!-- Копирует поставляемые файлы stdlib, если они есть на машине сборки -->
<Target Name="InstallStdLib">
<ItemGroup>
<LibraryFiles Include="$(StandardLibraryPacks)\**\*" Exclude="package-loader.os"/>
</ItemGroup>
<Copy SourceFiles="@(LibraryFiles)" DestinationFolder="$(LibFolder)\%(RecursiveDir)"/>
</Target>
<!-- Собирает в целевой папке содержимое папки examples -->
<Target Name="GatherExamples" DependsOnTargets="PrepareArtifactsRoot">
<ItemGroup>
<ExampleFiles Include="$(MSBuildProjectDirectory)\install\examples\**\*"/>
</ItemGroup>
<MakeDir Directories="$(ExamplesFolder)" />
<Copy SourceFiles="@(ExampleFiles)" DestinationFolder="$(ExamplesFolder)\%(RecursiveDir)"/>
</Target>
<!-- Собирает в целевой папке содержимое папки doc -->
<Target Name="GatherDocuments" DependsOnTargets="PrepareArtifactsRoot;GenerateDocs">
<MakeDir Directories="$(DocFolder)"/>
<Exec Command="$(OneScriptDocumenter) html $(TMP)\tempdoc.xml "$(DocFolder)""/>
</Target>
<!-- Генерирует необходимую документацию -->
<Target Name="GenerateDocs">
<Exec Command="$(OneScriptDocumenter) $(TMP)\tempdoc.xml "$(ToolFolder)\ScriptEngine.dll" "$(ToolFolder)\ScriptEngine.HostedScript.dll" "$(ToolFolder)\oscript.exe""/>
<MakeDir Directories="$(MDDocFolder)"/>
<Exec Command="$(OneScriptDocumenter) markdown $(TMP)\tempdoc.xml "$(MDDocFolder)" /syntax/page"/>
</Target>
<!-- Чистка промежуточных файлов -->
<Target Name="CleanIntermediates">
<ItemGroup>
<ExcludedArtifacts Include="$(TempFolder)/%(PlatformItem.BinFolder)/*.pdb" />
<ExcludedArtifacts Include="$(TempFolder)/%(PlatformItem.BinFolder)/*.xml" />
<!-- остается от документера. Надо починить его чтобы писал куда-то в другое место -->
<ExcludedArtifacts Include="$(MSBuildProjectDirectory)/map.json"/>
</ItemGroup>
<Delete Files="@(ExcludedArtifacts)"/>
</Target>
<!-- Инсталлятор -->
<Target Name="CreateInstaller" DependsOnTargets="PrepareArtifactsRoot">
<Error Text="No installer path is specified" Condition="'$(InnoSetupPath)' == ''"/>
<PropertyGroup>
<InstallerStandardPath>"$(InnoSetupPath)\iscc.exe"</InstallerStandardPath>
<DistPath>$(ArtifactsRoot)</DistPath>
</PropertyGroup>
<Exec Command="$(InstallerStandardPath) /o"$(DistPath)" /DSuffix=%(PlatformItem.Identity) "$(MSBuildProjectDirectory)\install\install.iss""/>
</Target>
<!-- Nuget -->
<Target Name="CreateNuget" DependsOnTargets="PrepareArtifactsRoot">
<ItemGroup>
<NugetAbleProject Include="ScriptEngine"/>
<NugetAbleProject Include="ScriptEngine.HostedScript"/>
<NugetAbleProject Include="OneScript.Language"/>
<NugetAbleProject Include="OneScript.DebugServices"/>
<NugetAbleProject Include="OneScript.DebugProtocol"/>
</ItemGroup>
<MSBuild Projects="src/%(NugetAbleProject.Identity)/%(NugetAbleProject.Identity).csproj" Targets="pack" Properties="PackageOutputPath=$(ArtifactsRoot);ReleaseNumber=$(ReleaseNumber)"/>
</Target>
<!-- ZIP -->
<Target Name="CreateZip" DependsOnTargets="PrepareArtifactsRoot">
<Exec Command=""$(MSBuildProjectDirectory)\install\prepare-zip.cmd" $(TempFolder) %(PlatformItem.Identity)"/>
<Exec Command=""$(ToolFolder)\oscript.exe" "$(MSBuildProjectDirectory)\install\unicode-zipper.os" pack "$(TempFolder)/zip%(PlatformItem.Identity)/*" "$(ArtifactsRoot)/OneScript-$(ReleaseNumber)-%(PlatformItem.Identity).zip""/>
<Exec Command=""$(ToolFolder)\oscript.exe" "$(MSBuildProjectDirectory)\install\unicode-zipper.os" pack "$(MDDocFolder)/*" "$(ArtifactsRoot)/mddoc-$(ReleaseNumber).zip""/>
</Target>
<!-- MSI -->
<Target Name="CreateMSI">
<MSBuild Projects="$(MSBuildProjectDirectory)\src\Installer\Installer.wixproj"
Properties="Configuration=$(Configuration);OutputPath=$(ArtifactsRoot);OutputPathForBuild=$(ArtifactsRoot);Version=$(ReleaseNumber).$(BuildNumber)" />
</Target>
<Target Name="xUnitTest" DependsOnTargets="PrepareArtifactsRoot">
<CreateItem Include="$(MSBuildProjectDirectory)\tests\*.os.xml">
<Output TaskParameter="Include" ItemName="RemoveXMLTestResult" />
</CreateItem>
<Delete Files="@(RemoveXMLTestResult)" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\tests" Command=""$(ToolFolder)/oscript.exe" "$(MSBuildProjectDirectory)\tests\testrunner.os" -runall . xddReportPath ." IgnoreExitCode="true"/>
</Target>
<Target Name="PublishNuget">
<ItemGroup>
<NugetAbleProject Include="OneScript"/>
<NugetAbleProject Include="OneScript.StandardLibrary"/>
<NugetAbleProject Include="OneScript.Language"/>
<NugetAbleProject Include="OneScript.DebugServices"/>
<NugetAbleProject Include="OneScript.DebugProtocol"/>
</ItemGroup>
<Error Text="No nuget token (/p:NugetToken=) specified" Condition="'$(NugetToken)' == ''" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\built"
Command="dotnet nuget push %(NugetAbleProject.Identity).$(ReleaseNumber).nupkg -k $(NugetToken) -s https://api.nuget.org/v3/index.json"/>
</Target>
</Project>