forked from ploeh/ZeroToNine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildRelease.msbuild
98 lines (90 loc) · 4.13 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
88
89
90
91
92
93
94
95
96
97
98
<?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="xunit" AssemblyFile="$(XUnitPath)\xunit.runner.msbuild.dll" />
<!--What to build-->
<ItemGroup>
<ProjectToBuild Include="Src\*.sln" />
</ItemGroup>
<ItemGroup>
<BuildOutput Include="Src\Zero29\bin\Release\Zero29.exe" />
<BuildOutput Include="Src\Zero29\bin\Release\Zero29.XML" />
<BuildOutput Include="Src\ZeroToNine\bin\Release\Ploeh.ZeroToNine.dll" />
<BuildOutput Include="Src\ZeroToNine\bin\Release\Ploeh.ZeroToNine.XML" />
</ItemGroup>
<!--Clean-->
<Target Name="CleanAll" DependsOnTargets="CleanDebug;CleanRelease" />
<Target Name="CleanDebug">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Debug" />
</Target>
<Target Name="CleanRelease">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Release" />
</Target>
<!--Compile-->
<Target Name="Build" DependsOnTargets="CleanAll">
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Release" />
</Target>
<!--Test-->
<Target Name="Test" DependsOnTargets="Build">
<ItemGroup>
<TestAssemblies Include="**\bin\Release\*Tests.dll" />
</ItemGroup>
<xunit Assemblies="@(TestAssemblies)" />
</Target>
<!--Release-->
<PropertyGroup>
<ReleaseFolder>Release</ReleaseFolder>
</PropertyGroup>
<Target Name="DeleteReleaseFolder">
<RemoveDir Directories="$(ReleaseFolder)" />
</Target>
<Target Name="MakeReleaseFolder" DependsOnTargets="DeleteReleaseFolder">
<MakeDir Directories="$(ReleaseFolder)" Condition="!Exists($(ReleaseFolder))" />
</Target>
<Target Name="CopyToReleaseFolder" DependsOnTargets="Test">
<Copy SourceFiles="@(BuildOutput)" DestinationFolder="$(ReleaseFolder)" />
</Target>
<!--NuGet-->
<ItemGroup>
<NuSpecFiles Include="NuGetSpecs\*.nuspec" />
</ItemGroup>
<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 Condition="Exists('$(ReleaseFolder)\%(TempNuspecFiles.Filename).dll')">$(ReleaseFolder)\%(TempNuspecFiles.Filename).dll</AssemblyFile>
<AssemblyFile Condition="Exists('$(ReleaseFolder)\%(TempNuspecFiles.Filename).exe')">$(ReleaseFolder)\%(TempNuspecFiles.Filename).exe</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[contains(@id, 'zerotonine')]/@version"
Value="$(SemanticVersion)" />
</Target>
<Target Name="NuGetPack" DependsOnTargets="NuGetPrepare">
<Exec Command="Src\packages\NuGet.CommandLine.2.7.1\tools\nuget.exe pack %(TempNuspecFiles.FullPath) -BasePath $(ReleaseFolder) -OutputDirectory $(NuGetOutputFolder) -NoPackageAnalysis" />
</Target>
<Target Name="CleanTemporaryNuGetSpecFiles" DependsOnTargets="NuGetPack">
<Delete Files="@(TempNuspecFiles)" />
</Target>
<!--Done-->
<Target Name="CompleteBuild" DependsOnTargets="CleanTemporaryNuGetSpecFiles" />
</Project>