-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon_csproj.targets
269 lines (210 loc) · 13.8 KB
/
common_csproj.targets
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Includes MSBuild properties and targets common across all C# projects. -->
<Import Project="$(MSBuildThisFileDirectory)common.targets"/>
<!-- The default clean only removes files from the bin folder that it knows about. Make sure a clean totally cleans the bin folder.-->
<PropertyGroup>
<CleanDependsOn>
$(CleanDependsOn);
ReallyCleanBinDir
</CleanDependsOn>
</PropertyGroup>
<Target Name="ReallyCleanBinDir">
<RemoveDir Directories="$(OutputPath)" Condition="Exists('$(OutputPath)')" />
</Target>
<!-- Can't do up-to-date checking of creating the dynamic assembly info file until SetVersionProperties has run -->
<Target Name="CreateDynamicAssemblyInfo" DependsOnTargets="SetVersionProperties;_CreateDynamicAssemblyInfo">
</Target>
<Target Name="_CreateDynamicAssemblyInfo" Inputs="$(MSBuildThisFileFullPath)" Outputs="Properties\AssemblyInfo_$(Version).cs">
<MSBuild.Community.Tasks.AssemblyInfo CodeLanguage="CS" OutputFile="Properties\AssemblyInfo_$(Version).cs"
AssemblyVersion="$(Version)" AssemblyFileVersion="$(Version)" />
<!-- Don't use an <ItemGroup> because mono's xbuild doesn't support dynamic items. -->
<CreateItem Include="Properties\AssemblyInfo_$(Version).cs">
<Output TaskParameter="Include" ItemName="Compile"/>
</CreateItem>
</Target>
<Target Name="CleanDynamicAssemblyInfo" DependsOnTargets="SetVersionProperties">
<CreateItem Include="Properties\AssemblyInfo_*.cs">
<Output TaskParameter="Include" ItemName="DynamicAssemblyInfoFiles" />
</CreateItem>
<Delete Files="@(DynamicAssemblyInfoFiles)" />
</Target>
<PropertyGroup>
<BuildDependsOn>
CreateDynamicAssemblyInfo;
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>
<PropertyGroup>
<CleanDependsOn>
$(CleanDependsOn);
CleanDynamicAssemblyInfo
</CleanDependsOn>
</PropertyGroup>
<Target Name="BuildZipPackage" DependsOnTargets="_CheckZipProperties;SetVersionProperties;Build">
<RemoveDir Directories="ZipReleases\Staging\$(ZipNameWithoutVersion)_$(Version)" Condition="Exists('ZipReleases\Staging\$(ZipNameWithoutVersion)_$(Version)')" />
<CreateItem Include="bin\$(Configuration)_$(Platform)\**\*" Exclude="**\*.pdb;**\*.mdb;**\*.xml;**\*vshost.exe*">
<Output TaskParameter="Include" ItemName="BuildOutput" />
</CreateItem>
<Copy SourceFiles="@(BuildOutput)" DestinationFolder="ZipReleases\Staging\$(ZipNameWithoutVersion)_$(Version)\%(RecursiveDir)" />
<MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" ZipFileName="$(ZipNameWithoutVersion)_$(Version).zip" CompressPath="ZipReleases\Staging\$(ZipNameWithoutVersion)_$(Version)" />
<Move SourceFiles="$(ZipNameWithoutVersion)_$(Version).zip" DestinationFolder="ZipReleases" />
<RemoveDir Directories="ZipReleases\Staging" Condition="Exists('ZipReleases\Staging')" />
</Target>
<Target Name="_CheckZipProperties">
<Error Condition="'$(ZipNameWithoutVersion)' == ''" Text="ZipNameWithoutVersion not set" />
</Target>
<Target Name="CleanZipReleases">
<RemoveDir Directories="ZipReleases" Condition="Exists('ZipReleases')" />
</Target>
<PropertyGroup>
<CleanDependsOn>
$(CleanDependsOn);
CleanZipReleases
</CleanDependsOn>
</PropertyGroup>
<PropertyGroup>
<PackageMaintainer>Greg Najda <[email protected]></PackageMaintainer>
<PackageUrl>https://github.com/lhcgreg/dbsc</PackageUrl>
</PropertyGroup>
<PropertyGroup>
<DebSourceDir>$(MSBuildProjectDirectory)/deb/</DebSourceDir>
<DebStagingBaseDir>$(MSBuildProjectDirectory)/deb/staging/</DebStagingBaseDir>
<DebOutputDir>$(MSBuildProjectDirectory)/deb/bin/</DebOutputDir>
<LintianSuppressFilePath>$(MSBuildProjectDirectory)/../linux_common/lintian_suppress.txt</LintianSuppressFilePath>
<DebDescriptionFilePath>$(DebSourceDir)description.txt</DebDescriptionFilePath>
</PropertyGroup>
<Target Name="SetDebProperties" DependsOnTargets="CheckDebProperties;SetVersionProperties;Build">
<!-- Don't use a <PropertyGroup> because mono's xbuild doesn't support dynamic properties. -->
<CreateProperty Value="$(MajorVersion).$(MinorVersion).$(FixVersion)">
<Output TaskParameter="Value" PropertyName="DebianPackageVersion" />
</CreateProperty>
<CreateProperty Value="$(DebStagingBaseDir)$(DebianPackageName)_$(DebianPackageVersion)/">
<Output TaskParameter="Value" PropertyName="DebStagingDir" />
</CreateProperty>
<CreateItem Include="$(TargetDir)*.dll;$(TargetDir)*.exe;$(TargetDir)*.config">
<Output TaskParameter="Include" ItemName="UsrLibPackageFiles" />
</CreateItem>
<CreateItem Include="linux_common/$(DebianPackageName)">
<Output TaskParameter="Include" ItemName="UsrBinPackageFiles" />
</CreateItem>
<CreateItem Include="@(LicenseFiles)">
<Output TaskParameter="Include" ItemName="UsrShareDocPackageFiles" />
</CreateItem>
<CreateProperty Value="$(MSBuildProjectDirectory)/linux_common/$(DebianPackageName).1">
<Output TaskParameter="Value" PropertyName="ManPagePath" />
</CreateProperty>
<CreateProperty Value="$(DebOutputDir)$(DebianPackageName)_$(DebianPackageVersion).deb">
<Output TaskParameter="Value" PropertyName="DebOutputFilePath" />
</CreateProperty>
</Target>
<Target Name="BuildDebianPackage" DependsOnTargets="CheckDebProperties;Rebuild;SetVersionProperties;SetDebProperties">
<!-- Copy *.dll, *.exe, *.config to deb/staging/$(DebianPackageName)_$(DebianPackageVersion)/usr/lib/$(DebianPackageName)/ -->
<Copy SourceFiles="@(UsrLibPackageFiles)" DestinationFolder="$(DebStagingDir)usr/lib/$(DebianPackageName)/" />
<!-- Copy copyright and license files to deb/staging/$(DebianPackageName)_$(DebianPackageVersion)/usr/share/doc/$(DebianPackageName)/ -->
<Copy SourceFiles="@(UsrShareDocPackageFiles)" DestinationFolder="$(DebStagingDir)usr/share/doc/$(DebianPackageName)/" />
<Copy SourceFiles="$(DebCopyrightFile)" DestinationFiles="$(DebStagingDir)usr/share/doc/$(DebianPackageName)/copyright" />
<!-- Mark the .exe as executable as per packaging guidelines. It's not required to run it using "mono foo.exe" but it does allow
it to be executed if the system is set to be able to execute CLR assemblies like regular binaries. -->
<Exec Command="chmod +x $(DebStagingDir)usr/lib/$(DebianPackageName)/*.exe" />
<!-- Mark dlls as not executable to fix a lintian warning. -->
<Exec Command="chmod -x $(DebStagingDir)usr/lib/$(DebianPackageName)/*.dll" />
<!-- Copy wrapper shell script to deb/staging/$(DebianPackageName)_$(DebianPackageVersion)usr/bin/ -->
<Copy SourceFiles="@(UsrBinPackageFiles)" DestinationFolder="$(DebStagingDir)usr/bin/" />
<!-- Copy man page to deb/staging/$(DebianPackageName)_$(DebianPackageVersion)/usr/share/man/man1 and gzip it. -->
<Copy SourceFiles="$(ManPagePath)" DestinationFolder="$(DebStagingDir)usr/share/man/man1" />
<Exec Command="gzip -9 $(DebStagingDir)usr/share/man/man1/$(DebianPackageName).1" />
<MakeDir Directories="$(DebOutputDir)" />
<CreateProperty Value="fpm -t deb -s dir --package $(DebOutputFilePath) --force --name $(DebianPackageName) --version $(DebianPackageVersion) --deb-priority extra --category database --architecture all --maintainer '$(PackageMaintainer)' --url '$(PackageUrl)' --vendor '' --license '' --description "`cat $(DebDescriptionFilePath)`" $(DebianDependencyFpmFlags) .">
<Output TaskParameter="Value" PropertyName="fpmCommandLine" />
</CreateProperty>
<Exec Command="$(fpmCommandLine)" WorkingDirectory="$(DebStagingDir)" />
<Exec Command="lintian --suppress-tags-from-file $(LintianSuppressFilePath) $(DebOutputFilePath)" />
</Target>
<Target Name="CheckDebProperties">
<Error Condition="'$(DebianPackageName)' == ''" Text="DebianPackageName not set. It should be set in the .targets file for the project." />
<Error Condition="'@(LicenseFiles)' == ''" Text="LicenseFiles not set. It should be set in the .targets file for the project." />
<Error Condition="'$(DebianDependencyFpmFlags)' == ''" Text="DebianDependencyFpmFlags not set. It should be set in the .targets file for the project." />
</Target>
<Target Name="CleanDeb">
<RemoveDir Directories="$(DebStagingBaseDir)" Condition="Exists('$(DebStagingBaseDir)')" />
<RemoveDir Directories="$(DebOutputDir)" Condition="Exists('$(DebOutputDir)')" />
</Target>
<PropertyGroup>
<CleanDependsOn>
$(CleanDependsOn);
CleanDeb
</CleanDependsOn>
</PropertyGroup>
<PropertyGroup>
<RpmSourceDir>$(MSBuildProjectDirectory)/rpm/</RpmSourceDir>
<RpmStagingBaseDir>$(MSBuildProjectDirectory)/rpm/staging/</RpmStagingBaseDir>
<RpmOutputDir>$(MsBuildProjectDirectory)/rpm/bin/</RpmOutputDir>
<RpmDescriptionFilePath>$(RpmSourceDir)description.txt</RpmDescriptionFilePath>
<RpmGroup>Development/Tools</RpmGroup>
<RpmlintSuppressFilePath>$(MSBuildProjectDirectory)/../linux_common/rpmlint_suppress.txt</RpmlintSuppressFilePath>
</PropertyGroup>
<Target Name="CheckRpmProperties">
<Error Condition="'$(RpmPackageName)' == ''" Text="RpmPackageName not set. It should be set in the .targets file for the project." />
<Error Condition="'@(LicenseFiles)' == ''" Text="LicenseFiles not set. It should be set in the .targets file for the project." />
<Error Condition="'$(RpmDependencyFpmFlags)' == ''" Text="RpmDependencyFpmFlags not set. It should be set in the .targets file for the project." />
<Error Condition="'$(RpmLicense)' == ''" Text="RpmLicense not set. It should be set in the .targets file for the project." />
</Target>
<Target Name="SetRpmProperties" DependsOnTargets="CheckRpmProperties;SetVersionProperties;Build">
<!-- Don't use a <PropertyGroup> because mono's xbuild doesn't support dynamic properties. -->
<CreateProperty Value="$(MajorVersion).$(MinorVersion).$(FixVersion)">
<Output TaskParameter="Value" PropertyName="RpmPackageVersion" />
</CreateProperty>
<CreateProperty Value="$(RpmStagingBaseDir)$(RpmPackageName)_$(RpmPackageVersion)/">
<Output TaskParameter="Value" PropertyName="RpmStagingDir" />
</CreateProperty>
<CreateItem Include="$(TargetDir)*.dll;$(TargetDir)*.exe;$(TargetDir)*.config">
<Output TaskParameter="Include" ItemName="UsrLibPackageFiles" />
</CreateItem>
<CreateItem Include="linux_common/$(RpmPackageName)">
<Output TaskParameter="Include" ItemName="UsrBinPackageFiles" />
</CreateItem>
<CreateItem Include="@(LicenseFiles)">
<Output TaskParameter="Include" ItemName="UsrShareDocPackageFiles" />
</CreateItem>
<CreateProperty Value="$(MSBuildProjectDirectory)/linux_common/$(RpmPackageName).1">
<Output TaskParameter="Value" PropertyName="ManPagePath" />
</CreateProperty>
<CreateProperty Value="$(RpmOutputDir)$(RpmPackageName)-$(RpmPackageVersion).noarch.rpm">
<Output TaskParameter="Value" PropertyName="RpmOutputFilePath" />
</CreateProperty>
</Target>
<Target Name="BuildRpmPackage" DependsOnTargets="CheckRpmProperties;Rebuild;SetVersionProperties;SetRpmProperties">
<!-- Copy *.dll, *.exe, *.config to rpm/staging/$(RpmPackageName)_$(RpmPackageVersion)/usr/lib/$(RpmPackageName)/ -->
<Copy SourceFiles="@(UsrLibPackageFiles)" DestinationFolder="$(RpmStagingDir)usr/lib/$(RpmPackageName)/" />
<!-- Copy copyright and license files to rpm/staging/$(RpmPackageName)_$(RpmPackageVersion)/usr/share/doc/$(RpmPackageName)/ -->
<Copy SourceFiles="@(UsrShareDocPackageFiles)" DestinationFolder="$(RpmStagingDir)usr/share/doc/$(RpmPackageName)/" />
<Copy SourceFiles="$(RpmCopyrightFile)" DestinationFiles="$(RpmStagingDir)usr/share/doc/$(RpmPackageName)/copyright" />
<!-- Mark the .exe as executable as per packaging guidelines. It's not required to run it using "mono foo.exe" but it does allow
it to be executed if the system is set to be able to execute CLR assemblies like regular binaries. -->
<Exec Command="chmod +x $(RpmStagingDir)usr/lib/$(RpmPackageName)/*.exe" />
<!-- Mark dlls as not executable. -->
<Exec Command="chmod -x $(RpmStagingDir)usr/lib/$(RpmPackageName)/*.dll" />
<!-- Copy wrapper shell script to rpm/staging/$(RpmPackageName)_$(RpmPackageVersion)usr/bin/ -->
<Copy SourceFiles="@(UsrBinPackageFiles)" DestinationFolder="$(RpmStagingDir)usr/bin/" />
<!-- Copy man page to rpm/staging/$(RpmPackageName)_$(RpmPackageVersion)/usr/share/man/man1 and gzip it. -->
<Copy SourceFiles="$(ManPagePath)" DestinationFolder="$(RpmStagingDir)usr/share/man/man1" />
<Exec Command="gzip -9 $(RpmStagingDir)usr/share/man/man1/$(RpmPackageName).1" />
<MakeDir Directories="$(RpmOutputDir)" />
<CreateProperty Value="fpm -s dir -t rpm --package '$(RpmOutputFilePath)' --force --name '$(RpmPackageName)' --version '$(RpmPackageVersion)' --epoch 1 --category '$(RpmGroup)' --architecture all --maintainer '$(PackageMaintainer)' --url '$(PackageUrl)' --vendor '' --license '$(RpmLicense)' --description "`cat $(RpmDescriptionFilePath)`" $(RpmDependencyFpmFlags) .">
<Output TaskParameter="Value" PropertyName="fpmCommandLine" />
</CreateProperty>
<Exec Command="$(fpmCommandLine)" WorkingDirectory="$(RpmStagingDir)" />
<Exec Command="rpmlint -f '$(RpmlintSuppressFilePath)' $(RpmOutputFilePath)" />
</Target>
<Target Name="CleanRpm">
<RemoveDir Directories="$(RpmStagingBaseDir)" Condition="Exists('$(RpmStagingBaseDir)')" />
<RemoveDir Directories="$(RpmOutputDir)" Condition="Exists('$(RpmOutputDir)')" />
</Target>
<PropertyGroup>
<CleanDependsOn>
$(CleanDependsOn);
CleanRpm
</CleanDependsOn>
</PropertyGroup>
</Project>