Skip to content

Commit cfba7c4

Browse files
committed
Add ASP.NET 5 project to build script
1 parent 6a18a8f commit cfba7c4

File tree

12 files changed

+165
-33
lines changed

12 files changed

+165
-33
lines changed

build.proj

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ of patent rights can be found in the PATENTS file in the same directory.
1010
<Project ToolsVersion="4.0" DefaultTargets="Build;Test;Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1111
<PropertyGroup>
1212
<Major>1</Major>
13-
<Minor>3</Minor>
14-
<Build>1</Build>
13+
<Minor>4</Minor>
14+
<Build>0</Build>
1515
<Revision>0</Revision>
1616
<DevNuGetServer>http://reactjs.net/packages/</DevNuGetServer>
1717
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\tools\MSBuildTasks</MSBuildCommunityTasksPath>
18-
<SolutionFile>src\React.sln</SolutionFile>
1918
<PackageOutputDir>output</PackageOutputDir>
19+
20+
<!-- Only build ASP.NET 5 projects if on MSBuild 14+ (VS2015+) -->
21+
<BuildAspNet5>false</BuildAspNet5>
22+
<BuildAspNet5 Condition="$(VisualStudioVersion) == '14.0'">true</BuildAspNet5>
23+
<SolutionFile>src\React.VS2015.sln</SolutionFile>
24+
<SolutionFile Condition="$(BuildAspNet5) == 'false'">src\React.sln</SolutionFile>
2025
</PropertyGroup>
2126
<ItemGroup>
2227
<PackageAssemblies Include="React" />
@@ -28,14 +33,12 @@ of patent rights can be found in the PATENTS file in the same directory.
2833
<PackageAssemblies Include="React.MSBuild" />
2934
<PackageAssemblies Include="React.JavaScriptEngine.VroomJs" />
3035
<PackageAssemblies Include="React.JavaScriptEngine.ClearScriptV8" />
36+
<PackageAssembliesAspNet5 Include="React.AspNet5" />
37+
<AspNet5ProjectJson Include="src/**/project.json" />
3138
</ItemGroup>
3239

