forked from xunit/xunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xunit.msbuild
205 lines (177 loc) · 8.92 KB
/
xunit.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
<Project DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<UsingTask
AssemblyFile="packages\xunit.buildtasks\tools\CodePlex.MSBuildTasks.dll"
TaskName="CodePlex.MSBuildTasks.RegexReplace"/>
<UsingTask
AssemblyFile="packages\xunit.buildtasks\tools\CodePlex.MSBuildTasks.dll"
TaskName="CodePlex.MSBuildTasks.Zip"/>
<!-- Settings -->
<PropertyGroup>
<SolutionName Condition="'$(SolutionName)' == ''">xunit.sln</SolutionName>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<ParallelizeTests Condition="'$(ParallelizeTests)' == ''">true</ParallelizeTests>
<MaxParallelThreads Condition="'$(MaxParallelThreads)' == ''">0</MaxParallelThreads>
<TrackFileAccess>false</TrackFileAccess>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)</SolutionDir>
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(SolutionDir)\.nuget\nuget.exe</NuGetExePath>
<RequestedVerbosity Condition=" '$(RequestedVerbosity)' == '' ">normal</RequestedVerbosity>
</PropertyGroup>
<ItemGroup>
<NuspecFiles Include="**\*.nuspec" />
<NuGetNuspecTargets Include="src\xunit.assert.nuspec;src\xunit.core.nuspec;src\xunit.execution.nuspec;src\xunit.runner.utility.nuspec;src\xunit.runner.utility.visualstudio.win8.nuspec" />
<NuGetNuspecNoSymbolsTargets Include="src\*.nuspec" Exclude="@(NuGetNuspecTargets)" />
</ItemGroup>
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="http://www.myget.org/F/b4ff5f68eccf4f6bbfed74f055f88d8f/" />
</ItemGroup>
<!-- Cascading attempts to find a build number -->
<PropertyGroup Condition="'$(BuildNumber)' == ''">
<BuildNumber>$(BUILD_NUMBER)</BuildNumber>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildNumber)' == ''">
<BuildNumber>0</BuildNumber>
</PropertyGroup>
<!-- Build server targets -->
<Target Name="TeamCity" DependsOnTargets="DisableParallelization;Clean;PackageRestore;SetVersionNumber;Test;Packages;ZipArtifacts;PushMyGet" />
<!-- Individiual targets -->
<Target Name="DisableParallelization">
<PropertyGroup>
<ParallelizeTests>false</ParallelizeTests>
</PropertyGroup>
</Target>
<Target Name="Clean">
<ItemGroup>
<CleanFileList Include="*.html;*.xml;*.nupkg;.nuget\NuGet.exe"/>
<CleanFolderList Include="xunit.console\bin\$(Configuration).x86"/>
</ItemGroup>
<MSBuild
Projects="$(SolutionName)"
Targets="Clean"
Properties="Configuration=$(Configuration);TrackFileAccess=$(TrackFileAccess)"/>
<Delete Files="@(CleanFileList)"/>
<RemoveDir Directories="@(CleanFolderList)" ContinueOnError="true"/>
</Target>
<Target Name="PackageRestore" DependsOnTargets="_DownloadNuGet">
<Message Text="Restoring NuGet packages..." Importance="High" />
<Exec Command=""$(NuGetExePath)" install xunit.buildtasks -Source @(PackageSource) -SolutionDir "$(SolutionDir)" -Verbosity quiet -ExcludeVersion" Condition="!Exists('$(SolutionDir)\packages\xunit.buildtasks\')" />
<Exec Command=""$(NuGetExePath)" restore "$(SolutionDir)\$(SolutionName)" -NonInteractive -Source @(PackageSource) -Verbosity quiet" />
</Target>
<Target Name="Build" DependsOnTargets="PackageRestore">
<MSBuild
Projects="$(SolutionName)"
Targets="Build"
Properties="Configuration=$(Configuration);TrackFileAccess=$(TrackFileAccess)"/>
<!-- Build xunit.console.x86 -->
<Copy
SourceFiles="src\xunit.console\xunit.console.csproj"
DestinationFiles="src\xunit.console\xunit.console.x86.csproj"/>
<RegexReplace
Pattern="<AssemblyName>xunit\.console</AssemblyName>"
Replacement="<AssemblyName>xunit.console.x86</AssemblyName>"
Files="src\xunit.console\xunit.console.x86.csproj"/>
<RegexReplace
Pattern="<OutputPath>bin\\(\w+)\\</OutputPath>"
Replacement="<OutputPath>bin\$1.x86\</OutputPath>"
Files="src\xunit.console\xunit.console.x86.csproj"/>
<MSBuild
Projects="src\xunit.console\xunit.console.x86.csproj"
Targets="Build"
Properties="PlatformTarget=x86;Configuration=$(Configuration);TrackFileAccess=$(TrackFileAccess)"/>
<RegexReplace
Pattern="type="Xunit.ConsoleClient.XunitConsoleConfigurationSection, xunit.console""
Replacement="type="Xunit.ConsoleClient.XunitConsoleConfigurationSection, xunit.console.x86""
Files="src\xunit.console\bin\$(Configuration).x86\xunit.console.x86.exe.config" />
<Delete
Files="src\xunit.console\xunit.console.x86.csproj" />
</Target>
<Target Name="_Test32" DependsOnTargets="Build">
<MSBuild
Projects="tools\xunit.tests.msbuild"
Properties="Configuration=$(Configuration);ParallelizeTests=$(ParallelizeTests);MaxParallelThreads=$(MaxParallelThreads)" />
</Target>
<Target Name="_Test64" DependsOnTargets="Build">
<Exec
Condition="'$(PROCESSOR_ARCHITEW6432)' != ''"
Command="$(SystemRoot)\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe tools\xunit.tests.msbuild /nologo /p:Configuration=$(Configuration);ParallelizeTests=$(ParallelizeTests);MaxParallelThreads=$(MaxParallelThreads) /v:$(RequestedVerbosity)" />
</Target>
<Target Name="Test" DependsOnTargets="Build;_Test32;_Test64" />
<Target Name="Help" DependsOnTargets="Build">
<Exec Command='"C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\SandcastleBuilderConsole.exe" help\xunit.shfb' />
</Target>
<Target Name="SetVersionNumber">
<RegexReplace
Pattern='AssemblyVersion\("(\d+\.\d+\.\d+)\.\d+"\)'
Replacement='AssemblyVersion("$1.$(BuildNumber)")'
Files='src\common\GlobalAssemblyInfo.cs'/>
<RegexReplace
Pattern='<version>(\d+\.\d+\.\d+(-[A-Za-z0-9-]+)?)<'
Replacement='<version>$1-build$(BuildNumber)<'
Files='@(NuspecFiles)'/>
<RegexReplace
Pattern='version="\[(\d+\.\d+\.\d+(-[A-Za-z0-9-]+)?)\]"'
Replacement='version="[$1-build$(BuildNumber)]"'
Files='@(NuspecFiles)'/>
</Target>
<Target Name='Packages'>
<Exec Command='.nuget\NuGet.exe pack %(NuGetNuspecTargets.Identity) -Symbols -NoPackageAnalysis -NonInteractive -Verbosity quiet' />
<Exec Command='.nuget\NuGet.exe pack %(NuGetNuspecNoSymbolsTargets.Identity) -NoPackageAnalysis -NonInteractive -Verbosity quiet' />
</Target>
<Target Name='ZipArtifacts'>
<ItemGroup>
<TestResults Include="TestResults*.*" />
<Binaries Include="*.nupkg" />
<Binaries Include="src/xunit.runner.visualstudio.settings/bin/Release/*.vsix" />
</ItemGroup>
<Delete Files="test-results.zip" />
<Zip Files="@(TestResults)" ZipFileName="test-results.zip" />
<Delete Files="binaries.zip" />
<Zip Files="@(Binaries)" ZipFileName="binaries.zip" StripPath="true" />
</Target>
<Target Name="PushMyGet">
<ItemGroup>
<NupkgSymbolsFiles Include="*.symbols.nupkg" />
<NupkgFiles Include="*.nupkg" Exclude="@(NupkgSymbolsFiles)" />
</ItemGroup>
<Exec Command=".nuget\NuGet.exe push %(NupkgFiles.Identity) -NonInteractive -Source https://www.myget.org/F/xunit/api/v2/package" />
<Exec Command=".nuget\NuGet.exe push %(NupkgSymbolsFiles.Identity) -NonInteractive -Source https://nuget.symbolsource.org/MyGet/xunit" />
</Target>
<Target Name="PushNuGet">
<ItemGroup>
<NupkgFiles Include="*.nupkg" Exclude="*.symbols*.nupkg" />
</ItemGroup>
<Exec Command=".nuget\NuGet.exe push %(NupkgFiles.Identity) -NonInteractive" />
</Target>
<Target Name="_DownloadNuGet">
<MakeDir Directories="$(SolutionDir)\.nuget" />
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="!Exists('$(NuGetExePath)')" />
</Target>
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>