-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLombiq.Gulp.Extensions.csproj
More file actions
65 lines (58 loc) · 3.83 KB
/
Lombiq.Gulp.Extensions.csproj
File metadata and controls
65 lines (58 loc) · 3.83 KB
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
<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>
<!-- This target ensures that pnpm version 7 is used instead of any newer version. You can opt out of this behavior by
setting the property "PreventPnpm7" to "true", e.g. in a Directory.Build.props file above this project. -->
<Target Name="ActivatePnpmVersion7" BeforeTargets="InitCommonNodeModules" Condition="'$(PreventPnpm7)' != 'true'">
<!-- Corepack is a Node.js tool available since v14.9.0 and v16.9.0. In case this command fails, we assume that it
fails due to running on an older Node.js version, in which case we don't care about the pnpm version. -->
<Exec Command="corepack enable" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true">
<Output TaskParameter="ExitCode" PropertyName="CorepackExitCode" />
</Exec>
<!-- Enable the latest version of pnpm@7 in case "corepack enable" executed successfully. -->
<Exec Command="corepack prepare pnpm@7.30.5 --activate" Condition="'$(CorepackExitCode)' == '0'" />
</Target>
<!--
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>