-
Notifications
You must be signed in to change notification settings - Fork 2
/
Lombiq.Npm.Targets.targets
75 lines (66 loc) · 3.03 KB
/
Lombiq.Npm.Targets.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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target
Name="NpmInstall"
Inputs="$(PackageJson)"
Outputs="$(NpmInstallStampFile)"
Condition="'$(ExecNpmInstallCommand)' == 'true' AND Exists($(PackageJson))">
<!-- Check if pnpm is installed. -->
<Exec Command="pnpm -v" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="PnpmInstalledExitCode" />
</Exec>
<!-- Use pnpm if installed. -->
<Exec Command="$(PnpmInstallCommand)"
Condition="'$(PnpmInstalledExitCode)' == '0'"
WorkingDirectory="$(NpmTargetsWorkingDirectory)"
EnvironmentVariables="@(NpmCommandsEnvironmentVariables)" />
<!-- Otherwise use regular npm. -->
<Exec Command="$(NpmInstallCommand)"
Condition="'$(PnpmInstalledExitCode)' != '0'"
WorkingDirectory="$(NpmTargetsWorkingDirectory)"
EnvironmentVariables="@(NpmCommandsEnvironmentVariables)" />
<!-- Ensure that the node_modules folder exists because we use it for our stamp files. -->
<MakeDir Directories="$(NodeModulesFolderPath)" Condition="!Exists($(NodeModulesFolderPath))" />
<Touch Files="$(NpmInstallStampFile)" AlwaysCreate="true" Condition="'$(CreateNpmInstallStampFile)' == 'true'" />
</Target>
<Target
Name="DeleteDotnetPrebuildStampFile"
AfterTargets="Clean"
Condition="Exists($(NpmDotnetPrebuildStampFile))">
<Delete Files="$(NpmDotnetPrebuildStampFile)" />
</Target>
<Target
Name="NpmDotnetPostclean"
AfterTargets="Clean"
Condition="'$(ExecDotnetPostcleanCommand)' == 'true' AND Exists($(PackageJson)) AND Exists($(NpmTargetsWorkingDirectory))">
<Exec Command="$(NpmDotnetPostcleanCommand)"
WorkingDirectory="$(NpmTargetsWorkingDirectory)"
EnvironmentVariables="@(NpmCommandsEnvironmentVariables)"
IgnoreExitCode="true"
IgnoreStandardErrorWarningFormat="true" />
</Target>
<!--
EmbeddModuleAssets (sic!) was renamed to OrchardCoreEmbedModuleAssets (first released in Orchard Core 1.4), but
we're keeping it here for backwards compatibility.
-->
<Target
Name="NpmDotnetPrebuild"
DependsOnTargets="NpmInstall"
AfterTargets="AfterResolveReferences;InitCommonNodeModules"
BeforeTargets="EmbeddModuleAssets;OrchardCoreEmbedModuleAssets;Compile"
Inputs="@(NpmDotnetPrebuildWatchedFiles)"
Outputs="$(NpmDotnetPrebuildStampFile)"
Condition="'$(ExecDotnetPrebuildCommand)' == 'true' AND Exists($(PackageJson))">
<CallTarget Targets="_NpmDotnetPrebuild" />
<Touch Files="$(NpmDotnetPrebuildStampFile)"
Condition="'$(CreateDotnetPrebuildStampFile)' == 'true'"
AlwaysCreate="true" />
</Target>
<Target Name="_NpmDotnetPrebuild">
<Exec Command="$(NpmDotnetPrebuildCommand)"
ConsoleToMSBuild="true"
WorkingDirectory="$(NpmTargetsWorkingDirectory)"
EnvironmentVariables="@(NpmCommandsEnvironmentVariables)">
<Output TaskParameter="ConsoleOutput" PropertyName="PrebuildOutput" />
</Exec>
</Target>
</Project>