-
Notifications
You must be signed in to change notification settings - Fork 14
/
MSBuild.Grunt.targets
77 lines (70 loc) · 3.95 KB
/
MSBuild.Grunt.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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="EnsureGrunt">
<PropertyGroup>
<GruntNotFoundError>Grunt module not found. Please install Grunt in the node module path '$(NodeModulePath)'.</GruntNotFoundError>
<GruntExecutable>$(NodeModulePath)\grunt.cmd</GruntExecutable>
<GruntOut>$([System.IO.Path]::GetTempFileName())</GruntOut>
<GruntExitCode>0</GruntExitCode>
<GruntTaskDeprecationWarning>The 'GruntTask' property is deprecated and will be removed in a future version. Please use 'GruntBuildTask' instead.</GruntTaskDeprecationWarning>
</PropertyGroup>
<Message Text="Ensuring Grunt is installed" Importance="low" />
<Exec Command="$(WINDIR)\system32\where.exe grunt"
ContinueOnError="true"
IgnoreExitCode="true"
Condition=" !Exists('$(GruntExecutable)') ">
<Output TaskParameter="ExitCode" PropertyName="GruntExitCode" />
<Output TaskParameter="ConsoleOutput" PropertyName="GruntExecutable" />
</Exec>
<Error Condition=" '$(GruntExitCode)' != '0' " Text="'$(GruntNotFoundError)'" />
<!-- Deprecated Warning & Fallback -->
<Warning Condition=" '$(GruntTask)' != '' " Text="'$(GruntTaskDeprecationWarning)'" />
<PropertyGroup Condition=" '$(GruntTask)' != '' ">
<GruntBuildTask>$(GruntTask)</GruntBuildTask>
</PropertyGroup>
<PropertyGroup>
<RunGruntBuildCmd>$(EnsureNodeInPathCmd) "$(GruntExecutable)" --no-color --gruntfile "$(GruntFile)" $(GruntBuildTask) > "$(GruntOut)"</RunGruntBuildCmd>
<RunGruntCleanCmd>$(EnsureNodeInPathCmd) "$(GruntExecutable)" --no-color --gruntfile "$(GruntFile)" $(GruntCleanTask) > "$(GruntOut)"</RunGruntCleanCmd>
<GruntBuildTaskError>Error running grunt task '$(GruntBuildTask)'. See Warnings for details.</GruntBuildTaskError>
<GruntCleanTaskError>Error running grunt task '$(GruntCleanTask)'. See Warnings for details.</GruntCleanTaskError>
</PropertyGroup>
<Message Text="Grunt found: '$(GruntExecutable)'" />
</Target>
<Target Name="RunGruntBuild"
DependsOnTargets="EnsureNodeModules;EnsureGrunt"
BeforeTargets="Build"
Condition=" Exists('$(GruntFile)') AND '$(GruntBuildTask)' != '' " >
<Exec Command="$(RunGruntBuildCmd)"
ContinueOnError="true"
IgnoreExitCode="true"
ConsoleToMsBuild="true"
WorkingDirectory="$(GruntWorkingDirectory)" >
<Output TaskParameter="ExitCode" PropertyName="GruntExitCode"/>
</Exec>
<ReadLinesFromFile File="$(GruntOut)">
<Output TaskParameter="Lines" ItemName="GruntOutLines"/>
</ReadLinesFromFile>
<Delete Files="$(GruntOut)"/>
<Warning Condition=" '$(GruntExitCode)' != '0' " Text="%(GruntOutLines.Identity)" />
<Error Condition=" '$(GruntExitCode)' != '0' " Text="$(GruntBuildTaskError)" />
</Target>
<Target Name="RunGruntClean"
DependsOnTargets="EnsureNodeModules;EnsureGrunt"
AfterTargets="Clean"
Condition=" Exists('$(GruntFile)') AND '$(GruntCleanTask)' != '' " >
<Exec Command="$(RunGruntCleanCmd)"
ContinueOnError="true"
IgnoreExitCode="true"
ConsoleToMsBuild="true"
WorkingDirectory="$(GruntWorkingDirectory)" >
<Output TaskParameter="ExitCode" PropertyName="GruntExitCode"/>
</Exec>
<ReadLinesFromFile File="$(GruntOut)">
<Output TaskParameter="Lines" ItemName="GruntOutLines"/>
</ReadLinesFromFile>
<Delete Files="$(GruntOut)"/>
<Warning Condition=" '$(GruntExitCode)' != '0' " Text="%(GruntOutLines.Identity)" />
<Error Condition=" '$(GruntExitCode)' != '0' " Text="$(GruntCleanTaskError)" />
</Target>
<!-- vim: set ft=xml sw=4 :-->
</Project>