-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathDataTables.Queryable.proj
89 lines (80 loc) · 3.18 KB
/
DataTables.Queryable.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
<Project InitialTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AssemblyName>DataTables.Queryable</AssemblyName>
<ProjectName>DataTables.Queryable</ProjectName>
<ProjectPath>DataTables.Queryable</ProjectPath>
<BinDirectory>$(ProjectPath)\bin</BinDirectory>
<GetAssemblyVersionPath>$(BinDirectory)\Release\net40\</GetAssemblyVersionPath>
</PropertyGroup>
<ItemGroup>
<ProjectToBuild Include="$(ProjectPath)\$(ProjectName).csproj">
<Properties>Configuration=Release</Properties>
</ProjectToBuild>
</ItemGroup>
<Target Name="All">
<CallTarget Targets="Clean;Build;GetVersion;CreateNuGet;CreateZip" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(BinDirectory)" />
<Message Text="Cleaned" />
</Target>
<Target Name="Build">
<MSBuild Projects="@(ProjectToBuild)" BuildInParallel="true" />
<Message Text="Build complete" />
</Target>
<Target Name="GetVersion">
<GetAssemblyIdentity AssemblyFiles="$(GetAssemblyVersionPath)$(AssemblyName).dll">
<Output TaskParameter="Assemblies" ItemName="OutputAssemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<Pattern>(\d+)\.(\d+)\.(\d+)</Pattern>
<In>%(OutputAssemblyInfo.Version)</In>
<AssemblyVersion>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern)))</AssemblyVersion>
</PropertyGroup>
<Message Text="Assembly version: $(AssemblyVersion)" />
</Target>
<Target Name="CreateNuGet">
<Exec Command=".utils\NuGet.exe pack "$(ProjectPath)\$(ProjectName).nuspec" -OutputDirectory "." -properties id=$(AssemblyName);version=$(AssemblyVersion)" />
</Target>
<Target Name="CreateZip">
<ItemGroup>
<FilesToZip Include="$(BinDirectory)\Release\*\*.dll" />
<FilesToZip Include="$(BinDirectory)\Release\*\*.xml" />
</ItemGroup>
<Zip Files="@(FilesToZip)" OutputFileName="$(AssemblyName).$(AssemblyVersion).zip"/>
</Target>
<UsingTask TaskName="Zip" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try
{
using (Stream zipStream = new FileStream(Path.GetFullPath(OutputFilename), FileMode.Create, FileAccess.Write))
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
{
foreach (ITaskItem fileItem in Files)
{
string filename = fileItem.ItemSpec;
using (Stream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read))
using (Stream fileStreamInZip = archive.CreateEntry(Path.GetFileName(Path.GetDirectoryName(filename)) + "/" + new FileInfo(filename).Name).Open())
fileStream.CopyTo(fileStreamInZip);
}
}
return true;
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>