-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
167 lines (152 loc) · 6.99 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
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-Present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
-->
<Project ToolsVersion="4.0" DefaultTargets="Build;Test;Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Major>5</Major>
<Minor>2</Minor>
<Build>13</Build>
<Revision>0</Revision>
<DevNuGetServer>http://reactjs.net/packages/</DevNuGetServer>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\tools\MSBuildTasks</MSBuildCommunityTasksPath>
<PackageOutputDir>$(MSBuildProjectDirectory)\output</PackageOutputDir>
<BuildType Condition="'$(BuildType)' == ''">Dev</BuildType>
<SolutionFile>src\React.sln</SolutionFile>
</PropertyGroup>
<ItemGroup>
<PackageAssemblies Include="Cassette.React" />
<PackageAssemblies Include="React.AspNet" />
<PackageAssemblies Include="React.AspNet.Middleware" />
<PackageAssemblies Include="React.Core" />
<PackageAssemblies Include="React.MSBuild" />
<PackageAssemblies Include="React.Owin" />
<PackageAssemblies Include="React.Router" />
<PackageAssemblies Include="React.Router.Mvc4" />
<PackageAssemblies Include="React.Web" />
<PackageAssemblies Include="React.Web.Mvc4" />
<PackageAssemblies Include="React.Template" />
<PackageAssemblies Include="System.Web.Optimization.React" />
</ItemGroup>
<Import Project="$(MSBuildProjectDirectory)\tools\MSBuildTasks\MSBuild.Community.Tasks.Targets" />
<Target Name="RestorePackages" DependsOnTargets="Clean;UpdateVersion">
<!-- NuGet packages for "legacy" projects (eg. React.Samples.Mvc4) -->
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="tools\NuGet\nuget.exe restore $(SolutionFile)"
/>
<!-- NuGet packages for modern .csproj projects -->
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet restore $(SolutionFile) /p:Version=$(VersionString)"
/>
<!-- npm packages -->
<Exec
WorkingDirectory="src/React.Core"
Command="npm install"
/>
<Exec
WorkingDirectory="src/React.Core/Resources/babel-legacy"
Command="npm install"
/>
<Exec
WorkingDirectory="src/React.Sample.Mvc4"
Command="npm install"
/>
</Target>
<Target Name="UpdateVersion">
<GitVersion LocalPath="$(MSBuildProjectDirectory)">
<Output TaskParameter="CommitHash" PropertyName="Revision" />
</GitVersion>
<Time Format="yyyyMMdd-HHmm">
<Output TaskParameter="FormattedTime" PropertyName="Date" />
</Time>
<!-- Prepend date to build version if a dev build-->
<PropertyGroup Condition="$(BuildType) == 'Release'">
<VersionString>$(Major).$(Minor).$(Build)</VersionString>
</PropertyGroup>
<PropertyGroup Condition="$(BuildType) != 'Release'">
<VersionString>$(Major).$(Minor).$(Build)-dev-$(Date)</VersionString>
</PropertyGroup>
<!-- Set version for assemblies -->
<AssemblyInfo
CodeLanguage="CS"
OutputFile="src\SharedAssemblyVersionInfo.cs"
AssemblyVersion="$(Major).$(Minor)"
AssemblyFileVersion="$(VersionString).$(Revision)"
AssemblyInformationalVersion="$(VersionString)"
/>
</Target>
<Target Name="Clean" BeforeTargets="Build">
<!--
ASP.NET Core projects don't delete generated .nupkg files when cleaned or rebuilt, so we need to
do it here. See https://github.com/aspnet/XRE/issues/1301
-->
<DeleteTree Directories="src/artifacts" />
<DeleteTree Directories="src/%(PackageAssemblies.Identity)/bin" />
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages;UpdateVersion">
<Exec WorkingDirectory="src/React.Core" Command="node_modules/.bin/webpack" />
<Exec WorkingDirectory="src/React.Core/Resources/babel-legacy" Command="node_modules/.bin/webpack" />
<MSBuild Projects="$(SolutionFile)" Targets="Rebuild" Properties="Configuration=Release;Platform=Any CPU;NoWarn=1607,7035,1701;Version=$(VersionString)" />
</Target>
<Target Name="Test" DependsOnTargets="Build">
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet test --configuration Release --no-build tests/React.Tests/React.Tests.csproj"
/>
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet test --configuration Release --no-build tests/React.Tests.Integration/React.Tests.Integration.csproj"
/>
</Target>
<Target Name="PackageTemplates" DependsOnTargets="Build;PackageLibrary">
<Exec WorkingDirectory="src/React.Template/reactnet-vanilla" Command="dotnet restore ReactDemo.sln" />
<Exec WorkingDirectory="src/React.Template/reactnet-vanilla" Command="dotnet add package React.AspNet -v $(VersionString) -n" />
<Exec WorkingDirectory="src/React.Template/reactnet-vanilla" Command="dotnet restore ReactDemo.sln -s $(PackageOutputDir) " />
<Exec WorkingDirectory="src/React.Template/reactnet-vanilla" Command="dotnet build ReactDemo.sln -c Release -p:Version=$(VersionString)" />
<Exec WorkingDirectory="src/React.Template/reactnet-webpack" Command="dotnet restore" />
<Exec WorkingDirectory="src/React.Template/reactnet-webpack" Command="dotnet add package React.AspNet -v $(VersionString) -n" />
<Exec WorkingDirectory="src/React.Template/reactnet-webpack" Command="dotnet add package React.Router -v $(VersionString) -n" />
<Exec WorkingDirectory="src/React.Template/reactnet-webpack" Command="dotnet restore -s $(PackageOutputDir) " />
<Exec WorkingDirectory="src/React.Template/reactnet-webpack" Command="dotnet build -c Release -p:Version=$(VersionString)" />
<Exec WorkingDirectory="src/React.Template" Command="dotnet pack --output $(PackageOutputDir) React.Template.csproj -c Release /p:Version=$(VersionString)" />
</Target>
<Target Name="PackageLibrary" DependsOnTargets="Build">
<!-- Delete old packages -->
<RemoveDir Directories="$(PackageOutputDir)" />
<!-- Create new packages -->
<MakeDir Directories="$(PackageOutputDir)" />
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="dotnet pack --output $(PackageOutputDir) --configuration Release --no-build src/%(PackageAssemblies.Identity) /p:Version=$(VersionString)"
/>
</Target>
<Target Name="Package">
<CallTarget Targets="PackageLibrary" />
<CallTarget Targets="PackageTemplates" />
</Target>
<Target Name="Push">
<CallTarget Targets="PushDev" Condition="$(BuildType) != 'Release'" />
<CallTarget Targets="PushRelease" Condition="$(BuildType) == 'Release'" />
</Target>
<Target Name="PushRelease">
<ItemGroup>
<PackageFiles Include="$(PackageOutputDir)\*.nupkg" Exclude="$(PackageOutputDir)\*.symbols.nupkg" />
</ItemGroup>
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="tools\NuGet\nuget.exe push %(PackageFiles.Identity) -NonInteractive -Source https://www.nuget.org/api/v2/package"
/>
</Target>
<Target Name="PushDev">
<Exec
WorkingDirectory="$(MSBuildProjectDirectory)"
Command="tools\NuGet\nuget.exe push $(PackageOutputDir)\*.symbols.nupkg -Source $(DevNuGetServer) -NonInteractive"
/>
</Target>
</Project>