forked from FakeItEasy/FakeItEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFakeItEasy.build
186 lines (165 loc) · 9.17 KB
/
FakeItEasy.build
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
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Based on script from http://autofac.org" -->
<Import Project="Libraries\Build\MSBuild.Community.Tasks.targets" />
<PropertyGroup>
<!--
Primary configuration properties (override them via command line
if needed
-->
<BuildPath Condition="$(BuildPath)==''">Build</BuildPath>
<Configuration Condition="$(Configuration)==''">Release</Configuration>
<BuildFramework></BuildFramework>
<AllowPartiallyTrustedCallers Condition="$(AllowPartiallyTrustedCallers)==''">true</AllowPartiallyTrustedCallers>
<FxCopCmdPath Condition="$(FxCopCmdPath)==''">C:\Program Files (x86)\Microsoft FxCop 1.36\FxCopCmd.exe</FxCopCmdPath>
<SnCmdPath Condition="$(SnCmdPath)==''">C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\sn.exe</SnCmdPath>
<ILMergeCmdPath Condition="$(ILMergeCmdPath)==''">C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe</ILMergeCmdPath>
<SilverlightFrameworkDirectory Condition="'$(SilverlightFrameworkDirectory)' == ''">C:\Program Files (x86)\Microsoft Silverlight\4.0.60531.0</SilverlightFrameworkDirectory>
<FrameworkDirectory Condition="'$(FrameworkDirectory)' == ''">C:\Windows\Microsoft.NET\Framework\v4.0.30319</FrameworkDirectory>
<!--
Derived configuration properties
-->
<ArchiveDirectory Condition="$(ArchiveDirectory)==''">$(BuildPath)</ArchiveDirectory>
<NuPackPackageDirectory Condition="$(NuPackPackageDirectory)==''">$(BuildPath)\Package</NuPackPackageDirectory>
<BinariesPath>$(BuildPath)\Binaries</BinariesPath>
<LicensePath>$(BuildPath)\License</LicensePath>
<BinariesSource>Source\FakeItEasy\bin\$(Configuration)</BinariesSource>
<BinariesSource35>Source\FakeItEasy.Net35\bin\$(Configuration)</BinariesSource35>
<BinariesSourceSilverlight>Source\FakeItEasy-SL\Bin\$(Configuration)</BinariesSourceSilverlight>
<BinariesSourceSilverlight3>Source\FakeItEasy-SL3\Bin\$(Configuration)</BinariesSourceSilverlight3>
<ProjectName>$(MSBuildProjectName)</ProjectName>
</PropertyGroup>
<PropertyGroup>
<FxCop_CriticalErrors>0</FxCop_CriticalErrors>
<FxCop_Errors>0</FxCop_Errors>
<FxCop_CriticalWarnings>0</FxCop_CriticalWarnings>
<FxCop_Warnings>0</FxCop_Warnings>
<FxCop_TotalErrors>0</FxCop_TotalErrors>
<FxCopOutput>$(BuildPath)\Artifacts\FxCop.xml</FxCopOutput>
</PropertyGroup>
<!--
Solution redirects. Every VS project normally knows how to support these targets
-->
<Target Name="Build">
<MSBuild Projects="Source\$(ProjectName).sln" Targets="Build" Properties="Configuration=$(Configuration)$(BuildFramework);BuildConstants=$(BuildConstants);MSBuildTargets=$(BuildTargets)"/>
</Target>
<Target Name="Clean">
<MSBuild Projects="Source\$(ProjectName).sln" Targets="Clean" Properties="Configuration=$(Configuration)$(BuildFramework);BuildConstants=$(BuildConstants);MSBuildTargets=$(BuildTargets)" />
<CreateItem Include="**/Debug/**/*.*;**/Release/**/*.*">
<Output ItemName="_binaryFiles" TaskParameter="Include"/>
</CreateItem>
<Delete Files="@(_binaryFiles)" TreatErrorsAsWarnings="true"/>
<RemoveDir Directories="$(BuildPath)" />
</Target>
<Target Name="Rebuild" DependsOnTargets="UpdateVersion;Clean;Build;" />
<Target Name="CreateVersionNumber" Condition="$(VersionNumber)==''">
<Version VersionFile=".\Resources\Build\VersionNumber.txt" BuildType="Automatic" RevisionType="Increment" >
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
<CreateProperty Value="$(Major).$(Minor).$(Build).$(Revision)">
<Output TaskParameter="Value" PropertyName="VersionNumber" />
</CreateProperty>
</Target>
<Target Name="UpdateVersion" DependsOnTargets="CreateVersionNumber">
<CreateItem Include="**\SharedAssemblyInfo.cs">
<Output ItemName="UpdateVersionPaths" TaskParameter="Include"/>
</CreateItem>
<CreateItem Include="@(UpdateVersionPaths->'%(SubFolder)%(RecursiveDir)VersionAssemblyInfo.cs')">
<Output ItemName="UpdateVersionFiles" TaskParameter="Include"/>
</CreateItem>
<Time Format="u">
<Output TaskParameter="FormattedTime" PropertyName="BuildTime" />
</Time>
<AssemblyInfo OutputFile="%(UpdateVersionFiles.FullPath)" CodeLanguage="CS"
AssemblyVersion="$(VersionNumber)"
AssemblyFileVersion="$(VersionNumber)"
AssemblyConfiguration="$(Configuration) built on $(BuildTime)"
/>
</Target>
<Target Name="WipeResources">
<!--Wipe old version files-->
<CreateItem Include="**\VersionAssemblyInfo.cs">
<Output ItemName="UpdateVersionPaths" TaskParameter="Include"/>
</CreateItem>
<Delete Files="@(UpdateVersionPaths)" />
</Target>
<Target Name="BuildDebug">
<MSBuild Projects="Source\$(ProjectName).sln" Targets="Build" Properties="Configuration=Debug$(BuildFramework);BuildConstants=$(BuildConstants);MSBuildTargets=$(BuildTargets)"/>
</Target>
<Target Name="CodeAnalysis" DependsOnTargets="BuildDebug">
<MakeDir Directories="$(BuildPath)\Artifacts" />
<Exec
Command=""$(FxCopCmdPath)" /searchgac /file:Source\FakeItEasy\bin\Debug\FakeItEasy.dll /out:$(FxCopOutput)"
ContinueOnError="True" />
<XmlRead ContinueOnError="True"
XmlFileName="$(FxCopOutput)"
XPath="string(count(//Issue[@Level='CriticalError']))">
<Output TaskParameter="Value" PropertyName="FxCop_CriticalErrors" />
</XmlRead>
<XmlRead ContinueOnError="True"
XmlFileName="$(FxCopOutput)"
XPath="string(count(//Issue[@Level='Error']))">
<Output TaskParameter="Value" PropertyName="FxCop_Errors" />
</XmlRead>
<XmlRead ContinueOnError="True"
XmlFileName="$(FxCopOutput)"
XPath="string(count(//Issue[@Level='CriticalWarning']))">
<Output TaskParameter="Value" PropertyName="FxCop_CriticalWarnings" />
</XmlRead>
<XmlRead ContinueOnError="True"
XmlFileName="$(FxCopOutput)"
XPath="string(count(//Issue[@Level='Warning']))">
<Output TaskParameter="Value" PropertyName="FxCop_Warnings" />
</XmlRead>
<XmlRead ContinueOnError="True"
XmlFileName="$(FxCopOutput)"
XPath="string(count(//Issue))">
<Output TaskParameter="Value" PropertyName="FxCop_TotalErrors" />
</XmlRead>
<Warning Text="FxCop encountered $(FxCop_TotalErrors) rule violations"
Condition="$(FxCop_TotalErrors) > 0" />
<Error Text="FxCop encountered $(FxCop_TotalErrors) rule violations"
Condition="$(FxCop_TotalErrors) > 0" />
</Target>
<Target Name="Package" DependsOnTargets="Clean;Rebuild">
<MakeDir Directories="$(NuPackPackageDirectory)\$(VersionNumber)\lib" />
<MakeDir Directories="$(NuPackPackageDirectory)\$(VersionNumber)\lib\NET40" />
<MakeDir Directories="$(NuPackPackageDirectory)\$(VersionNumber)\lib\NET35" />
<MakeDir Directories="$(NuPackPackageDirectory)\$(VersionNumber)\lib\SL4" />
<MakeDir Directories="$(NuPackPackageDirectory)\$(VersionNumber)\lib\SL3" />
<CreateItem Include="$(BinariesSource)\FakeItEasy.*;">
<Output ItemName="fakeItEasyLibFiles" TaskParameter="Include"/>
</CreateItem>
<CreateItem Include="$(BinariesSource35)\FakeItEasy.*;">
<Output ItemName="fakeItEasyLibFiles35" TaskParameter="Include"/>
</CreateItem>
<CreateItem Include="$(BinariesSourceSilverlight)\FakeItEasy.*;">
<Output ItemName="fakeItEasyLibFiles-SL" TaskParameter="Include"/>
</CreateItem>
<CreateItem Include="$(BinariesSourceSilverlight3)\FakeItEasy.*;">
<Output ItemName="fakeItEasyLibFiles-SL3" TaskParameter="Include"/>
</CreateItem>
<Copy SourceFiles="@(fakeItEasyLibFiles)" DestinationFolder="$(NuPackPackageDirectory)\$(VersionNumber)\lib\NET40" />
<Copy SourceFiles="@(fakeItEasyLibFiles35)" DestinationFolder="$(NuPackPackageDirectory)\$(VersionNumber)\lib\NET35" />
<Copy SourceFiles="@(fakeItEasyLibFiles-SL)" DestinationFolder="$(NuPackPackageDirectory)\$(VersionNumber)\lib\SL4" />
<Copy SourceFiles="@(fakeItEasyLibFiles-SL3)" DestinationFolder="$(NuPackPackageDirectory)\$(VersionNumber)\lib\SL3" />
<Copy SourceFiles=".\Resources\Build\FakeItEasy.nuspec" DestinationFolder="$(NuPackPackageDirectory)\$(VersionNumber)" />
<!-- Update version number in NuPack file -->
<XmlUpdate XmlFileName="$(NuPackPackageDirectory)\$(VersionNumber)\FakeItEasy.nuspec" Xpath="/package/metadata/version" Value="$(VersionNumber)" />
<!-- Create package file -->
<Exec
Command=".\Source\.nuget\NuGet.exe pack $(NuPackPackageDirectory)\$(VersionNumber)\FakeItEasy.nuspec /o .\Build\Package\"
ContinueOnError="False" />
</Target>
<Target Name="Distrib" DependsOnTargets="Clean;CodeAnalysis;ReBuild;Merge;Merge-SL;Package">
<MakeDir Directories="$(ArchiveDirectory)" />
<!-- Archive-->
<CreateItem Include="$(BinariesPath)\Merged\*.*;$(BinariesPath)\Merged-SL\*.*;;$(LicensePath)\*.*">
<Output ItemName="archiveFiles" TaskParameter="Include" />
</CreateItem>
<Zip Files="@(archiveFiles)" ZipFileName="$(ArchiveDirectory)\$(ProjectName)-$(VersionNumber).zip" Flatten="true" WorkingDirectory="$(BuildPath)" />
</Target>
</Project>