forked from dotnet/aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpm.Common.targets
More file actions
143 lines (119 loc) · 6.48 KB
/
Npm.Common.targets
File metadata and controls
143 lines (119 loc) · 6.48 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<Project DefaultTargets="Build" InitialTargets="_CheckForInvalidConfiguration">
<!-- Version of this SDK is set in global.json -->
<Sdk Name="Yarn.MSBuild" />
<PropertyGroup>
<NormalizedPackageId>$(PackageId.Replace('@','').Replace('/','-'))</NormalizedPackageId>
<PackageFileName>$(NormalizedPackageId)-$(PackageVersion).tgz</PackageFileName>
<PackageJson>$(MSBuildProjectDirectory)\package.json</PackageJson>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(MSBuildProjectDirectory)\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(BaseIntermediateOutputPath)'))$(Configuration)\</IntermediateOutputPath>
<InstallArgs>$(InstallArgs) --frozen-lockfile</InstallArgs>
<_BackupPackageJson>$(IntermediateOutputPath)$(MSBuildProjectName).package.json.bak</_BackupPackageJson>
<BuildDependsOn>
PrepareForBuild;
ResolveProjectReferences;
_Build;
</BuildDependsOn>
<NpmBuildArgs Condition="'$(NpmBuildArgs)' == ''">run build</NpmBuildArgs>
</PropertyGroup>
<ItemGroup>
<TSFiles Include="src\**\*.ts" />
<TSFiles Include="test\**\*.ts" />
<TSFiles Include="package.json" />
<TSFiles Include="*.npmproj" />
<BuildOutputFiles Include="$(BaseIntermediateOutputPath)\build-sentinel" />
<BuildOutputFiles Include="dist\**\*.js" />
</ItemGroup>
<Target Name="_CheckForInvalidConfiguration" Condition=" '$(DisableYarnCheck)' != 'true' ">
<Error Text="Missing expected property: PackageId" Condition="'$(IsPackable)' != 'false' and '$(PackageId)' == ''" />
<Exec ContinueOnError="true" Command="node -v" StandardOutputImportance="Low">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
</Exec>
<Error Text="Building *.npmproj but NodeJS was not detected on path. Ensure NodeJS is on path or disable building NodeJS projects with -noBuildNodeJS or --no-build-nodejs. Skipping NodeJS projects will also skip managed projects depending on them, including Components, Mvc and Analysers."
Condition="'$(ErrorCode)' != '0'"/>
</Target>
<Target Name="Restore">
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Restore" />
<Message Importance="High" Text="Running yarn install on $(MSBuildProjectFullPath)" />
<Yarn Command="install --mutex network $(InstallArgs) --frozen-lockfile"
StandardOutputImportance="High"
StandardErrorImportance="High"
IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
</Target>
<Target Name="PrepareForBuild">
<MakeDir Directories="$(IntermediateOutputPath);$(PackageOutputPath)" />
</Target>
<Target Name="ResolveProjectReferences">
<MSBuild Projects="@(ProjectReference)"
BuildInParallel="true" />
</Target>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)">
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Build" />
<CallTarget Targets="_Pack" Condition="'$(PackOnBuild)' == 'true'" />
</Target>
<Target Name="GetBuildInputCacheFile">
<Hash ItemsToHash="@(TSFiles)">
<Output TaskParameter="HashResult" PropertyName="_TSFileHash" />
</Hash>
<WriteLinesToFile
Lines="$(_TSFileHash)"
File="$(BaseIntermediateOutputPath)tsfiles.cache"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
</Target>
<Target Name="_Build"
Condition="'$(IsBuildable)' != 'false'"
DependsOnTargets="GetBuildInputCacheFile"
Inputs="@(TSFiles);$(BaseIntermediateOutputPath)tsfiles.cache"
Outputs="@(BuildOutputFiles)">
<Yarn Command="$(NpmBuildArgs)" StandardOutputImportance="High" StandardErrorImportance="High" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
<WriteLinesToFile Overwrite="true" File="$(BaseIntermediateOutputPath)build-sentinel" />
</Target>
<PropertyGroup>
<PackDependsOn>
$(PackDependsOn);
PrepareForBuild
</PackDependsOn>
<PackDependsOn Condition="'$(NoBuild)' != 'true'">
$(PackDependsOn);
Build;
_Pack
</PackDependsOn>
</PropertyGroup>
<Target Name="_Pack" Condition="'$(IsPackable)' == 'true'"
Inputs="@(TSFiles)"
Outputs="$(PackageOutputPath)\$(PackageFileName)">
<PropertyGroup>
<_PackageTargetPath>$(MSBuildProjectDirectory)\$(PackageFileName)</_PackageTargetPath>
</PropertyGroup>
<Copy SourceFiles="$(PackageJson)" DestinationFiles="$(_BackupPackageJson)" />
<Yarn Command="version --no-git-tag-version --new-version $(PackageVersion)" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
<Exec Command="node "$(MSBuildThisFileDirectory)..\scripts\update-packagejson-links.js" "$(PackageJson)" $(PackageVersion)" />
<Yarn Command="pack --filename $(PackageFileName)" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
<Move SourceFiles="$(_PackageTargetPath)" DestinationFolder="$(PackageOutputPath)" />
<Message Importance="High" Text="$(MSBuildProjectName) -> $(_PackageTargetPath)" />
<CallTarget Targets="_RestoreBackupPackageJsonFile" />
<OnError ExecuteTargets="_RestoreBackupPackageJsonFile" />
</Target>
<Target Name="Pack" Condition="'$(IsPackable)' == 'true'" DependsOnTargets="$(PackDependsOn)" />
<!-- This target is used to get the package versions of projects. A variant also exists in Packaging.targets. -->
<Target Name="_GetPackageVersionInfo" Returns="@(_ProjectPathWithVersion)">
<ItemGroup>
<_ProjectPathWithVersion Include="$(MSBuildProjectFullPath)">
<PackageId>$(PackageId)</PackageId>
<PackageVersion>$(PackageVersionForPackageVersionInfo)</PackageVersion>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<!-- Fill in the item though variable names like "@microsoft/signalrVersion" are likely invalid. -->
<VersionVariableName>$(PackageId.Replace('.',''))dVersion</VersionVariableName>
</_ProjectPathWithVersion>
</ItemGroup>
</Target>
<Target Name="_RestoreBackupPackageJsonFile">
<Move SourceFiles="$(_BackupPackageJson)" DestinationFiles="$(PackageJson)" />
</Target>
<Target Name="Test" Condition=" $(IsTestProject) AND '$(SkipTests)' != 'true'">
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
<Message Importance="High" Text="Running npm tests for $(MSBuildProjectName)" />
<Yarn Command="$(NpmTestArgs)" StandardOutputImportance="High" StandardErrorImportance="High" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
</Target>
</Project>