-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDD4T Providers.Targets
158 lines (136 loc) · 6.92 KB
/
DD4T Providers.Targets
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
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<ProductName>DD4T.Providers</ProductName>
<!-- Source Directories -->
<BaseDirectory Condition="'$(BaseDirectory)' == ''">$(MSBuildProjectDirectory)</BaseDirectory>
<BaseDirectory Condition="!Exists('$(BaseDirectory)\source')">..\..</BaseDirectory>
<SourceDirectory>$(BaseDirectory)\source</SourceDirectory>
<!-- Build Directories -->
<BuildOutputDirectory>$(BaseDirectory)\build</BuildOutputDirectory>
<BuildBinDirectory>$(BuildOutputDirectory)\bin</BuildBinDirectory>
<BuildDocDirectory>$(BuildOutputDirectory)\doc</BuildDocDirectory>
<BuildLogDirectory>$(BuildOutputDirectory)\log</BuildLogDirectory>
<BuildPackageDirectory>$(BuildOutputDirectory)\package</BuildPackageDirectory>
<BuildWorkDirectory>$(BuildOutputDirectory)\work</BuildWorkDirectory>
<BuildNuGetDirectory>$(BuildPackageDirectory)\lib</BuildNuGetDirectory>
<BuildNuGetFramework40Directory>$(BuildNuGetDirectory)\net40</BuildNuGetFramework40Directory>
<BuildNuGetFramework45Directory>$(BuildNuGetDirectory)\net45</BuildNuGetFramework45Directory>
<DependencyDirectory>$(BaseDirectory)\dependencies</DependencyDirectory>
<NuGetFolder>$(SourceDirectory)\.nuget</NuGetFolder>
<ConfigurationDirectory>$(BaseDirectory)\configuration</ConfigurationDirectory>
<!-- NuSpec file for NuGet Package creation -->
<NuSpecFileName>$(ConfigurationDirectory)\$(ProductName).nuspec</NuSpecFileName>
</PropertyGroup>
<ItemGroup>
<CleanFolders Include="$(BuildOutputDirectory)"/>
<CleanFolders Include="TestResults"/>
<NuGetStructureFolders Include="$(BuildNugetDirectory);$(BuildNuGetFramework40Directory);$(BuildNuGetFramework45Directory)"/>
<DependencyFiles Include="$(DependencyDirectory)\**\*.dll"/>
<DependencyDirectories Include="@(DependencyFiles->'%(RootDir)%(Directory)'->Distinct())" />
</ItemGroup>
<Import Project="$(SolutionDir)packages\MSBuildTasks.1.5.0.235\build\MSBuildTasks.targets"/>
<!-- Task for retrieving ProductVersion from an Assembly -->
<UsingTask TaskName="GetInformationalVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<AssemblyFile ParameterType="System.String" Required="true" />
<Version ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Diagnostics" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage("Getting version details of assembly " + this.AssemblyFile, MessageImportance.High);
this.Version = FileVersionInfo.GetVersionInfo(this.AssemblyFile.Split(';').Where(a => a.Contains("DD4T")).ToList()[0]).ProductVersion;
Log.LogMessage("AssemblyVersion: " + this.Version, MessageImportance.High);
]]>
</Code>
</Task>
</UsingTask>
<!-- Task for generating a new version for local development -->
<UsingTask TaskName="GetNewDevVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<OldVersion ParameterType="System.String" Required="true" />
<NewVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Diagnostics" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage("Getting a new version for " + this.OldVersion, MessageImportance.High);
Version version = new Version(this.OldVersion.Split('-')[0]);
this.NewVersion = version.ToString() + "-build" + DateTime.Now.ToString("yyyyMMddHHmmss");
Log.LogMessage("New Version: " + this.NewVersion, MessageImportance.High);
]]>
</Code>
</Task>
</UsingTask>
<Target Name="CleanUp">
<!-- Clean removes all build artifacts to prepare for a new build. -->
<RemoveDir Directories="@(CleanFolders)" />
<MSBuild Projects="$(SolutionFile)" Targets="Clean" />
</Target>
<Target Name="Package">
<ItemGroup>
<PackageFilesCleanup Include="$(BuildPackageDirectory)\**\*.*"/>
</ItemGroup>
<Delete Files="@(PackageFilesCleanup)" />
<!-- Package builds the zip files, NuGet packages, and MSI files for the project. -->
<ItemGroup>
<BinFiles Include="$(BuildBinDirectory)\**\*.*" />
</ItemGroup>
<!-- Flatten file structure -->
<Copy SourceFiles="@(BinFiles)" DestinationFiles="@(BinFiles->'$(BuildWorkDirectory)\%(Filename)%(Extension)')"/>
<ItemGroup>
<PackageFiles Include="$(BuildWorkDirectory)\**\*.dll;$(BuildWorkDirectory)\**\*.pdb;$(BuildWorkDirectory)\**\*.xml;"/>
</ItemGroup>
<!-- Build NuGet package structure -->
<MakeDir Directories="@(NuGetStructureFolders)" />
<Copy SourceFiles="@(PackageFiles)" DestinationFiles="@(PackageFiles->'$(BuildNuGetFramework40Directory)\%(Filename)%(Extension)')" />
<Copy SourceFiles="@(PackageFiles)" DestinationFiles="@(PackageFiles->'$(BuildNuGetFramework45Directory)\%(Filename)%(Extension)')" />
<!-- Copy nuspec file -->
<Copy SourceFiles="$(NuSpecFileName)" DestinationFolder="$(BuildPackageDirectory)" />
<!-- Get the productversion from the assemblies -->
<GetInformationalVersion AssemblyFile="@(PackageFiles)">
<Output TaskParameter="Version" PropertyName="VersionInfo"/>
</GetInformationalVersion>
<GetNewDevVersion OldVersion="$(VersionInfo)" Condition="'$(Configuration)' == 'Debug'">
<Output TaskParameter="NewVersion" PropertyName="VersionInfo"/>
</GetNewDevVersion>
<PropertyGroup>
<NuSpecFile>$(BuildPackageDirectory)\$(ProductName).nuspec</NuSpecFile>
</PropertyGroup>
<!-- Update version in nuspec file -->
<XmlUpdate XmlFileName="$(NuSpecFile)" XPath="//version" Value="$(VersionInfo)" />
<!-- Create NuGet package -->
<Exec Command='$(NuGetFolder)\nuget.exe pack "$(NuSpecFile)"' WorkingDirectory="$(BuildPackageDirectory)"/>
<XmlPeek
Namespaces="<Namespace Prefix='nuget' Uri='http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd' />"
Query="//id/text()"
XmlInputPath="$(NuSpecFile)">
<Output TaskParameter="Result" ItemName="PackageName" />
</XmlPeek>
<!-- Create ZipPackage -->
<Zip Files="@(PackageFiles)" ZipFileName="$(BuildPackageDirectory)\@(PackageName).$(VersionInfo).zip" WorkingDirectory="$(BuildWorkDirectory)" />
<!-- Remove temporary files -->
<RemoveDir Directories="$(BuildNugetDirectory)" />
<RemoveDir Directories="$(BuildWorkDirectory)" />
<Delete Files="$(NuSpecFile)" />
</Target>
<Target Name="BeforeBuild">
<ItemGroup>
<ReferenceNew Include="@(Reference)">
<Private>False</Private>
</ReferenceNew>
<Reference Remove="@(Reference)"/>
<Reference Include="@(ReferenceNew)"/>
</ItemGroup>
</Target>
<Target Name="Install">
<ItemGroup>
<NuGetPackage Include="$(BuildPackageDirectory)\**\*.nupkg"/>
</ItemGroup>
<Copy SourceFiles="@(NuGetPackage)" DestinationFolder="$(NUGET_LOCALREPO)" />
</Target>
</Project>