This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.proj
169 lines (137 loc) · 9.76 KB
/
build.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
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Available Targets:
/t:Clean
Removes temporary build outputs.
/t:Build
Builds assemblies.
/t:Package
Builds NuGet packages using the binaries folder contents.
The packages will drop to .\binaries\packages.
/t:UnitTest
Runs unit tests
/t:IntegrationTests
Runs integration tests
/t:RestoreNugetPackages
Restores nuget packages
/t:NugetPack
Creates nuget package
-->
<PropertyGroup>
<ExtensionTasksPath Condition="'$(ExtensionTasksPath)' == ''">$(SolutionDir)\packages\MSBuild.Extension.Pack.1.5.0\tools\net40\</ExtensionTasksPath>
</PropertyGroup>
<PropertyGroup>
<LibraryRoot>$(MSBuildThisFileDirectory)</LibraryRoot>
<OutputPath>$(LibraryRoot)\lib</OutputPath>
<SDKMSBuildTasksSolution>cf-msbuild-tasks.sln</SDKMSBuildTasksSolution>
<PackageOutputDir>$(BinariesFolder)\packages</PackageOutputDir>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<NugetRepo>https://www.nuget.org/api/v2/</NugetRepo>
</PropertyGroup>
<PropertyGroup>
<major>1</major>
<minor>4</minor>
<revision>0</revision>
<build Condition="'$(BUILD_NUMBER)' == ''">0</build>
<build Condition="'$(BUILD_NUMBER)' != ''">$(BUILD_NUMBER)</build>
<commit Condition="'$(GIT_COMMIT)' == ''">?</commit>
<commit Condition="'$(GIT_COMMIT)' != ''">$(GIT_COMMIT)</commit>
<version>$(major).$(minor).$(revision).$(build)</version>
</PropertyGroup>
<PropertyGroup>
<NuGetCommand>"$(LibraryRoot).nuget\nuget.exe"</NuGetCommand>
<VSTestCommand>"$(VS120COMNTOOLS)\..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"</VSTestCommand>
<CoverageCommand>"$(VS120COMNTOOLS)\..\..\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe"</CoverageCommand>
<ExtensionTasksPath>$(LibraryRoot)\packages\MSBuild.Extension.Pack.1.5.0\tools\net40\</ExtensionTasksPath>
<ReportGeneratorCommand>$(LibraryRoot)\packages\ReportGenerator.2.1.4.0\ReportGenerator.exe</ReportGeneratorCommand>
<CoverageXml>$(LibraryRoot)\TestResults\cf-msbuild-tasks.coveragexml</CoverageXml>
<CoverageHtmlDir>$(LibraryRoot)\TestResults\coveragehtml</CoverageHtmlDir>
</PropertyGroup>
<!-- Import msbuild extensions -->
<Import Project="$(ExtensionTasksPath)MSBuild.ExtensionPack.tasks" Condition="exists('$(ExtensionTasksPath)')"/>
<!-- Build target -->
<Target Name="Build" DependsOnTargets="RestoreNugetPackages; Versioning">
<MSBuild Projects="$(SDKMSBuildTasksSolution)"
Properties="Configuration=$(Configuration);Platform=Any CPU;"
Targets="Build" />
</Target>
<!-- Clean target -->
<Target Name="Clean" DependsOnTargets="RestoreNugetPackages">
<MSBuild Projects="$(SDKMSBuildTasksSolution)"
Properties="Configuration=$(Configuration);Platform=Any CPU"
Targets="Clean" />
</Target>
<!-- Target for running unit tests -->
<Target Name="UnitTest">
<ItemGroup>
<TestDlls Include=".\lib\tests\CloudFoundry.Build.Tasks.Test.dll"/>
</ItemGroup>
<Exec Command="$(VSTestCommand) %(TestDlls.Identity) /inIsolation /settings:CodeCoverage.runsettings /logger:trx" ConsoleToMSBuild="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfTestRun" />
</Exec>
<!-- Use the VSTest output to discover the Results & Coverage files respectively -->
<PropertyGroup>
<!-- Unencoded Regex: (?<=(Results file: )).*?(?=\;)|(?<=(Attachments:;)).*?(?=\;) -->
<ResultsFileRegexPattern>(?<=(Results File: )).*.trx</ResultsFileRegexPattern>
<CoverageFileRegexPattern>(?<=(Attachments:;)).*.coverage</CoverageFileRegexPattern>
<SourceResultsFile>$([System.Text.RegularExpressions.Regex]::Match($(OutputOfTestRun), $(ResultsFileRegexPattern)))</SourceResultsFile>
<SourceCoverageFile>$([System.Text.RegularExpressions.Regex]::Match($(OutputOfTestRun), $(CoverageFileRegexPattern)))</SourceCoverageFile>
</PropertyGroup>
<Delete Files="$(CoverageXml)" />
<Message Text="Analysing coverage file $(SourceCoverageFile)"/>
<Exec Command="$(CoverageCommand) analyze /output:"$(CoverageXml)" "$(SourceCoverageFile)"" />
<Message Text="Generating html coverage report"/>
<MakeDir Directories="$(CoverageHtmlDir)"/>
<Exec Command="$(ReportGeneratorCommand) -reports:"$(CoverageXml)" -targetdir:"$(CoverageHtmlDir)"" />
</Target>
<!-- Target for running integration tests-->
<Target Name="IntegrationTest">
<ItemGroup>
<TestDlls Include=".\lib\tests\CloudFoundry.Build.Tasks.IntegrationTests.dll"/>
<ConfigFile Include=".\lib\tests\CloudFoundry.Build.Tasks.IntegrationTests.dll.config"/>
</ItemGroup>
<Warning Text="The CFMSBuildTestsWindowsStack property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsWindowsStack)' == ''" />
<Warning Text="The CFMSBuildTestsLinuxStack property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsLinuxStack)' == ''" />
<Warning Text="The CFMSBuildTestsOrganization property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsOrganization)' == ''" />
<Warning Text="The CFMSBuildTestsSpace property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsSpace)' == ''" />
<Warning Text="The CFMSBuildTestsUser property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsUser)' == ''" />
<Warning Text="The CFMSBuildTestsPassword property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsPassword)' == ''" />
<Warning Text="The CFMSBuildTestsServerUri property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsServerUri)' == ''" />
<Warning Text="The CFMSBuildTestsHost property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsHost)' == ''" />
<Warning Text="The CFMSBuildTestsDomain property not set, value from app.config will be used." Condition="'$(CFMSBuildTestsDomain)' == ''" />
<Message Text="Updating config file at %(ConfigFile.Identity)" />
<XmlPoke Condition="'$(CFMSBuildTestsWindowsStack)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='WindowsStack']/value" Value="$(CFMSBuildTestsWindowsStack)"/>
<XmlPoke Condition="'$(CFMSBuildTestsLinuxStack)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='LinuxStack']/value" Value="$(CFMSBuildTestsLinuxStack)"/>
<XmlPoke Condition="'$(CFMSBuildTestsOrganization)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='Organization']/value" Value="$(CFMSBuildTestsOrganization)"/>
<XmlPoke Condition="'$(CFMSBuildTestsSpace)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='Space']/value" Value="$(CFMSBuildTestsSpace)"/>
<XmlPoke Condition="'$(CFMSBuildTestsServerUri)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='ServerUri']/value" Value="$(CFMSBuildTestsServerUri)"/>
<XmlPoke Condition="'$(CFMSBuildTestsUser)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='User']/value" Value="$(CFMSBuildTestsUser)"/>
<XmlPoke Condition="'$(CFMSBuildTestsPassword)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='Password']/value" Value="$(CFMSBuildTestsPassword)"/>
<XmlPoke Condition="'$(CFMSBuildTestsHost)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='Host']/value" Value="$(CFMSBuildTestsHost)"/>
<XmlPoke Condition="'$(CFMSBuildTestsDomain)' != ''" XmlInputPath="%(ConfigFile.Identity)" Query="/configuration/userSettings/CloudFoundry.Build.Tasks.IntegrationTests.Properties.Settings/setting[@name='Domain']/value" Value="$(CFMSBuildTestsDomain)"/>
<Exec Command="$(VSTestCommand) %(TestDlls.Identity) /inIsolation /settings:CodeCoverage.runsettings /logger:trx" ConsoleToMSBuild="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfTestRun" />
</Exec>
</Target>
<!-- Target for restoring nuget packages -->
<Target Name="RestoreNugetPackages">
<Exec Command="$(NuGetCommand) restore $(SDKMSBuildTasksSolution) -source $(NugetRepo)"/>
</Target>
<!-- Target for creating the nuget package -->
<Target Name="NugetPack">
<Exec Command="$(NuGetCommand) pack "$(LibraryRoot)\lib\package\cf-msbuild-tasks.nuspec" -Prop commit=$(commit);version=$(version) "/>
</Target>
<!-- Target for automatically versioning the assemblies -->
<Target Name="Versioning">
<Message Text="Version: $(version)" />
<ItemGroup>
<AssemblyInfoFiles Include="$(LibraryRoot)\src\CloudFoundry.Build.Tasks\Properties\AssemblyInfo.cs"/>
</ItemGroup>
<MSBuild.ExtensionPack.Framework.AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
AssemblyVersion="$(version)"
AssemblyFileVersion="$(version)" />
</Target>
</Project>