-
Notifications
You must be signed in to change notification settings - Fork 6
/
BlueCollar.targets
205 lines (178 loc) · 12.3 KB
/
BlueCollar.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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildCommunityTasksPath>$(MSBuildProgramFiles32)\MSBuild\MSBuildCommunityTasks</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets" />
<UsingTask TaskName="GetVersion" AssemblyFile="Tools\Tasty\Tasty.dll"/>
<PropertyGroup>
<CompressAssets Condition="'$(CompressAssets)' == ''">false</CompressAssets>
<ConsoleConfigSubstitutionsFile Condition="'$(ConsoleConfigSubstitutionsFile)' == ''">App.config.Net40</ConsoleConfigSubstitutionsFile>
<HtmlHelpWorkshopDir Condition="'$(HtmlHelpWorkshopDir)' == ''">$(MSBuildProgramFiles32)\HTML Help Workshop</HtmlHelpWorkshopDir>
<RootDir Condition="'$(RootDir)' == ''">$(MSBuildProjectDirectory)</RootDir>
<SandcastleDir Condition="'$(SandcastleDir)' == ''">$(MSBuildProgramFiles32)\Sandcastle</SandcastleDir>
</PropertyGroup>
<PropertyGroup>
<BootstrapDir Condition="'$(BootstrapDir)' == ''">$(RootDir)\Bootstrap</BootstrapDir>
<ExamplesDir Condition="'$(ExamplesDir)' == ''">$(RootDir)\Examples</ExamplesDir>
<KeyFileArgs Condition="'$(SignAssembly)' == 'true' And Exists('$(AssemblyOriginatorKeyFile)')">/keyfile:"$(AssemblyOriginatorKeyFile)"</KeyFileArgs>
<StaticDir Condition="'$(StaticDir)' == ''">$(RootDir)\Source\BlueCollar.Dashboard\Static</StaticDir>
<TemplatesOutputPath Condition="'$(TemplatesOutputPath)' == ''">$(RootDir)\Source\BlueCollar.Dashboard\Views\Shared\_Templates.cshtml</TemplatesOutputPath>
</PropertyGroup>
<Target Name="GenerateConsoleConfig">
<Copy SourceFiles="App.config.base" DestinationFiles="$(OutputPath)$(AssemblyName).exe.config"/>
<XmlMassUpdate ContentFile="$(OutputPath)$(AssemblyName).exe.config" ContentRoot="/configuration" SubstitutionsFile="$(ConsoleConfigSubstitutionsFile)" SubstitutionsRoot="/configuration"/>
<CreateItem Include="$(OutputPath)$(AssemblyName).exe.config">
<Output TaskParameter="Include" ItemName="FileWrites"/>
</CreateItem>
</Target>
<Target Name="GenerateDocs">
<Message Text="Warning: Documentation will not be generated because Sandcaslte and/or the HTML Help Workshop could not be found." Condition="!Exists('$(SandcastleDir)') Or !Exists('$(HtmlHelpWorkshopDir)')" Importance="high"/>
<CallTarget Targets="_GenerateDocs"/>
</Target>
<Target Name="_GenerateDocs" Condition="Exists('$(SandcastleDir)') And Exists('$(HtmlHelpWorkshopDir)') And '$(DocsInputAssemblyPath)' != '' And '$(DocsInputCommentsPath)' != '' And '$(DocsProjectName)' != '' And '$(DocsStagingDir)' != '' And '$(DocsOutputPath)' != ''">
<!-- Staging directories. -->
<PropertyGroup>
<ChmDir>$(DocsStagingDir)\Chm</ChmDir>
<HtmlDir>$(DocsStagingDir)\Html</HtmlDir>
</PropertyGroup>
<!-- Sandcastle executables. -->
<PropertyGroup>
<BuildAssemblerPath>$(SandcastleDir)\ProductionTools\BuildAssembler.exe</BuildAssemblerPath>
<ChmBuilderPath>$(SandcastleDir)\ProductionTools\ChmBuilder.exe</ChmBuilderPath>
<HhcPath>$(HtmlHelpWorkshopDir)\hhc.exe</HhcPath>
<MrefBuilderPath>$(SandcastleDir)\ProductionTools\MrefBuilder.exe</MrefBuilderPath>
<XslTransformPath>$(SandcastleDir)\ProductionTools\XslTransform.exe</XslTransformPath>
</PropertyGroup>
<!-- Sandcastle XSL transforms. -->
<PropertyGroup>
<AddFriendlyFileNamesXslPath>$(SandcastleDir)\ProductionTransforms\AddFriendlyFilenames.xsl</AddFriendlyFileNamesXslPath>
<ApplyVSDocModelXslPath>$(SandcastleDir)\ProductionTransforms\ApplyVSDocModel.xsl</ApplyVSDocModelXslPath>
<CreateVSTocXslPath>$(SandcastleDir)\ProductionTransforms\CreateVSToc.xsl</CreateVSTocXslPath>
<ReflectionToManifestXslPath>$(SandcastleDir)\ProductionTransforms\ReflectionToManifest.xsl</ReflectionToManifestXslPath>
</PropertyGroup>
<!-- Assets the for documentation style we're using. -->
<ItemGroup>
<Icons Include="$(SandcastleDir)\Presentation\vs2005\icons\**\*.*"/>
<Scripts Include="$(SandcastleDir)\Presentation\vs2005\Scripts\**\*.*"/>
<Styles Include="$(SandcastleDir)\Presentation\vs2005\Styles\**\*.*"/>
</ItemGroup>
<!-- Ensure our staging directories and the custom config file we're going to use. -->
<MakeDir Directories="$(DocsStagingDir);$(ChmDir);$(HtmlDir)"/>
<Copy SourceFiles="$(RootDir)\Source\sandcastle.config" DestinationFolder="$(DocsStagingDir)"/>
<!-- Copy the style assets over. -->
<Copy SourceFiles="@(Icons)" DestinationFolder="$(ChmDir)\icons\%(RecursiveDir)"/>
<Copy SourceFiles="@(Scripts)" DestinationFolder="$(ChmDir)\Scripts\%(RecursiveDir)"/>
<Copy SourceFiles="@(Styles)" DestinationFolder="$(ChmDir)\Styles\%(RecursiveDir)"/>
<!-- Copy the XML comments over. -->
<Copy SourceFiles="$(DocsInputCommentsPath)" DestinationFiles="$(DocsStagingDir)\comments.xml"/>
<!-- Run all of the required sandcastle commands. -->
<Exec Command='"$(MrefBuilderPath)" "$(DocsInputAssemblyPath)" /out:mref.xml' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(XslTransformPath)" mref.xml /xsl:"$(ApplyVSDocModelXslPath)" /out:docmodel.xml' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(XslTransformPath)" docmodel.xml /xsl:"$(AddFriendlyFileNamesXslPath)" /out:reflection.xml' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(XslTransformPath)" reflection.xml /xsl:"$(ReflectionToManifestXslPath)" /out:manifest.xml' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(BuildAssemblerPath)" manifest.xml /config:"$(DocsStagingDir)\sandcastle.config"' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(XslTransformPath)" reflection.xml /xsl:"$(CreateVSTocXslPath)" /out:toc.xml' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(ChmBuilderPath)" /project:$(DocsProjectName) /html:"$(HtmlDir)" /lcid:1033 /toc:toc.xml /out:"$(ChmDir)"' WorkingDirectory="$(DocsStagingDir)"/>
<Exec Command='"$(HhcPath)" "$(ChmDir)\$(DocsProjectName).hhp"' WorkingDirectory="$(DocsStagingDir)" ContinueOnError="true"/>
<!-- Copy the final output to the destination. -->
<Copy SourceFiles="$(ChmDir)\$(DocsProjectName).chm" DestinationFiles="$(DocsOutputPath)"/>
<!-- Clean up after ourselves. -->
<ItemGroup>
<CleanupFiles Include="$(DocsStagingDir)\**\*.*"/>
</ItemGroup>
<RemoveDir Directories="$(ChmDir);$(HtmlDir)"/>
<Delete Files="@(CleanupFiles)"/>
</Target>
<Target Name="GetVersion">
<GetVersion AssemblyInfoFile="$(RootDir)\Source\SolutionInfo.cs">
<Output TaskParameter="Major" PropertyName="Major"/>
<Output TaskParameter="Minor" PropertyName="Minor"/>
<Output TaskParameter="Build" PropertyName="Build"/>
<Output TaskParameter="Revision" PropertyName="Revision"/>
</GetVersion>
</Target>
<Target Name="Img">
<MakeDir Directories="$(StaticDir)\Img"/>
<ItemGroup>
<Gifs Include="$(StaticDir)\Src\Img\*.gif"/>
<OldImages Include="$(StaticDir)\Img\*.gif"/>
<OldImages Include="$(StaticDir)\Img\*.png"/>
<Pngs Include="$(StaticDir)\Src\Img\*.png"/>
</ItemGroup>
<Delete Files="@(OldImages)"/>
<Exec Command='"$(RootDir)\Tools\PNGCrush\pngcrush.exe" -q -force "%(Pngs.Identity)" "$(StaticDir)\Img\%(Pngs.Filename)%(Pngs.Extension)"' Condition="'$(CompressAssets)' == 'true'"/>
<Copy SourceFiles="@(Pngs)" DestinationFolder="$(StaticDir)\Img" Condition="'$(CompressAssets)' != 'true'"/>
<Copy SourceFiles="@(Gifs)" DestinationFolder="$(StaticDir)\Img"/>
</Target>
<Target Name="Js" DependsOnTargets="GetVersion">
<MakeDir Directories="$(StaticDir)\Js"/>
<ItemGroup>
<JsTokens Include="Version">
<ReplacementValue>$(Major).$(Minor).$(Build)</ReplacementValue>
</JsTokens>
</ItemGroup>
<TemplateFile Template="$(RootDir)\Source\Copyright.js.template" OutputFilename="$(StaticDir)\Src\Js\copyright.js" Tokens="@(JsTokens)" Condition="'$(ExcludeCopyright)' != 'true'"/>
<Exec Command='"$(RootDir)\Tools\JSPack\JSPack.exe" /map:"$(RootDir)\Source\Js.jspack" /actions:$(CompressAssets)'/>
</Target>
<Target Name="Less" DependsOnTargets="GetVersion">
<MakeDir Directories="$(StaticDir)\Css"/>
<ItemGroup>
<CssTokens Include="Version">
<ReplacementValue>$(Major).$(Minor).$(Build)</ReplacementValue>
</CssTokens>
</ItemGroup>
<Exec Command='recess --compile "$(StaticDir)\Src\Less\collar.less" > "$(StaticDir)\Src\Css\collar.css"' WorkingDirectory="$(StaticDir)\Src\Less" />
<Exec Command='recess --compile "$(StaticDir)\Src\Less\test.less" > "$(StaticDir)\Src\Css\test.css"' WorkingDirectory="$(StaticDir)\Src\Less" />
<TemplateFile Template="$(RootDir)\Source\Copyright.css.template" OutputFilename="$(StaticDir)\Src\Css\copyright.css" Tokens="@(CssTokens)" />
<Exec Command='"$(RootDir)\Tools\JSPack\JSPack.exe" /map:"$(RootDir)\Source\Css.jspack" /actions:$(CompressAssets)'/>
</Target>
<Target Name="LessBootstrap">
<MakeDir Directories="$(StaticDir)\Css"/>
<Exec Command='recess --compile "$(BootstrapDir)\less\bootstrap.less" > "$(StaticDir)\Src\Css\bootstrap.css"' WorkingDirectory="$(BootstrapDir)\less" />
<Exec Command='recess --compile "$(BootstrapDir)\less\responsive.less" > "$(StaticDir)\Src\Css\bootstrap-responsive.css"' WorkingDirectory="$(BootstrapDir)\less" />
<ItemGroup>
<BootstrapCssFiles Include="$(StaticDir)\Src\Css\bootstrap.css"/>
<BootstrapCssFiles Include="$(StaticDir)\Src\Css\bootstrap-responsive.css"/>
</ItemGroup>
<Copy SourceFiles="@(BootstrapCssFiles)" DestinationFolder="$(ExamplesDir)\Mvc\BlueCollar.Examples.Mvc\assets\css"/>
<Copy SourceFiles="@(BootstrapCssFiles)" DestinationFolder="$(ExamplesDir)\Webpages\BlueCollar.Examples.Webpages\assets\css"/>
</Target>
<Target Name="MergeConsole" Condition="'$(MergedConsoleOutputPath)' != ''">
<Exec Command='"$(RootDir)\Tools\ILRepack\ILRepack.exe" /log /internalize /ndebug $(KeyFileArgs) /lib:$(OutputPath) /out:"$(MergedConsoleOutputPath)\Collar.exe" $(OutputPath)Collar.exe $(OutputPath)NDesk.Options.dll'/>
<Copy SourceFiles="$(OutputPath)NLog.config" DestinationFolder="$(MergedConsoleOutputPath)"/>
</Target>
<Target Name="MergeLibrary" Condition="'$(MergedLibraryOutputPath)' != ''">
<Exec Command='"$(RootDir)\Tools\ILRepack\ILRepack.exe" /log /internalize /xmldocs $(KeyFileArgs) /lib:$(OutputPath) /out:"$(MergedLibraryOutputPath)\BlueCollar.dll" $(OutputPath)BlueCollar.dll $(OutputPath)Dapper.dll $(OutputPath)Newtonsoft.Json.dll $(OutputPath)NLog.dll'/>
</Target>
<Target Name="MergeService" Condition="'$(MergedServiceOutputPath)' != ''">
<Exec Command='"$(RootDir)\Tools\ILRepack\ILRepack.exe" /log /internalize $(KeyFileArgs) /lib:$(OutputPath) /out:"$(MergedServiceOutputPath)\CollarService.exe" $(OutputPath)CollarService.exe $(OutputPath)NLog.dll'/>
<Copy SourceFiles="App.config" DestinationFiles="$(MergedServiceOutputPath)\$(AssemblyName).exe.config"/>
<Copy SourceFiles="$(OutputPath)NLog.config" DestinationFolder="$(MergedServiceOutputPath)"/>
</Target>
<Target Name="MergeSQLiteRepository" Condition="'$(MergedSQLiteRepositoryOutputPath)' != ''">
<Exec Command='"$(RootDir)\Tools\ILRepack\ILRepack.exe" /log /internalize $(KeyFileArgs) /xmldocs /lib:$(OutputPath) /out:"$(MergedSQLiteRepositoryOutputPath)\BlueCollar.SQLiteRepository.dll" $(OutputPath)BlueCollar.SQLiteRepository.dll $(OutputPath)Dapper.dll'/>
</Target>
<Target Name="SetPackageVersion" DependsOnTargets="GetVersion">
<XmlUpdate
Prefix="n"
Namespace="http://schemas.microsoft.com/wix/2006/wi"
XmlFileName="$(InstallerDir)\BlueCollar.wxs"
XPath="/n:Wix/n:Product/@Name"
Value="Blue Collar $(Major).$(Minor)"/>
<XmlUpdate
Prefix="n"
Namespace="http://schemas.microsoft.com/wix/2006/wi"
XmlFileName="$(InstallerDir)\BlueCollar.wxs"
XPath="/n:Wix/n:Product/@Version"
Value="$(Major).$(Minor).$(Build)"/>
</Target>
<Target Name="Templates">
<ItemGroup>
<TemplateFiles Include="$(RootDir)\Source\BlueCollar.Dashboard\Views\Shared\Templates\*.cshtml"/>
</ItemGroup>
<ReadLinesFromFile File="%(TemplateFiles.Identity)">
<Output TaskParameter="Lines" ItemName="TemplateLines"/>
</ReadLinesFromFile>
<WriteLinesToFile File="$(TemplatesOutputPath)" Lines="@(TemplateLines)" Overwrite="true"/>
</Target>
</Project>