forked from moodmosaic/Fare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildRelease.msbuild
87 lines (87 loc) · 4.3 KB
/
BuildRelease.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
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="CompleteBuild" ToolsVersion="4.0">
<PropertyGroup>
<XUnitPath>Src\packages\xunit.runners.1.9.2\tools</XUnitPath>
</PropertyGroup>
<UsingTask TaskName="xunitproject" AssemblyFile="$(XUnitPath)\xunit.runner.msbuild.dll" />
<ItemGroup>
<ProjectToBuild Include="Src\*.sln" />
</ItemGroup>
<ItemGroup>
<BuildOutput Include="Src\Fare\bin\Release\Fare.dll" />
<BuildOutput Include="Src\Fare\bin\Release\Fare.XML" />
</ItemGroup>
<ItemGroup>
<NuSpecFiles Include="NuGet\*.nuspec" />
<NuGetPackageScripts Include="NuGet\*.ps1" />
</ItemGroup>
<PropertyGroup>
<ReleaseFolder>Release</ReleaseFolder>
</PropertyGroup>
<!--Optional Clean targets-->
<Target Name="CleanAll" DependsOnTargets="CleanDebug;CleanVerify;CleanRelease" />
<Target Name="CleanDebug">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Debug" />
</Target>
<Target Name="CleanVerify">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Verify" />
</Target>
<Target Name="CleanRelease">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Release" />
</Target>
<!--Build tasks-->
<Target Name="DeleteReleaseFolder">
<RemoveDir Directories="$(ReleaseFolder)" />
</Target>
<Target Name="MakeReleaseFolder" DependsOnTargets="DeleteReleaseFolder">
<MakeDir Directories="$(ReleaseFolder)" Condition="!Exists($(ReleaseFolder))" />
</Target>
<Target Name="Verify" DependsOnTargets="MakeReleaseFolder">
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Verify" />
</Target>
<Target Name="Build" DependsOnTargets="Verify">
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Release" />
</Target>
<Target Name="Test" DependsOnTargets="Build">
<xunitproject ProjectFile="Src\All.xunit" />
</Target>
<Target Name="CopyToReleaseFolder" DependsOnTargets="Test">
<Copy SourceFiles="@(BuildOutput)" DestinationFolder="$(ReleaseFolder)" />
<Copy SourceFiles="@(NuGetPackageScripts)" DestinationFolder="$(ReleaseFolder)" />
</Target>
<Target Name="CreateTemporaryNuGetSpecFiles">
<PropertyGroup>
<NuGetOutputFolder>NuGetPackages</NuGetOutputFolder>
</PropertyGroup>
<RemoveDir Directories="$(NuGetOutputFolder)" />
<Copy SourceFiles="@(NuSpecFiles)" DestinationFolder="$(NuGetOutputFolder)">
<Output TaskParameter="CopiedFiles" ItemName="TempNuspecFiles" />
</Copy>
</Target>
<Target Name="NuGetPrepare" DependsOnTargets="CreateTemporaryNuGetSpecFiles;CopyToReleaseFolder" Outputs="%(TempNuspecFiles.Identity)">
<PropertyGroup>
<TempNuspecFilePath>%(TempNuspecFiles.FullPath)</TempNuspecFilePath>
<AssemblyFile>$(ReleaseFolder)\%(TempNuspecFiles.Filename).dll</AssemblyFile>
</PropertyGroup>
<GetAssemblyIdentity AssemblyFiles="$(AssemblyFile)">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<Version>%(AssemblyInfo.Version)</Version>
<SemanticVersion>$(Version.Substring(0, $(Version.LastIndexOf('.'))))</SemanticVersion>
</PropertyGroup>
<XmlPoke XmlInputPath="$(TempNuspecFilePath)"
Query="//metadata/version"
Value="$(SemanticVersion)" />
<XmlPoke XmlInputPath="$(TempNuspecFilePath)"
Query="//metadata/dependencies/dependency/Fare/@version"
Value="$(SemanticVersion)" />
</Target>
<Target Name="NuGetPack" DependsOnTargets="NuGetPrepare">
<Exec Command="NuGet\NuGet.exe pack %(TempNuspecFiles.FullPath) -BasePath $(ReleaseFolder) -OutputDirectory $(NuGetOutputFolder)" />
</Target>
<Target Name="CleanTemporaryNuGetSpecFiles" DependsOnTargets="NuGetPack">
<Delete Files="@(TempNuspecFiles)" />
</Target>
<Target Name="CompleteBuild" DependsOnTargets="CopyToReleaseFolder;CleanTemporaryNuGetSpecFiles" />
</Project>