-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.msbuild
217 lines (179 loc) · 9.73 KB
/
build.msbuild
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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Start">
<PropertyGroup>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\.build</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets" />
<PropertyGroup>
<Major>1</Major>
<Minor>8</Minor>
<Patch>2</Patch>
<PreReleaseString />
<VersionInfoString Condition="$(PreReleaseString) != ''">$(Major).$(Minor).$(Patch)-$(PreReleaseString)</VersionInfoString>
<VersionInfoString Condition="$(PreReleaseString) == ''">$(Major).$(Minor).$(Patch)</VersionInfoString>
</PropertyGroup>
<PropertyGroup>
<Configuration>Release</Configuration>
<DirSource>$([System.IO.Path]::GetFullPath($(MSBuildProjectDirectory)))</DirSource>
<SolutionFilePath>$(DirSource)\Diagnosis.sln</SolutionFilePath>
<VersionInfoPath>$(DirSource)\VersionInfo.cs</VersionInfoPath>
<DirMainOutput>$(DirSource)\$(Configuration)</DirMainOutput>
</PropertyGroup>
<PropertyGroup>
<BuildSolutionDependsOn>
UpdateVersion
</BuildSolutionDependsOn>
<UpdateVersionDependsOn>
</UpdateVersionDependsOn>
<CleanupAfterBuildDependsOn>
BuildSolution
</CleanupAfterBuildDependsOn>
<BuildTestsDependsOn>
</BuildTestsDependsOn>
<BuildSetupDependsOn>
</BuildSetupDependsOn>
<RunTestsDependsOn>
BuildTests
</RunTestsDependsOn>
<ZipSetupDependsOn>
BuildSetup
</ZipSetupDependsOn>
</PropertyGroup>
<!-- "Autostart" -->
<Target Name="Start">
<CallTarget Condition="$(App) == 'client'" Targets="SetUpForClient" />
<CallTarget Condition="$(App) == 'server'" Targets="SetUpForServer" />
<!-- <CallTarget Condition="$(App) == 'tests'" Targets="" /> -->
<CallTarget Condition="$(BuildRelease) == '1'" Targets="Clean" />
<CallTarget Condition="$(BuildRelease) == '1'" Targets="BuildSolution" />
<CallTarget Condition="$(BuildRelease) == '1'" Targets="CleanupAfterBuild" />
<CallTarget Condition="$(BuildRelease) == '1'" Targets="CopyRelease" />
<CallTarget Condition="$(RunTests) == '1'" Targets="RunTests" />
<CallTarget Condition="$(BuildAndZipSetup) == '1'" Targets="BuildInnoSetup" />
</Target>
<Target Name="SetUpForClient">
<PropertyGroup>
<DirAppOutput>$(DirSource)\Diagnosis.Client.App\bin\$(Configuration)</DirAppOutput>
<AppWithVersionName>diagnosis.client.$(VersionInfoString)</AppWithVersionName>
<AppProject>$(DirSource)\Diagnosis.Client.App\Diagnosis.Client.App.csproj</AppProject>
<DirLast>$(DirMainOutput)\$(AppWithVersionName)</DirLast>
<SetupProject>Diagnosis.Client.Setup</SetupProject>
<DirSetup>$(DirSource)\$(SetupProject)</DirSetup>
<DirSetupOutput>$(DirSetup)\$(Configuration)</DirSetupOutput>
<ZipSetupPath>$(DirMainOutput)\$(AppWithVersionName).zip</ZipSetupPath>
<MsiFileName>diagnosis-client.msi</MsiFileName>
<IssFileName>setup-client.iss</IssFileName>
<SetupExeFileNameStart>setup-client</SetupExeFileNameStart>
<!-- copy Help -->
<PostBuild>echo d | xcopy "$(DirSource)\Diagnosis.Client.App\Resources\Help" "$(DirAppOutput)\Help" /d /y</PostBuild>
<!-- copy sql server ce and sqlite.dll -->
<CommonPostBuild>
xcopy /s /y "$(DirSource)\packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\x86\*.*" "$(DirAppOutput)\bin" & xcopy "$(DirSource)\libs\SQLite.Interop.dll" "$(DirAppOutput)\bin" /i /d /y
</CommonPostBuild>
</PropertyGroup>
</Target>
<Target Name="SetUpForServer">
<PropertyGroup>
<DirAppOutput>$(DirSource)\Diagnosis.Server.App\bin\$(Configuration)</DirAppOutput>
<AppWithVersionName>diagnosis.server.$(VersionInfoString)</AppWithVersionName>
<AppProject>$(DirSource)\Diagnosis.Server.App\Diagnosis.Server.App.csproj</AppProject>
<DirLast>$(DirMainOutput)\$(AppWithVersionName)</DirLast>
<SetupProject>Diagnosis.Server.Setup</SetupProject>
<DirSetup>$(DirSource)\$(SetupProject)</DirSetup>
<DirSetupOutput>$(DirSetup)\$(Configuration)</DirSetupOutput>
<ZipSetupPath>$(DirMainOutput)\$(AppWithVersionName).zip</ZipSetupPath>
<MsiFileName>diagnosis-server.msi</MsiFileName>
<IssFileName>setup-server.iss</IssFileName>
<SetupExeFileNameStart>setup-server</SetupExeFileNameStart>
<PostBuild/>
<!-- copy sql server ce and sqlite.dll -->
<CommonPostBuild>
xcopy /s /y "$(DirSource)\packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\x86\*.*" "$(DirAppOutput)\bin" & xcopy "$(DirSource)\libs\SQLite.Interop.dll" "$(DirAppOutput)\bin" /i /d /y
</CommonPostBuild>
</PropertyGroup>
</Target>
<!-- clean output -->
<Target Name="Clean">
<MSBuild Projects="$(AppProject)" ContinueOnError="false" Properties="Configuration=$(Configuration)" Targets="Clean" />
<RemoveDir Directories="$(DirAppOutput)" ContinueOnError="true" />
<MakeDir Directories="$(DirAppOutput)" ContinueOnError="true" />
</Target>
<!-- build porjects -->
<Target Name="BuildSolution" DependsOnTargets="$(BuildSolutionDependsOn)">
<MSBuild Projects="$(AppProject)" ContinueOnError="false" Properties="Configuration=$(Configuration);BuildInParallel=True;PostBuildEvent=">
<Output ItemName="BuildOutput" TaskParameter="TargetOutputs" />
</MSBuild>
<Exec Command="$(CommonPostBuild)" />
<Exec Condition="$(PostBuild) != ''" Command="$(PostBuild)" />
</Target>
<Target Name="CleanupAfterBuild" DependsOnTargets="$(CleanupAfterBuildDependsOn)">
<!-- Delete code analysis files -->
<CreateItem Include="$(DirAppOutput)\**\*CodeAnalysisLog.xml">
<Output TaskParameter="Include" ItemName="CodeAnalysisFiles" />
</CreateItem>
<CreateItem Include="$(DirAppOutput)\**\*.lastcodeanalysissucceeded">
<Output TaskParameter="Include" ItemName="CodeAnalysisFiles" />
</CreateItem>
<Delete Files="%(CodeAnalysisFiles.FullPath)" ContinueOnError="false" />
</Target>
<Target Name="BuildTests" DependsOnTargets="$(BuildTestsDependsOn)">
<ItemGroup>
<TestProject Include="$(DirSource)\**\*.Tests.csproj"></TestProject>
</ItemGroup>
<MSBuild Projects="$(TestProject)" ContinueOnError="false" Properties="Configuration=$(Configuration);BuildInParallel=True;PostBuildEvent=">
<Output ItemName="BuildOutput" TaskParameter="TargetOutputs" />
</MSBuild>
</Target>
<!-- copy files to last-release folder -->
<Target Name="CopyRelease">
<ItemGroup>
<ReleaseFiles
Include="$(DirAppOutput)\**\*.*"
Exclude="$(DirAppOutput)\*.pdb">
</ReleaseFiles>
</ItemGroup>
<Copy SourceFiles="@(ReleaseFiles)" DestinationFiles="@(ReleaseFiles->'$(DirLast)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
<Target Name="UpdateVersion" DependsOnTargets="$(UpdateVersionDependsOn)">
<Message Text="Version: $(VersionInfoString)" />
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(VersionInfoPath)"
AssemblyVersion="$(Major).$(Minor).$(Patch)"
AssemblyFileVersion="$(Major).$(Minor).$(Patch)"
AssemblyInformationalVersion="$(VersionInfoString)" />
</Target>
<!-- build inno setup porject -->
<Target Name="BuildInnoSetup" DependsOnTargets="$(BuildSetupDependsOn)">
<InnoSetup ScriptFile="$(DirSource)\Setup\$(IssFileName)" Quiet="True" />
</Target>
<Target Name="RunTests" DependsOnTargets="$(RunTestsDependsOn)">
<PropertyGroup>
<MsTest>$(ProgramFiles)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe</MsTest>
</PropertyGroup>
<Exec Command=""$(MsTest)" Diagnosis.Common.Tests\bin\Debug\Diagnosis.Common.Tests.dll Diagnosis.Models.Tests\bin\Debug\Diagnosis.Models.Tests.dll Diagnosis.Data.Tests\bin\Debug\Diagnosis.Data.Tests.dll Diagnosis.ViewModels.Tests\bin\Debug\Diagnosis.ViewModels.Tests.dll /logger:trx" />
</Target>
<!-- obsolete setup -->
<!-- build setup porject -->
<Target Name="BuildSetup" DependsOnTargets="$(BuildSetupDependsOn)">
<Exec Command=""$(ProgramFiles)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" "$(SolutionFilePath)" /project "$(DirSetup)\$(SetupProject).vdproj" /rebuild "$(Configuration)|x86"" />
</Target>
<!-- zip setup project installer with correct filename -->
<Target Name="ZipSetup" DependsOnTargets="$(ZipSetupDependsOn)">
<!-- http://stackoverflow.com/questions/3359974/how-to-include-version-number-in-vs-setup-project-output-filename/9891044#9891044 -->
<Exec Command="
findstr /v PostBuildEvent "$(DirSetup)\$(SetupProject).vdproj" | findstr ProductVersion > "$(DirSetup)\temp.txt"
set /p var=<"$(DirSetup)\temp.txt"
set var=%var:"=%
set var=%var: =%
set var=%var:.=-%
for /f "tokens=1,2 delims=:" %%i in ("%var%") do @echo %%j >"$(DirSetup)\temp.txt"
set /p version=<"$(DirSetup)\temp.txt"
del "$(DirSetup)\temp.txt"
rem msi filename must be in vdproj for setup.exe working
rem rename "$(DirSetup)\$(Configuration)\Setup.msi" "$(MsiFileName)"
rename "$(DirSetup)\$(Configuration)\setup.exe" "$(SetupExeFileNameStart)-%version%.exe"" />
<ItemGroup>
<SetupFiles Include="$(DirSetupOutput)\**\*.*" />
</ItemGroup>
<MSBuild.Community.Tasks.Zip Files="@(SetupFiles)" ZipFileName="$(ZipSetupPath)" WorkingDirectory="$(DirSetupOutput)" />
</Target>
</Project>