forked from Lombiq/Gulp-Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lombiq.Gulp.Extensions.csproj
50 lines (44 loc) · 2.83 KB
/
Lombiq.Gulp.Extensions.csproj
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
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
<IsPublishable>false</IsPublishable>
</PropertyGroup>
<ItemGroup>
<None Remove="node_modules\**" />
</ItemGroup>
<!-- Note how the paths are hard-coded as two folders up (as documented in the Readme) and not using $(SolutionDir)
or something. This is because the project should be possible to build alone, without a solution too, and should
still work if after that it's also built as part of a solution. -->
<PropertyGroup>
<InitCommonNodeModulesStampFile>..\..\node_modules\.install-stamp</InitCommonNodeModulesStampFile>
<ESLintConfigFileTargetPath>../../.eslintrc</ESLintConfigFileTargetPath>
</PropertyGroup>
<!--
Instructions for the future if the project would target multiple frameworks:
- PreBuildEvent executes when there's only one target framework defined or when built for a specific target framework.
DispatchToInnerBuilds is executed once before the project is built for each target framework, but only when there
are more than one.
- Binding InitCommonNodeModules to run before both of those ensures that the NPM-related commands will run towards the
beginning of the build only once, so there are no concurrent processes locking each other's files.
-->
<Target Name="InitCommonNodeModules" BeforeTargets="ResolveReferences" Inputs="package.json" Outputs="$(InitCommonNodeModulesStampFile)">
<!-- Check if pnpm is installed. -->
<Exec Command="pnpm -v" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="PnpmInstalledExitCode" />
</Exec>
<!-- Use pnpm if installed. -->
<Exec Condition="'$(PnpmInstalledExitCode)' == '0'" Command="pnpm install --modules-dir ../../node_modules" />
<!-- Otherwise use regular npm. -->
<Exec Condition="'$(PnpmInstalledExitCode)' != '0'" Command="npm install" />
<RemoveDir Directories="../../node_modules" Condition="'$(PnpmInstalledExitCode)' != '0' AND Exists('node_modules') AND Exists('../../node_modules')" />
<!-- Using move command as the Move task did not complete correctly during testing in a Linux-based build pipeline.
-->
<Exec Command="move node_modules ..\..\" Condition="'$(PnpmInstalledExitCode)' != '0' AND '$(OS)' == 'Windows_NT' AND Exists('node_modules')" />
<Exec Command="mv node_modules ../../" Condition="'$(PnpmInstalledExitCode)' != '0' AND '$(OS)' != 'Windows_NT' AND Exists('node_modules')" />
<Touch Files="$(InitCommonNodeModulesStampFile)" AlwaysCreate="true" />
</Target>
<Target Name="CopyVsEslintPackage" AfterTargets="InitCommonNodeModules">
<Copy SourceFiles="ESLint/vs-eslint-package.json" DestinationFiles="../../package.json" />
</Target>
</Project>