-
Notifications
You must be signed in to change notification settings - Fork 34
/
ciBuild.proj
167 lines (144 loc) · 11.8 KB
/
ciBuild.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
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Remember to run msbuild ciBuild.csproj /t:Restore first so the MSBuild extension package is installed from nuget -->
<Import Project="packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets" Condition="Exists('packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets')"/>
<PropertyGroup>
<!-- Input parameters -->
<BuildConfiguration>Release</BuildConfiguration>
<ProjectDirectory>$(MSBuildProjectDirectory)</ProjectDirectory>
<!-- Version -->
<Version Condition="'$(VERSION)' == ''">0.0.0.0</Version>
<Version Condition="'$(VERSION)' != ''">$(VERSION)</Version>
<VersionMajor>$(Version.Split('.')[0])</VersionMajor>
<VersionMinor>$(Version.Split('.')[1])</VersionMinor>
<VersionPatch>$(Version.Split('.')[2])</VersionPatch>
<VersionBuild>$(Version.Split('.')[3])</VersionBuild>
<PackageVersion>$(VersionMajor).$(VersionMinor).$(VersionPatch)</PackageVersion>
<!--Tools-->
<NuGet>"$(ProjectDirectory)\_tools\NuGet.exe"</NuGet>
<NuGetPackageDirectory>$(ProjectDirectory)\_NuGet</NuGetPackageDirectory>
<DxaFrameworkPackageDirectory>$(NuGetPackageDirectory)\Sdl.Dxa.Framework</DxaFrameworkPackageDirectory>
<MsTestExe Condition="'$(MsTestExe)'=='' And Exists('$(MSBuildProgramFiles32)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe')">$(MSBuildProgramFiles32)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe</MsTestExe>
<MsTestExe Condition="'$(MsTestExe)'=='' And Exists('$(MSBuildProgramFiles32)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe')">$(MSBuildProgramFiles32)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe</MsTestExe>
<MsTestExe Condition="'$(MsTestExe)'=='' And Exists('$(MSBuildProgramFiles32)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\MSTest.exe')">$(MSBuildProgramFiles32)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\MSTest.exe</MsTestExe>
<MsTestExe Condition="'$(MsTestExe)'=='' And Exists('$(MSBuildProgramFiles32)\Microsoft Visual Studio\2017\Professional\Common7\IDE\MSTest.exe')">$(MSBuildProgramFiles32)\Microsoft Visual Studio\2017\Professional\Common7\IDE\MSTest.exe</MsTestExe>
</PropertyGroup>
<!-- ======================================================================================================================= -->
<!-- You should run msbuild with this target first to make sure all packages are installed before building everything else -->
<!-- ======================================================================================================================= -->
<Target Name="Restore">
<Message Text="Clearing NuGet cache..."/>
<Exec Command="$(NuGet) locals all -Clear" />
<Message Text="Restoring NuGet packages..."/>
<Exec Command="_tools\RestorePackages DxaFramework.sln" WorkingDirectory="$(ProjectDirectory)" />
</Target>
<!-- ================================================================================== -->
<Target Name="Build">
<Message Importance="high" Text="Start build..."/>
<CallTarget Targets="PrepareBuild"/>
<CallTarget Targets="RunBuild"/>
<CallTarget Targets="CreatePackages"/>
</Target>
<!-- ============================================================================================================================================= -->
<Target Name="PrepareBuild">
<Message Text="Preparing build..." Importance="high" />
<Message Text="Setting Assembly Info"/>
<ItemGroup>
<AssemblyInfoFile Include="$(ProjectDirectory)\CommonAssemblyInfo.cs">
<Attributes>Normal</Attributes>
</AssemblyInfoFile>
</ItemGroup>
<Message Text="Setting Assembly Info @(AssemblyInfoFile)"/>
<MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="yyyy">
<Output TaskParameter="Result" PropertyName="Year"/>
</MSBuild.ExtensionPack.Framework.DateAndTime>
<MSBuild.ExtensionPack.FileSystem.File TaskAction="SetAttributes" Files="@(AssemblyInfoFile)"/>
<MSBuild.ExtensionPack.Framework.AssemblyInfo
AssemblyInfoFiles="@(AssemblyInfoFile)"
AssemblyVersion="$(Version)"
AssemblyFileVersion="$(VersionMajor).$(VersionMinor).$(VersionPatch).$(VersionBuild)"
AssemblyCopyright="Copyright © 2014-$(Year) RWS Group"
SkipVersioning="false"
/>
<Message Text="Restoring NuGet packages for extensions..."/>
<Exec Command="_tools\RestorePackages DxaFramework.sln" WorkingDirectory="$(ProjectDirectory)" />
</Target>
<!-- ================================================================================== -->
<Target Name="RunBuild">
<Message Importance="high" Text="Running build commands..."/>
<MSBuild Projects="$(ProjectDirectory)\Sdl.Web.Tridion\Sdl.Web.Tridion.csproj" Properties="Configuration=$(BuildConfiguration);Platform=AnyCPU" StopOnFirstFailure="true"/>
<MSBuild Projects="$(ProjectDirectory)\Site\Sdl.Web.Site.csproj" Properties="Configuration=$(BuildConfiguration);Platform=AnyCPU" StopOnFirstFailure="true"/>
<MSBuild Projects="$(ProjectDirectory)\DD4T\DD4T.Providers.DxaModelService\DD4T.Providers.DxaModelService.csproj" Properties="Configuration=$(BuildConfiguration);Platform=AnyCPU" StopOnFirstFailure="true"/>
<!-- Uncomment to enable tests
<MSBuild Projects="$(ProjectDirectory)\Sdl.Web.Tridion.Tests\Sdl.Web.Tridion.Tests.csproj" Properties="Configuration=$(BuildConfiguration);Platform=AnyCPU" StopOnFirstFailure="true"/>
-->
</Target>
<!-- ================================================================================== -->
<Target Name="CreatePackages">
<Message Importance="high" Text="Creating NuGet packages in '$(NuGetPackageDirectory)' ..."/>
<Message Text="Package Version: $(PackageVersion)"/>
<!--Versionize the path to DXA Framework libs in the {package_id}.targets files -->
<XmlPoke Namespaces="<Namespace Prefix='msb' Uri='http://schemas.microsoft.com/developer/msbuild/2003' />" Query="//msb:DxaFrameworkLibs/@Include" Value="..\packages\Sdl.Dxa.Framework.Web8.$(PackageVersion)\lib\net48\*.*" XmlInputPath="$(DxaFrameworkPackageDirectory)\Sdl.Dxa.Framework.Web8.targets"/>
<!-- Create nuget package for Dxa framework -->
<Exec Command="$(NuGet) pack Sdl.Dxa.Framework.Web8.nuspec -Version $(PackageVersion)" WorkingDirectory="$(DxaFrameworkPackageDirectory)"/>
<!-- Create nuget package for DD4T DxaModelService provider -->
<Exec Command="$(NuGet) pack DD4T.Providers.DxaModelService.nuspec -Version $(PackageVersion)" WorkingDirectory="$(NuGetPackageDirectory)"/>
<!-- Create symbols nuget package. Note the use of .symbols in the filename! -->
<Exec Command="$(NuGet) pack Sdl.Dxa.Framework.Web8.symbols.nuspec -Symbols -Version $(PackageVersion)" WorkingDirectory="$(DxaFrameworkPackageDirectory)"/>
</Target>
<!-- ================================================================================== -->
<Target Name="PublishPackages" Condition="'$(NuGetRepositoryUrl)' != ''">
<Message Importance="high" Text="Publishing NuGet packages to '$(NuGetRepositoryUrl)' ..."/>
<!-- Publish Dxa framework package -->
<Exec Command="$(NuGet) push Sdl.Dxa.Framework.Web8.$(PackageVersion).nupkg -Source $(NuGetRepositoryUrl)" WorkingDirectory="$(DxaFrameworkPackageDirectory)"/>
<!-- Publish DD4T Dxa Model Service provider -->
<Exec Command="$(NuGet) push DD4T.Providers.DxaModelService.$(PackageVersion).nupkg -Source $(NuGetRepositoryUrl)" WorkingDirectory="$(NuGetPackageDirectory)"/>
<!-- Publish symbols package. Will automatically use symbolsource.org as the target repository since .symbols
is used in the nupkg filename. We could send this to a local symbol server but currently there are non
available. -->
<Exec Command="$(NuGet) push Sdl.Dxa.Framework.Web8.$(PackageVersion).symbols.nupkg -Source $(NugetSymbolServerUrl)" Condition="'$(PublishSymbols)' == 'true' AND '$(NugetSymbolServerUrl)' != ''" WorkingDirectory="$(DxaFrameworkPackageDirectory)"/>
</Target>
<!-- ================================================================================== -->
<!-- Sandcastle Help File Builder (SHFB)
Notes:
1) Install sandcastle from: https://github.com/EWSoftware/SHFB/releases
2) Setup environment variables:
set DXROOT=c:\<install location>\Sandcastle
set SHFBROOT=c:\<install location>\Sandcastle Help File Builder
set LANGUAGE="%SHFBROOT%\SandcastleBuilderGUI.exe"
-->
<Target Name="CreateDocs">
<Message Importance="high" Text="Creating API documentation..."/>
<MSBuild Projects="$(ProjectDirectory)\Sdl.Web.Documentation\Sdl.Web.Documentation.shfbproj" Properties="Configuration=$(BuildConfiguration);Platform=AnyCPU;Version=$(PackageVersion)" StopOnFirstFailure="true"/>
</Target>
<!-- ================================================================================== -->
<Target Condition="'$(BuildConfiguration)' == 'Release'" Name="Test">
<Message Text="Running unit tests..."/>
<Exec Command="packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user "-target:$(MsTestExe)" "-targetargs:/testcontainer:Sdl.Web.Tridion.Tests\bin\$(BuildConfiguration)\Sdl.Web.Tridion.Tests.dll /resultsfile:TestResults.trx" "-filter:+[Sdl.*]* -[*Test*]*" -output:CoverageReports\Coverage.xml""/>
<Exec Command="packages\ReportGenerator.2.4.4.0\tools\ReportGenerator.exe "-reports:CoverageReports\Coverage.xml" "-targetdir:CoverageReports""/>
</Target>
<!-- ============================================================================================================================================= -->
<PropertyGroup>
<DstFolder>$(ProjectDirectory)\dist</DstFolder>
</PropertyGroup>
<Target Name="Artifacts">
<Message Text="Generating artifacts ..." Importance="high" />
<ItemGroup>
<ConfigFiles Include="$(ProjectDirectory)\Site\*.config;$(ProjectDirectory)\Site\Global.asax" Exclude="$(ProjectDirectory)\Site\packages.config"/>
<ViewFiles Include="$(ProjectDirectory)\Site\Views\**\*"/>
<AreaFiles Include="$(ProjectDirectory)\Site\Areas\**\*"/>
<BinFiles Include="$(ProjectDirectory)\Site\bin\*"/>
<InstallationFiles Include="$(ProjectDirectory)\installation\**\*"/>
<SrcFilesA Include="$(ProjectDirectory)\CommonAssemblyInfo.cs;$(ProjectDirectory)\DxaWebApp.sln;"/>
<SrcFilesB Include="$(ProjectDirectory)\Site\**\*" Exclude="$(ProjectDirectory)\Site\bin\**\*;$(ProjectDirectory)\Site\obj\**\*" />
</ItemGroup>
<RemoveDir Directories="$(DstFolder)" />
<Copy DestinationFolder="$(DstFolder)\web\dist" SourceFiles="@(ConfigFiles)"/>
<Copy DestinationFolder="$(DstFolder)\web\dist\Views\%(RecursiveDir)" SourceFiles="@(ViewFiles)"/>
<Copy DestinationFolder="$(DstFolder)\web\dist\Areas\%(RecursiveDir)" SourceFiles="@(AreaFiles)"/>
<Copy DestinationFolder="$(DstFolder)\web\dist\bin\%(RecursiveDir)" SourceFiles="@(BinFiles)"/>
<Copy DestinationFolder="$(DstFolder)\web\%(RecursiveDir)" SourceFiles="@(InstallationFiles)"/>
<Copy DestinationFolder="$(DstFolder)\web\src\%(RecursiveDir)" SourceFiles="@(SrcFilesA)"/>
<Copy DestinationFolder="$(DstFolder)\web\src\Site\%(RecursiveDir)" SourceFiles="@(SrcFilesB)"/>
</Target>
</Project>