forked from fwestrom/Medseek.Util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMedseek.Util.proj
282 lines (256 loc) · 14.6 KB
/
Medseek.Util.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
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
270
271
272
273
274
275
276
277
278
279
280
281
282
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build;Test" InitialTargets="Prepare" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Configurable properties -->
<PropertyGroup Label="Configurable Properties">
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<RootDir Condition="'$(RootDir)' == ''">$(MSBuildProjectDirectory)\</RootDir>
<SourceDir Condition="'$(SourceDir)' == ''">$(RootDir)</SourceDir>
<BuildDir Condition="'$(BuildDir)' == ''">$(RootDir)build\</BuildDir>
<ToolsDir Condition="'$(ToolsDir)' == ''">$(RootDir)tools\</ToolsDir>
<NuGetDir Condition="'$(NuGetDir)' == ''">$(SourceDir).nuget\</NuGetDir>
<Pack-If-Value Condition="'$(Pack-If-Value)' == ''"></Pack-If-Value>
<Pack-If-Whitelist Condition="'$(Pack-If-Whitelist)' == ''"></Pack-If-Whitelist>
<Skip Condition="'$(Skip)' == ''" />
</PropertyGroup>
<PropertyGroup Label="Other Properties">
<BuildBinDir>$(BuildDir)bin\</BuildBinDir>
<BuildObjDir>$(BuildDir)obj\</BuildObjDir>
<BuildNuspecsDir>$(BuildDir)nuspec\</BuildNuspecsDir>
<BuildPackagesDir>$(BuildDir)packages\</BuildPackagesDir>
<DoClean Condition="'$(DoClean)' == ''">True</DoClean>
<DoBuild Condition="'$(DoBuild)' == ''">True</DoBuild>
<DoTest Condition="'$(DoTest)' == ''">True</DoTest>
<DoPack Condition="'$(DoPack)' == ''">True</DoPack>
<MSBuildCommunityTasksPath Condition="'$(MSBuildCommunityTasksPath)' == ''">$(SourceDir)packages\MSBuildTasks.1.4.0.65\tools\</MSBuildCommunityTasksPath>
<MSBuildNUnitDllPath Condition="'$(MSBuildNUnitDllPath)' == ''"></MSBuildNUnitDllPath>
<NuGetConfigPath Condition="'$(NuGetConfigPath)' == ''">$(NuGetDir)NuGet.config</NuGetConfigPath>
<NuGetExePath Condition="'$(NuGetExePath)' == ''">$(NuGetDir)NuGet.exe</NuGetExePath>
<NuGetTargetsPath Condition="'$(NuGetTargetsPath)' == ''">$(NuGetDir)NuGet.targets</NuGetTargetsPath>
<SolutionDir>$(SourceDir)</SolutionDir>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\</VSToolsPath>
<ProjectProperties>Configuration=$(Configuration)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);RootDir=$(RootDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);SourceDir=$(SourceDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);ToolsDir=$(ToolsDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);NuGetDir=$(NuGetDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);BuildDir=$(BuildDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);BuildBinDir=$(BuildBinDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);BuildObjDir=$(BuildObjDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);BuildPackagesDir=$(BuildPackagesDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);Skip=$(Skip)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);DebugSymbols=true</ProjectProperties>
<ProjectProperties>$(ProjectProperties);GenerateDocumentation=true</ProjectProperties>
<ProjectProperties>$(ProjectProperties);IntermediateOutputPath=$(BuildObjDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);OutputPath=$(BuildBinDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);SolutionDir=$(SolutionDir)</ProjectProperties>
<ProjectProperties>$(ProjectProperties);VSToolsPath=$(VSToolsPath)</ProjectProperties>
</PropertyGroup>
<!-- Build items -->
<ItemGroup>
<ExcludeProjectReferences Include="$(SourceDir)Medseek.Util*\ProjectTemplate.csproj" />
<ExcludeProjectReferences Include="$(SourceDir)Medseek.Util*\*.HelloWorld.csproj" />
<ExcludeProjectReferences Include="$(SourceDir)Medseek.Util*\*.ProjectTemplate.csproj" />
<ExcludeProjectReferences Include="$(SourceDir)Medseek.Util*\*.Extension.csproj" />
<ProjectReference Include="$(SourceDir)Medseek.Util*\*.csproj" Exclude="@(ExcludeProjectReferences)">
<ProjectDir>%(RootDir)%(Directory)</ProjectDir>
<nuspecFileName>%(ProjectDir)%(FileName).nuspec</nuspecFileName>
<ProjAssemblyPath>$(BuildBinDir)%(FileName).$ext$</ProjAssemblyPath>
<UseNuspec Condition="'%(FileName)'=='Medseek.Util.MicroServices.ApplicationServer'">true</UseNuspec>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<!--<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Ioc.Castle.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Logging.Log4Net.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Logging.NLog.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Messaging.RabbitMq.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.MicroServices.Host.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Plugin.WebApi.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Serialization.Newtonsoft.Json.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.Testing.csproj" />
<NuSpec Include="$(SourceDir)Medseek.*\Medseek.Util.MicroServices.ApplicationServer.nuspec" />-->
<NuSpec Include="@(ProjectReference)" />
</ItemGroup>
<!-- Import External Project Files -->
<Import Condition="Exists('$(MSBuildCommunityTasksPath)MSBuild.Community.Tasks.Targets')" Project="$(MSBuildCommunityTasksPath)MSBuild.Community.Tasks.Targets" />
<!-- Prepare -->
<Target Name="Prepare" DependsOnTargets="Prepare-Pack">
<ItemGroup>
<Skip Include="$(Skip)" />
</ItemGroup>
<Message Text="Skip: %(Skip.Identity)" />
<CreateProperty Value="False">
<Output PropertyName="Do%(Skip.Identity)" TaskParameter="Value" />
</CreateProperty>
<CreateProperty Value="True">
<Output PropertyName="Skip%(Skip.Identity)" TaskParameter="Value" />
</CreateProperty>
<ItemGroup>
<PrepareDir Include="$(BuildDir)" />
<PrepareDir Include="$(BuildBinDir)" />
<PrepareDir Include="$(BuildObjDir)" />
<PrepareDir Include="$(BuildNuspecsDir)" />
<PrepareDir Include="$(BuildPackagesDir)" />
</ItemGroup>
<MakeDir Directories="@(PrepareDir)" />
<Exec Command='$(NuGetExePath) restore -Verbosity detailed -ConfigFile "$(NuGetConfigPath)" -NonInteractive' WorkingDirectory="$(SourceDir)" />
</Target>
<Target Name="Prepare-Pack" Condition="'$(Pack-If-Whitelist)' != '' AND '$(Pack-If-Value)' != ''">
<Message Text="Pack-If-Value = $(Pack-If-Value)" />
<Message Text="Pack-If-Whitelist = $(Pack-If-Whitelist)" />
<ItemGroup>
<Pack-If-Whitelist Include="$(Pack-If-Whitelist)" />
</ItemGroup>
<Message Text="Pack-If-Whitelist: %(Pack-If-Whitelist.Identity)" />
<PropertyGroup>
<Skip-Pack Condition="'$(Skip-Pack)' == '' AND '$(Pack-If-Value)' == '%(Pack-If-Whitelist.Identity)'">true</Skip-Pack>
<Skip Condition="'$(Skip-Pack)' != 'true'">$(Skip);Pack</Skip>
</PropertyGroup>
</Target>
<!-- Clean -->
<Target Name="Clean" Condition="$(DoClean)">
<ItemGroup>
<Directory Include="@(PrepareDir)" />
<Directory Include="%(ProjectReference.RelativeDir)bin\" />
<Directory Include="%(ProjectReference.RelativeDir)obj\" />
<File Include="%(Directory.Identity)**" />
</ItemGroup>
<RemoveDir Directories="@(Directory)" ContinueOnError="true" />
<Delete Files="@(File)" TreatErrorsAsWarnings="true" />
</Target>
<!-- Build -->
<Target Name="Build" Condition="$(DoBuild)">
<MSBuild Projects="@(ProjectReference)" Properties="$(ProjectProperties)" RebaseOutputs="true">
<Output TaskParameter="TargetOutputs" ItemName="OutputAssemblies" />
</MSBuild>
</Target>
<!-- Test -->
<Target Name="Test" Condition="$(DoTest)" DependsOnTargets="Build">
<PropertyGroup>
<NeedUpdatePath>True</NeedUpdatePath>
<NeedUpdatePath Condition="'$(MSBuildNUnitDllPath)' != ''">False</NeedUpdatePath>
</PropertyGroup>
<Message Text="MSBuildNUnitDllPath = $(MSBuildNUnitDllPath)" />
<ItemGroup Condition="$(NeedUpdatePath)">
<MSBuildNUnitDll Include="$(SourceDir)packages\MSBuild.NUnit.*\tools\MSBuild.NUnit.dll" />
</ItemGroup>
<CreateProperty Value="%(MSBuildNUnitDll.Identity)" Condition="$(NeedUpdatePath)">
<Output PropertyName="MSBuildNUnitDllPath" TaskParameter="Value" />
</CreateProperty>
<Message Text="MSBuildNUnitDllPath = $(MSBuildNUnitDllPath)" Condition="$(NeedUpdatePath)" />
<CallTarget Targets="Test-NUnit" Condition="!$(NeedUpdatePath)" />
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="Test"
Properties="MSBuildNUnitDllPath=$(MSBuildNUnitDllPath);DoBuild=false;DoBuild=false"
Condition="$(NeedUpdatePath)"
/>
</Target>
<UsingTask TaskName="NUnit" AssemblyFile="$(MSBuildNUnitDllPath)" Condition="'$(MSBuildNUnitDllPath)' != ''" />
<Target Name="Test-NUnit" Condition="'$(RunIncompleteTestTarget)' == true">
<ItemGroup>
<TestAssembly Include="$(BuildBinDir)Medseek.Util.Test.dll" />
<TestAssembly Include="$(BuildBinDir)Medseek.Util.*.Test.dll" />
</ItemGroup>
<NUnit
Assemblies="@(TestAssembly)"
TestCaseTimeoutInMilliseconds="30000"
WorkingDirectory="$(BuildBinDir)"
/>
</Target>
<!-- Pack -->
<Target Name="Pack" DependsOnTargets="Build" Inputs="@(NuSpec)" Outputs="$(BuildPackagesDir)%(Filename).nupkg" Condition="$(DoPack)">
<!--
<MSBuild.Community.Tasks.Git.GitBranch LocalPath="$(SourceDir)">
<Output TaskParameter="Branch" PropertyName="GitBranch" />
</MSBuild.Community.Tasks.Git.GitBranch>
<PropertyGroup>
<PreReleaseTag Condition="'$(GitBranch)' != 'develop'">$(GitBranch)</PreReleaseTag>
</PropertyGroup>
-->
<PropertyGroup>
<UseNuspec>false</UseNuspec>
<UseNuspec Condition="'%(NuSpec.UseNuspec)'=='true'">true</UseNuspec>
</PropertyGroup>
<GetMetadataInfo Condition="$(UseNuspec)" AssemblyPath="%(NuSpec.ProjAssemblyPath)">
<Output TaskParameter="MetadataInfo" ItemName="MetadataInfo"/>
</GetMetadataInfo>
<Copy Condition="$(UseNuspec)" SourceFiles="%(NuSpec.nuspecFileName)" DestinationFiles="$(BuildNuspecsDir)%(NuSpec.Filename).nuspec">
<Output TaskParameter="CopiedFiles" ItemName="CopiedNuspec" />
</Copy>
<!--Add Configuration to the metadata-->
<ItemGroup>
<MetadataInfo>
<Configuration>$(Configuration)</Configuration>
</MetadataInfo>
</ItemGroup>
<ReplaceTokens Condition="$(UseNuspec)" NuspecPath="%(CopiedNuspec.Identity)" MetadataInfo="@(MetadataInfo)" />
<PropertyGroup>
<PackCommand>$(NuGetExePath) pack</PackCommand>
<PackCommand Condition="'$(UseNuspec)'=='true'">$(PackCommand) "%(CopiedNuspec.Identity)"</PackCommand>
<PackCommand Condition="'$(UseNuspec)'!='true'">$(PackCommand) "%(NuSpec.Identity)"</PackCommand>
<PackCommand>$(PackCommand) -BasePath $(BuildBinDir)</PackCommand>
<PackCommand>$(PackCommand) -OutputDirectory $(BuildPackagesDir)</PackCommand>
<PackCommand>$(PackCommand) -Symbols</PackCommand>
<PackCommand>$(PackCommand) -Prop Configuration=$(Configuration)</PackCommand>
<PackCommand>$(PackCommand) -Prop OutputPath=$(BuildBinDir)</PackCommand>
<PackCommand>$(PackCommand) -Verbosity detailed</PackCommand>
<PackCommand>$(PackCommand) -NoPackageAnalysis</PackCommand>
</PropertyGroup>
<Exec Command="$(PackCommand)" WorkingDirectory="$(BuildDir)" />
<ItemGroup>
<ToCopy Include="$(BuildBinDir)*.vsix" />
</ItemGroup>
<Copy SourceFiles="@(ToCopy)" DestinationFolder="$(BuildPackagesDir)" />
</Target>
<!-- Custom tasks -->
<UsingTask TaskName="GetMetadataInfo" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<AssemblyPath ParameterType="System.String" Required="true"/>
<MetadataInfo ParameterType="Microsoft.Build.Framework.ITaskItem" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Reflection" />
<Code Type="Fragment" Language="cs">
<![CDATA[
if (System.IO.File.Exists(this.AssemblyPath.Replace("$ext$", "dll")))
this.AssemblyPath = this.AssemblyPath.Replace("$ext$", "dll");
else if (System.IO.File.Exists(this.AssemblyPath.Replace("$ext$", "exe")))
this.AssemblyPath = this.AssemblyPath.Replace("$ext$", "exe");
Assembly assembly = System.Reflection.Assembly.LoadFrom(this.AssemblyPath);
MetadataInfo = new TaskItem(assembly.GetName().Name);
MetadataInfo.SetMetadata("Version", assembly.GetName().Version.ToString());
var attributes = assembly.GetCustomAttributes(typeof (AssemblyTitleAttribute), false);
MetadataInfo.SetMetadata("Title", ((AssemblyTitleAttribute)attributes[0]).Title);
attributes = assembly.GetCustomAttributes(typeof (AssemblyCompanyAttribute), false);
MetadataInfo.SetMetadata("Company", ((AssemblyCompanyAttribute)attributes[0]).Company);
attributes = assembly.GetCustomAttributes(typeof (AssemblyDescriptionAttribute), false);
MetadataInfo.SetMetadata("Description", ((AssemblyDescriptionAttribute)attributes[0]).Description);
attributes = assembly.GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false);
MetadataInfo.SetMetadata("Copyright", ((AssemblyCopyrightAttribute)attributes[0]).Copyright);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ReplaceTokens" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<NuspecPath ParameterType="System.String" Required="true" />
<MetadataInfo ParameterType="Microsoft.Build.Framework.ITaskItem" Required="true"/>
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
string content = File.ReadAllText(NuspecPath);
content = content.Replace("$id$", MetadataInfo.ItemSpec);
content = content.Replace("$version$", MetadataInfo.GetMetadata("Version"));
content = content.Replace("$title$", MetadataInfo.GetMetadata("Title"));
content = content.Replace("$author$", MetadataInfo.GetMetadata("Company"));
content = content.Replace("$copyright$", MetadataInfo.GetMetadata("Copyright"));
content = content.Replace("$description$", MetadataInfo.GetMetadata("Description"));
content = content.Replace("$configuration$", MetadataInfo.GetMetadata("Configuration"));
File.WriteAllText(NuspecPath, content);
]]>
</Code>
</Task>
</UsingTask>
</Project>