33-
<Import Project="$(MSBuildProjectDirectory)\tools\MSBuildTasks\MSBuild.Community.Tasks.Targets" />
34-
<UsingTask
35-
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll"
36-
TaskName="TransformXml"
37-
/>
38-
40+
<Import Project="src/React.tasks.proj" />
41+
3942
<Target Name="RestorePackages">
4043
<Exec
4144
WorkingDirectory="$(MSBuildProjectDirectory)"
@@ -47,27 +50,64 @@ of patent rights can be found in the PATENTS file in the same directory.
4750
<GitVersion LocalPath="$(MSBuildProjectDirectory)">
4851
<Output TaskParameter="CommitHash" PropertyName="Revision" />
4952
</GitVersion>
50-
<!--TODO: Only do this if a dev build -->
5153
<Time Format="yyyyMMdd-HHmm">
5254
<Output TaskParameter="FormattedTime" PropertyName="Date" />
5355
</Time>
5456
<!-- Prepend date to build version if a dev build-->
57+
<PropertyGroup Condition="$(BuildType) == 'Release'">
58+
<FullBuild>$(Build)</FullBuild>
59+
</PropertyGroup>
5560
<PropertyGroup Condition="$(BuildType) != 'Release'">
56-
<Build>$(Build)-dev-$(Date)</Build>
61+
<FullBuild>$(Build)-dev-$(Date)</FullBuild>
5762
</PropertyGroup>
63+
<!-- Set version for .csproj projects -->
5864
<AssemblyInfo
5965
CodeLanguage="CS"
6066
OutputFile="src\SharedAssemblyVersionInfo.cs"
6167
AssemblyVersion="$(Major).$(Minor)"
62-
AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
63-
AssemblyInformationalVersion="$(Major).$(Minor).$(Build)"
64-
/>
68+
AssemblyFileVersion="$(Major).$(Minor).$(FullBuild).$(Revision)"
69+
AssemblyInformationalVersion="$(Major).$(Minor).$(FullBuild)"
70+
/>
71+
<!--
72+
Set version for ASP.NET 5 projects. In theory K_BUILD_VERSION should work but it doesn't seem
73+
to be functional yet :(. We work around this by physically writing the build number to the
74+
project.json files. For development builds we write the full version number (including
75+
build date) and reset it later so the dev build number isn't commited to the repo.
76+
-->
77+
<!--SetEnvironmentVariable
78+
Condition="$(BuildAspNet5) == 'true'"
79+
Name="K_BUILD_VERSION"
80+
Value="$(Build)"
81+
/-->
82+
<UpdateAspNetProjectVersion
83+
Files="@(AspNet5ProjectJson)"
84+
Version="$(Major).$(Minor).$(FullBuild)"
85+
/>
86+
</Target>
87+
88+
<Target Name="Clean" BeforeTargets="Build">
89+
<!--
90+
ASP.NET 5 projects don't delete generated .nupkg files when cleaned or rebuilt, so we need to
91+
do it here. See https://github.com/aspnet/XRE/issues/1301
92+
-->
93+
<ItemGroup>
94+
<OldAspNet5Packages Include="bin/%(PackageAssembliesAspNet5.Identity)/**/*.nupkg" />
95+
</ItemGroup>
96+
<Delete Files="@(OldAspNet5Packages)" />
6597
</Target>
6698

6799
<Target Name="Build" DependsOnTargets="RestorePackages;UpdateVersion">
68100
<MSBuild Projects="$(SolutionFile)" Targets="Rebuild" Properties="Configuration=Release;Platform=Any CPU;NoWarn=1607" />
69101
</Target>
70102

103+
<Target Name="ResetAspNetVersion" AfterTargets="Build">
104+
<!-- Resets the version number in ASP.NET project.json files so we don't commit -dev- version numbers -->
105+
<UpdateAspNetProjectVersion
106+
Files="@(AspNet5ProjectJson)"
107+
Version="$(Major).$(Minor).$(Build)-*"
108+
/>
109+
</Target>
110+
71111
<Target Name="Test" DependsOnTargets="Build">
72112
<ItemGroup>
73113
<TestAssemblies Include="bin/ReleaseTests/**/React.Tests*.dll" />
@@ -98,6 +138,14 @@ of patent rights can be found in the PATENTS file in the same directory.
98138
/>
99139
</Target>
100140

141+
<Target Name="CopyAspNetPackages" AfterTargets="Package" Condition="$(BuildAspNet5) == 'true'">
142+
<!-- Copy over ASP.NET 5 packages -->
143+
<ItemGroup>
144+
<AspNet5Packages Include="bin/%(PackageAssembliesAspNet5.Identity)/Release/*.nupkg" />
145+
</ItemGroup>
146+
<Copy SourceFiles="@(AspNet5Packages)" DestinationFolder="output" />
147+
</Target>
148+
101149
<Target Name="Push">
102150
<CallTarget Targets="PushDev" Condition="$(BuildType) != 'Release'" />
103151
<CallTarget Targets="PushRelease" Condition="$(BuildType) == 'Release'" />

dev-build-push.bat

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
@echo off
2-
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /t:Package;Push /p:BuildType=Dev
2+
IF EXIST "%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" (
3+
"%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" build.proj /t:Package;Push /p:BuildType=Dev
4+
) ELSE (
5+
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /t:Package;Push /p:BuildType=Dev
6+
)
37
pause

dev-build-vs2015.bat

Lines changed: 0 additions & 3 deletions
This file was deleted.

dev-build.bat

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
@echo off
2-
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /p:BuildType=Dev
2+
IF EXIST "%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" (
3+
"%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" build.proj /p:BuildType=Dev
4+
) ELSE (
5+
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /p:BuildType=Dev
6+
)
37
pause

release-build-push.bat

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
@echo off
2-
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /t:Package;Push /p:BuildType=Release
2+
IF EXIST "%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" (
3+
"%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" build.proj /t:Package;Push /p:BuildType=Release
4+
) ELSE (
5+
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /t:Package;Push /p:BuildType=Release
6+
)
37
pause

release-build.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
@echo off
2-
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /p:BuildType=Release
2+
IF EXIST "%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" (
3+
"%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" build.proj /p:BuildType=Release
4+
) ELSE (
5+
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" build.proj /p:BuildType=Release
6+
)
7+
pause
38
pause

src/React.AspNet5/React.AspNet5.kproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ProjectGuid>a7acdb56-5e43-40a6-92c9-2c52228e6074</ProjectGuid>
1010
<RootNamespace>React.AspNet5</RootNamespace>
1111
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12-
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\bin\$(MSBuildProjectName)\</OutputPath>
1313
</PropertyGroup>
1414
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
1515
<AssemblyName>React.AspNet5</AssemblyName>

src/React.AspNet5/project.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"version": "1.3.1-*",
2+
"version": "1.4.0-*",
33
"configurations": {
44
"Debug": {
55
"compilationOptions": {
6-
"define": ["DEBUG", "TRACE", "ASPNET5"]
6+
"define": [ "DEBUG", "TRACE", "ASPNET5" ]
77
}
88
},
99
"Release": {
1010
"compilationOptions": {
11-
"define": ["RELEASE", "TRACE", "ASPNET5"],
12-
"optimize": true
11+
"define": [ "RELEASE", "TRACE", "ASPNET5" ],
12+
"optimize": true,
13+
"warningsAsErrors": true,
1314
}
14-
},
15+
}
1516
},
1617
"dependencies": {
1718
"Microsoft.Framework.DependencyInjection": "1.0.0.0-beta3",
@@ -20,8 +21,13 @@
2021
"Microsoft.AspNet.StaticFiles": "1.0.0.0-beta3",
2122
"React": ""
2223
},
23-
2424
"frameworks": {
25-
"aspnet50": {}
26-
}
25+
"aspnet50": { }
26+
},
27+
28+
// NuGet info
29+
"authors": [ "Daniel Lo Nigro" ],
30+
"description": "ReactJS tools for ASP.NET 5, including ASP.NET MVC 6. Please refer to project site (http://reactjs.net/) for more details, usage examples and sample code",
31+
"tags": [ "asp.net", "mvc", "asp", "javascript", "js", "react", "facebook", "reactjs", "vnext" ],
32+
"projectUrl": "http://reactjs.net/"
2733
}

src/React.Sample.Mvc6/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
/* Click to learn more about project.json http://go.microsoft.com/fwlink/?LinkID=517074 */
33
"webroot": "wwwroot",
4-
"version": "1.0.0-*",
4+
"version": "1.4.0-*",
55
"dependencies": {
66
"Microsoft.AspNet.Mvc": "6.0.0.0-beta3",
77
"Microsoft.AspNet.Diagnostics": "1.0.0.0-beta3",

src/React.VS2015.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22512.0
4+
VisualStudioVersion = 14.0.22609.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{F567B25C-E869-4C93-9C96-077761250F87}"
77
EndProject
@@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CB51F03F
1515
..\build.proj = ..\build.proj
1616
..\dev-build-push.bat = ..\dev-build-push.bat
1717
..\dev-build.bat = ..\dev-build.bat
18+
build\React.tasks.proj = build\React.tasks.proj
1819
..\README.md = ..\README.md
1920
..\release-build-push.bat = ..\release-build-push.bat
2021
..\release-build.bat = ..\release-build.bat

0 commit comments

Comments
 (0)