Skip to content

Commit 5b635c9

Browse files
authored
[Infrastructure] Cleanups from the move to NPM (#52959)
* Remove Yarn references and SDK from global.json * Get package name and version from npm * Update get version target
1 parent 62fee19 commit 5b635c9

File tree

15 files changed

+49
-40
lines changed

15 files changed

+49
-40
lines changed

docs/BuildFromSource.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The steps you follow next depend on your preferred development environment:
5151

5252
## Visual Studio on Windows
5353

54-
1. This repo has JavaScript dependencies, so you need [Node.js](https://nodejs.org/en/). [Yarn](https://yarnpkg.com/) version 1.x will be installed automatically using `npm`, if you have already installed it with a version >= 2.x then you may have to uninstall it as it is not compatible with the aspnetcore build script.
54+
1. This repo has JavaScript dependencies, so you need [Node.js](https://nodejs.org/en/).
5555

5656
1. Before you open project in Visual Studio, install the required dependencies and set up the repo by running the `restore.cmd` script in the root of the repo:
5757

@@ -89,7 +89,7 @@ The steps you follow next depend on your preferred development environment:
8989
9090
1. To use Visual Studio Code for developing in this repo, you need [Visual Studio Code installed](https://code.visualstudio.com/) and the ability to [launch `code` from the command line](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line).
9191
92-
1. This repo has JavaScript dependencies, so you need [Node.js](https://nodejs.org/en/). [Yarn](https://yarnpkg.com/) version 1.x will be installed automatically using `npm`, if you have already installed it with a version >= 2.x then you may have to uninstall it as it is not compatible with the aspnetcore build script.
92+
1. This repo has JavaScript dependencies, so you need [Node.js](https://nodejs.org/en/).
9393
9494
1. Before you open anything in Visual Studio Code, run the `restore` script in the root of the repo to install the required .NET dependencies.
9595
@@ -235,5 +235,4 @@ To support building and testing the projects in the repo, several dependencies m
235235
| [Chrome](https://www.google.com/chrome/) | Required when running tests with Selenium or Playwright in the projects above. When using Playwright, the dependency is automatically installed. | |
236236
| [Java Development Kit (v11 or newer)](https://jdk.java.net/) | Required when building the Java SignalR client. Can be installed using the `./eng/scripts/InstallJdk.ps1` script on Windows. | Ensure that the `JAVA_HOME` directory points to the installation and that the `PATH` has been updated to include the `$(jdkInstallDir)/bin` folder. |
237237
| [Wix](https://wixtoolset.org/releases/) | Required when working with the Windows installers in the [Windows installers project](https://github.com/dotnet/aspnetcore/tree/main/src/Installers/Windows). | |
238-
| [Node.js](https://nodejs.org/en/) | Used for building JavaScript assets in the repo, such as those in Blazor and SignalR. | Required a minimum version of the current NodeJS LTS. |
239-
| [Yarn](https://yarnpkg.com/) | Used for installing JavaScript dependencies in the repo, such as those in Blazor and SignalR. | |
238+
| [Node.js](https://nodejs.org/en/) | Used for building JavaScript assets in the repo, such as those in Blazor and SignalR. | Required a minimum version of the current NodeJS LTS. |

eng/Build.props

-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@
137137
<ProjectToBuild Condition=" '$(BuildNodeJS)' == 'true'" Include="@(NodeJsProjects)" Exclude="@(ProjectToExclude)" />
138138
<ProjectToExclude Condition=" '$(BuildNodeJS)' != 'true'" Include="@(NodeJsProjects)" />
139139

140-
<ProjectToExclude Condition=" '$(DotNetBuildFromSource)' == 'true'" Include="@(YarnMSBuildProjects)" />
141-
142140
<JavaProjects Include="$(RepoRoot)src\SignalR\**\*.javaproj"
143141
Exclude="@(ProjectToExclude)" />
144142

eng/Npm.Workspace.nodeproj

+17
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@
3535
<Exec Command="node $(MSBuildThisFileDirectory)scripts\pack-workspace.js $(RepoRoot)package.json $(PackageVersion) $(PackageOutputPath)" />
3636
</Target>
3737

38+
<Target Name="_GetPackageVersionInfo" Returns="@(_NodePackageNameAndVersions)">
39+
<Exec Command="npm run get-version" ConsoleToMsBuild="true">
40+
<Output TaskParameter="ConsoleOutput" ItemName="_GetNpmVersionOutput" />
41+
</Exec>
42+
<ItemGroup>
43+
<_FilteredNpmVersionOuput Include="@(_GetNpmVersionOutput)" Condition="'%(Identity)' == '' or $([System.String]::Copy('%(Identity)').StartsWith('>')) " />
44+
<_NodePackageNameAndVersions Include="@(_GetNpmVersionOutput)" Exclude="@(_FilteredNpmVersionOuput)">
45+
</_NodePackageNameAndVersions>
46+
<_NodePackageNameAndVersions Condition="$([System.String]::new('%(_NodePackageNameAndVersions.Identity)').Contains(';'))">
47+
<PackageName>$([System.String]::new('%(_NodePackageNameAndVersions.Identity)').Split(';')[0])</PackageName>
48+
<PackageVersion>$([System.String]::new('%(_NodePackageNameAndVersions.Identity)').Split(';')[1])</PackageVersion>
49+
</_NodePackageNameAndVersions>
50+
</ItemGroup>
51+
52+
<Message Text="Computed package version info: %(_NodePackageNameAndVersions.PackageName)=%(_NodePackageNameAndVersions.PackageVersion)" Importance="high" />
53+
</Target>
54+
3855
<!-- Import Directory.Build.targets -->
3956
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" />
4057

eng/Publishing.props

+15-7
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@
4747
version string to use as our publish location), non-packed (won't be shipped in the future), and it is _not_ a
4848
C# or F# project. For now at least, C# and F# projects should not be referenced when using desktop msbuild.
4949
-->
50-
<MSBuild Projects="$(RepoRoot)src\SignalR\clients\ts\FunctionalTests\SignalR.Npm.FunctionalTests.nodeproj"
51-
Properties="DisableYarnCheck=true;ExcludeFromBuild=false"
50+
<MSBuild Projects="$(RepoRoot)eng\Npm.Workspace.nodeproj"
51+
Properties="ExcludeFromBuild=false"
5252
Targets="_GetPackageVersionInfo">
5353
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedPackageVersionInfo" />
5454
</MSBuild>
5555

5656
<PropertyGroup>
57+
<!-- _GetPackageVersionInfo will return all the versions for all public/shipping packages.
58+
They are all the same, so we just take the last one.
59+
If this changes in the future, we'll have to update this logic.
60+
-->
5761
<_PackageVersion>@(_ResolvedPackageVersionInfo->'%(PackageVersion)')</_PackageVersion>
5862
</PropertyGroup>
5963

@@ -101,19 +105,23 @@
101105
Name="_WriteProductVersionFile"
102106
Condition=" '$(PublishInstallerBaseVersion)' == 'true'">
103107
<!--
104-
This target is defined in eng/targets/Packaging.targets and Npm.Common.targets and included in every C#, F#,
105-
and npm project. We use Microsoft.JSInterop.JS.nodeproj because it is shipping (we need a stable
108+
This target is defined in eng/targets/Packaging.targets and Npm.Workspace.nodeproj and included in every C#, F#,
109+
and JS project. We use Microsoft.JSInterop.JS.nodeproj because it is shipping (we need a stable
106110
version string to use for productVersion.txt), and because it won't break when the SDK requires a newer
107111
desktop MSBuild than exists on the build machine.
108112
-->
109-
<MSBuild Projects="$(RepoRoot)src\JSInterop\Microsoft.JSInterop.JS\src\Microsoft.JSInterop.JS.nodeproj"
110-
Properties="DisableYarnCheck=true;ExcludeFromBuild=false"
113+
<MSBuild Projects="$(RepoRoot)eng\Npm.Workspace.nodeproj"
114+
Properties="ExcludeFromBuild=false"
111115
Targets="_GetPackageVersionInfo">
112116
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedProductVersionInfo" />
113117
</MSBuild>
114118

115119
<PropertyGroup>
116-
<_ProductVersion>@(_ResolvedProductVersionInfo->'%(PackageVersion)')</_ProductVersion>
120+
<!-- _GetPackageVersionInfo will return all the versions for all public/shipping packages.
121+
They are all the same, so we just take the last one.
122+
If this changes in the future, we'll have to update this logic.
123+
-->
124+
<_ProductVersion>%(_ResolvedProductVersionInfo.PackageVersion)</_ProductVersion>
117125
</PropertyGroup>
118126

119127
<!-- Generate productVersion.txt containing the value of $(PackageVersion) -->

eng/Tools.props

-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<Project>
2-
<ItemGroup Condition=" '$(DotNetBuildFromSource)' != 'true' ">
3-
<!--
4-
This is here to workaround flakiness in the NuGet SDK resolver in MSBuild. Arcade will run a pre-restore for
5-
these packages. This works more consistently than the SDK resolution which uses global.json. Without this
6-
here, we see regular failures with 'error MSB4236: The SDK 'Yarn.MSBuild' specified could not be found.'
7-
Since this project is evaluated before .nodeproj files are loaded, this should cause the package to end up in
8-
the NuGet cache ahead of time. This is not needed in source build.
9-
-->
10-
<PackageReference Include="Yarn.MSBuild" Version="1.22.10" />
11-
</ItemGroup>
12-
132
<!-- Update the generated files when we restore projects. Skip in desktop msbuild due to VS 16.8 requirements. -->
143
<Target Name="GenerateDirectoryBuildFiles"
154
AfterTargets="Restore"

eng/helix/helix.proj

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
-->
121121
<Target Name="IncludeAspNetRuntime" BeforeTargets="Gather">
122122
<MSBuild Projects="$(RepoRoot)src\Framework\App.Runtime\src\Microsoft.AspNetCore.App.Runtime.csproj"
123-
Properties="DisableYarnCheck=true;ExcludeFromBuild=false"
123+
Properties="ExcludeFromBuild=false"
124124
Targets="_GetPackageVersionInfo">
125125
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedProductVersionInfo" />
126126
</MSBuild>

eng/scripts/CodeCheck.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ try {
9191
}
9292

9393
#
94-
# Check for unexpected (not from dotnet-public-npm) yarn resolutions in lock files.
94+
# Check for unexpected (not from dotnet-public-npm) npm resolutions in lock files.
9595
#
9696

9797
$registry = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/'
98-
Get-ChildItem src\yarn.lock -Recurse |
98+
Get-ChildItem src\package-lock.json -Recurse |
9999
ForEach-Object FullName |
100100
Where-Object {$_ -NotLike '*\node_modules\*'} |
101101
ForEach-Object {
@@ -104,7 +104,7 @@ try {
104104
} |
105105
ForEach-Object {
106106
LogError -filePath "${_.Path}" -lineNumber $_.LineNumber `
107-
"Packages in yarn.lock file resolved from wrong registry. All dependencies must be resolved from $registry"
107+
"Packages in package-lock.json file resolved from wrong registry. All dependencies must be resolved from $registry"
108108
}
109109

110110
#

eng/targets/CSharp.Common.props

-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,4 @@
2222
</Content>
2323
</ItemDefinitionGroup>
2424

25-
<!-- Properties to control how we handle warnings when using the tasks provided by the Yarn MSBuild SDK -->
26-
<PropertyGroup>
27-
<IgnoreYarnWarnings>false</IgnoreYarnWarnings>
28-
<IgnoreYarnWarnings Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</IgnoreYarnWarnings>
29-
</PropertyGroup>
3025
</Project>

global.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"xcopy-msbuild": "17.1.0"
2727
},
2828
"msbuild-sdks": {
29-
"Yarn.MSBuild": "1.22.10",
3029
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.23619.4",
3130
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.23619.4"
3231
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"lint": "npm run lint --workspaces --if-present",
2121
"test": "npm run test --workspaces --if-present",
2222
"integration-test": "npm run integration-test --workspaces --if-present",
23-
"coverage": "npm run coverage --workspaces --if-present"
23+
"coverage": "npm run coverage --workspaces --if-present",
24+
"get-version": "npm run get-version --workspaces --if-present"
2425
},
2526
"overrides": {
2627
"got": "^11.8.2",

src/Components/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To build this specific project from source, follow the instructions [on building
3939

4040
Prior to building `src\Components\Web.JS\`
4141

42-
1. You'll need to install [Node](https://nodejs.org) and [yarn](https://yarnpkg.com) on your machine.
42+
1. You'll need to install [Node](https://nodejs.org) on your machine.
4343

4444
2. You'll need to run the `restore` script locally to install the required dotnet dependencies and setup the repo. The `restore` script is located in the root of the repo.
4545

src/JSInterop/Microsoft.JSInterop.JS/src/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"clean": "npx rimraf ./dist",
1010
"build": "npm run clean && npm run build:esm",
1111
"build:lint": "eslint -c .eslintrc.json --ext .ts ./src",
12-
"build:esm": "npx tsc --project ./tsconfig.json"
12+
"build:esm": "npx tsc --project ./tsconfig.json",
13+
"get-version": "node -e \"const { name, version } = require('./package.json'); console.log(`${name};${version}`);\""
1314
},
1415
"repository": {
1516
"type": "git",

src/SignalR/clients/ts/signalr-protocol-msgpack/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"build:esm": "tsc --project ./tsconfig.json --module es2015 --outDir ./dist/esm -d",
1919
"build:cjs": "tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs",
2020
"build:browser": "webpack-cli",
21-
"build:uglify": "terser -m -c --ecma 2019 --module --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js"
21+
"build:uglify": "terser -m -c --ecma 2019 --module --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js",
22+
"get-version": "node -e \"const { name, version } = require('./package.json'); console.log(`${name};${version}`);\""
2223
},
2324
"keywords": [
2425
"signalr",

src/SignalR/clients/ts/signalr/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"build:esm": "tsc --project ./tsconfig.json --module es2015 --outDir ./dist/esm -d",
1919
"build:cjs": "tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs",
2020
"build:browser": "webpack-cli",
21-
"build:webworker": "webpack-cli --env platform=webworker"
21+
"build:webworker": "webpack-cli --env platform=webworker",
22+
"get-version": "node -e \"const { name, version } = require('./package.json'); console.log(`${name};${version}`);\""
2223
},
2324
"keywords": [
2425
"signalr",

src/SignalR/docs/JSFunctionalTests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Our JavaScript client functional tests are written using [Jasmine](https://jasmi
1313

1414
### Iterating
1515

16-
The `npm test` command will take a while, because it will build the `clients\ts\signalr`, `clients\ts\signalr-protocol-msgpack` and `clients\ts\FunctionalTests` folders as well as `dotnet build` the `clients\ts\FunctionalTests` folder (to build the server-side components). If you are making changes, it's nice to be able to build only the things you need to build. To skip all the optional build steps, you can run `yarn run test:inner` in `clients\ts\FunctionalTests`. This will skip building `clients\ts\signalr` and `clients\signalr-protocol-msgpack` (it will still build the `clients\ts\FunctionalTests` folder). If you make changes to those libraries, you have to manually build those directories.
16+
The `npm test` command will take a while, because it will build the `clients\ts\signalr`, `clients\ts\signalr-protocol-msgpack` and `clients\ts\FunctionalTests` folders as well as `dotnet build` the `clients\ts\FunctionalTests` folder (to build the server-side components). If you are making changes, it's nice to be able to build only the things you need to build. To skip all the optional build steps, you can run `npm run test:inner` in `clients\ts\FunctionalTests`. This will skip building `clients\ts\signalr` and `clients\signalr-protocol-msgpack` (it will still build the `clients\ts\FunctionalTests` folder). If you make changes to those libraries, you have to manually build those directories.
1717

1818
## Running tests from the browser
1919

0 commit comments

Comments
 (0)