mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Compare commits
81 Commits
rel/2.0.0-
...
2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c84e35392 | ||
|
|
6ba3014c57 | ||
|
|
7d30f2bbc3 | ||
|
|
424e5ed91a | ||
|
|
8ddacb8b73 | ||
|
|
2c81117b4b | ||
|
|
4d151a599e | ||
|
|
78f7dccfab | ||
|
|
7f550fb469 | ||
|
|
087a459c9c | ||
|
|
f22297a4db | ||
|
|
61b4951961 | ||
|
|
02beb11a5c | ||
|
|
c42db123bd | ||
|
|
04b8c17bdd | ||
|
|
8583f205f9 | ||
|
|
e6af1b892e | ||
|
|
24766621e1 | ||
|
|
ae4c4d6e8f | ||
|
|
8553647ce8 | ||
|
|
67560266ab | ||
|
|
ce49379afb | ||
|
|
4dc05d96ac | ||
|
|
53742ad649 | ||
|
|
91a1d83acd | ||
|
|
1d504e4565 | ||
|
|
873cfa9adf | ||
|
|
41b8642c2d | ||
|
|
d6b67ca75d | ||
|
|
4af70a0907 | ||
|
|
bf5f40b1ed | ||
|
|
a515f6bb0a | ||
|
|
12a2314a5e | ||
|
|
f35c814fc7 | ||
|
|
dbaa453d18 | ||
|
|
b2373e157e | ||
|
|
08c2f231ea | ||
|
|
6274733565 | ||
|
|
5f6f288056 | ||
|
|
78e583d0fb | ||
|
|
7c07beb494 | ||
|
|
e7ffb8bb71 | ||
|
|
3e6f7f3e45 | ||
|
|
0d83504863 | ||
|
|
370b5f7341 | ||
|
|
0b53b92bc6 | ||
|
|
116f33c66c | ||
|
|
c3964a0437 | ||
|
|
f291f87dfc | ||
|
|
a1c2c18326 | ||
|
|
d6588c31bf | ||
|
|
15d2f5a898 | ||
|
|
814441c933 | ||
|
|
a98c1459b5 | ||
|
|
975d537a0a | ||
|
|
4af2e8670e | ||
|
|
160c91f1b9 | ||
|
|
8ded472fe9 | ||
|
|
f9c62ebb5a | ||
|
|
d5a664e481 | ||
|
|
74512dc3b2 | ||
|
|
e6285f30ae | ||
|
|
bd5793e284 | ||
|
|
02bbcb68f1 | ||
|
|
18140929e7 | ||
|
|
50ba6114ee | ||
|
|
cd3e3c667c | ||
|
|
0de9f0e3ce | ||
|
|
9b1509a52b | ||
|
|
a8809f9a96 | ||
|
|
64389a9bbe | ||
|
|
86e94d7812 | ||
|
|
9f05a3d34b | ||
|
|
63e0af2ee8 | ||
|
|
dc5e980efa | ||
|
|
e0ab3ddcca | ||
|
|
0c058894c2 | ||
|
|
98385cbcb0 | ||
|
|
77cac3b6be | ||
|
|
051150475f | ||
|
|
128683be0e |
@@ -1,21 +1,19 @@
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
- git config --global core.autocrlf true
|
||||
install:
|
||||
- ps: Install-Product node 6.9.2 x64
|
||||
- ps: Install-Product node 6.9.2 x64
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- release
|
||||
- dev
|
||||
- /^(.*\/)?ci-.*$/
|
||||
- /^rel\/.*/
|
||||
- dev
|
||||
- /^release\/.*$/
|
||||
- /^(.*\/)?ci-.*$/
|
||||
build_script:
|
||||
- ps: .\run.ps1 default-build
|
||||
- ps: .\run.ps1 default-build
|
||||
clone_depth: 1
|
||||
environment:
|
||||
global:
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
test: off
|
||||
deploy: off
|
||||
test: 'off'
|
||||
deploy: 'off'
|
||||
os: Visual Studio 2017
|
||||
|
||||
11
.travis.yml
11
.travis.yml
@@ -12,8 +12,13 @@ addons:
|
||||
- zlib1g
|
||||
mono: none
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
- linux
|
||||
- osx
|
||||
osx_image: xcode7.1
|
||||
script:
|
||||
- ./build.sh
|
||||
- ./build.sh
|
||||
branches:
|
||||
only:
|
||||
- dev
|
||||
- /^release\/.*$/
|
||||
- /^(.*\/)?ci-.*$/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<Project>
|
||||
<Import Project="version.props" />
|
||||
<Import Project="build\dependencies.props" />
|
||||
<Import Project="build\sources.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Product>Microsoft ASP.NET Core</Product>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(MicrosoftNETCoreApp20PackageVersion)</RuntimeFrameworkVersion>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">$(MicrosoftNETCoreApp21PackageVersion)</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">$(NETStandardLibrary20PackageVersion)</NETStandardImplicitPackageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
|
||||
<add key="AspNetCoreTools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
<!-- Restore sources should be defined in build/sources.props. -->
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
||||
7
NuGetPackageVerifier.json
Normal file
7
NuGetPackageVerifier.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"Default": {
|
||||
"rules": [
|
||||
"DefaultCompositeRule"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,28 @@
|
||||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Package Versions">
|
||||
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-15549</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreMvcPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcTagHelpersPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreMvcTagHelpersPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftAspNetCoreWebSocketsPackageVersion>2.1.0-preview1-27478</MicrosoftAspNetCoreWebSocketsPackageVersion>
|
||||
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-preview1-27478</MicrosoftExtensionsDependencyInjectionPackageVersion>
|
||||
<MicrosoftExtensionsFileProvidersPhysicalPackageVersion>2.1.0-preview1-27478</MicrosoftExtensionsFileProvidersPhysicalPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-27478</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview1-27478</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<InternalAspNetCoreSdkPackageVersion>2.1.0-rtm-15783</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreMvcPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcTagHelpersPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreMvcTagHelpersPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftAspNetCoreWebSocketsPackageVersion>2.1.0-rtm-30721</MicrosoftAspNetCoreWebSocketsPackageVersion>
|
||||
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-rtm-30721</MicrosoftExtensionsDependencyInjectionPackageVersion>
|
||||
<MicrosoftExtensionsFileProvidersPhysicalPackageVersion>2.1.0-rtm-30721</MicrosoftExtensionsFileProvidersPhysicalPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-rtm-30721</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-rtm-30721</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||
<NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion>
|
||||
<SystemThreadingTasksDataflowPackageVersion>4.8.0</SystemThreadingTasksDataflowPackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.0-rtm-26502-02</MicrosoftNETCoreApp21PackageVersion>
|
||||
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
||||
<NewtonsoftJsonPackageVersion>11.0.2</NewtonsoftJsonPackageVersion>
|
||||
<SystemThreadingTasksDataflowPackageVersion>4.9.0-rtm-26502-02</SystemThreadingTasksDataflowPackageVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<Project>
|
||||
<Project>
|
||||
<Import Project="dependencies.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- These properties are use by the automation that updates dependencies.props -->
|
||||
<LineupPackageId>Internal.AspNetCore.Universe.Lineup</LineupPackageId>
|
||||
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json</LineupPackageRestoreSource>
|
||||
<LineupPackageVersion>2.1.0-rc1-*</LineupPackageVersion>
|
||||
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json</LineupPackageRestoreSource>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp20PackageVersion)" />
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp21PackageVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
17
build/sources.props
Normal file
17
build/sources.props
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project>
|
||||
<Import Project="$(DotNetRestoreSourcePropsPath)" Condition="'$(DotNetRestoreSourcePropsPath)' != ''"/>
|
||||
|
||||
<PropertyGroup Label="RestoreSources">
|
||||
<RestoreSources>$(DotNetRestoreSources)</RestoreSources>
|
||||
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true' AND '$(AspNetUniverseBuildOffline)' != 'true' ">
|
||||
$(RestoreSources);
|
||||
https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
|
||||
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
|
||||
https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json;
|
||||
</RestoreSources>
|
||||
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
|
||||
$(RestoreSources);
|
||||
https://api.nuget.org/v3/index.json;
|
||||
</RestoreSources>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,2 +1,2 @@
|
||||
version:2.1.0-preview1-15549
|
||||
commithash:f570e08585fec510dd60cd4bfe8795388b757a95
|
||||
version:2.1.0-rtm-15783
|
||||
commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json",
|
||||
"channel": "dev",
|
||||
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json",
|
||||
"channel": "release/2.1",
|
||||
"toolsets": {
|
||||
"nodejs": {
|
||||
"required": true,
|
||||
|
||||
17
run.ps1
17
run.ps1
@@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present.
|
||||
.PARAMETER ConfigFile
|
||||
The path to the configuration file that stores values. Defaults to korebuild.json.
|
||||
|
||||
.PARAMETER ToolsSourceSuffix
|
||||
The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores.
|
||||
|
||||
.PARAMETER Arguments
|
||||
Arguments to be passed to the command
|
||||
|
||||
@@ -51,7 +54,7 @@ Example config file:
|
||||
#>
|
||||
[CmdletBinding(PositionalBinding = $false)]
|
||||
param(
|
||||
[Parameter(Mandatory=$true, Position = 0)]
|
||||
[Parameter(Mandatory = $true, Position = 0)]
|
||||
[string]$Command,
|
||||
[string]$Path = $PSScriptRoot,
|
||||
[Alias('c')]
|
||||
@@ -63,6 +66,7 @@ param(
|
||||
[Alias('u')]
|
||||
[switch]$Update,
|
||||
[string]$ConfigFile,
|
||||
[string]$ToolsSourceSuffix,
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[string[]]$Arguments
|
||||
)
|
||||
@@ -79,7 +83,7 @@ function Get-KoreBuild {
|
||||
$lockFile = Join-Path $Path 'korebuild-lock.txt'
|
||||
|
||||
if (!(Test-Path $lockFile) -or $Update) {
|
||||
Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile
|
||||
Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix
|
||||
}
|
||||
|
||||
$version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1
|
||||
@@ -96,7 +100,7 @@ function Get-KoreBuild {
|
||||
|
||||
try {
|
||||
$tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip"
|
||||
Get-RemoteFile $remotePath $tmpfile
|
||||
Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix
|
||||
if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) {
|
||||
# Use built-in commands where possible as they are cross-plat compatible
|
||||
Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath
|
||||
@@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) {
|
||||
return $path
|
||||
}
|
||||
|
||||
function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
|
||||
function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) {
|
||||
if ($RemotePath -notlike 'http*') {
|
||||
Copy-Item $RemotePath $LocalPath
|
||||
return
|
||||
@@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
|
||||
while ($retries -gt 0) {
|
||||
$retries -= 1
|
||||
try {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath
|
||||
return
|
||||
}
|
||||
catch {
|
||||
@@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) {
|
||||
if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel }
|
||||
if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
Write-Warning "$ConfigFile could not be read. Its settings will be ignored."
|
||||
Write-Warning $Error[0]
|
||||
}
|
||||
|
||||
30
run.sh
30
run.sh
@@ -17,6 +17,7 @@ update=false
|
||||
repo_path="$DIR"
|
||||
channel=''
|
||||
tools_source=''
|
||||
tools_source_suffix=''
|
||||
|
||||
#
|
||||
# Functions
|
||||
@@ -29,13 +30,14 @@ __usage() {
|
||||
echo " <Arguments>... Arguments passed to the command. Variable number of arguments allowed."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --verbose Show verbose output."
|
||||
echo " -c|--channel <CHANNEL> The channel of KoreBuild to download. Overrides the value from the config file.."
|
||||
echo " --config-file <FILE> The path to the configuration file that stores values. Defaults to korebuild.json."
|
||||
echo " -d|--dotnet-home <DIR> The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet."
|
||||
echo " --path <PATH> The directory to build. Defaults to the directory containing the script."
|
||||
echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
|
||||
echo " -u|--update Update to the latest KoreBuild even if the lock file is present."
|
||||
echo " --verbose Show verbose output."
|
||||
echo " -c|--channel <CHANNEL> The channel of KoreBuild to download. Overrides the value from the config file.."
|
||||
echo " --config-file <FILE> The path to the configuration file that stores values. Defaults to korebuild.json."
|
||||
echo " -d|--dotnet-home <DIR> The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet."
|
||||
echo " --path <PATH> The directory to build. Defaults to the directory containing the script."
|
||||
echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
|
||||
echo " --tools-source-suffix|-ToolsSourceSuffix <SUFFIX> The suffix to append to tools-source. Useful for query strings."
|
||||
echo " -u|--update Update to the latest KoreBuild even if the lock file is present."
|
||||
echo ""
|
||||
echo "Description:"
|
||||
echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be."
|
||||
@@ -50,7 +52,7 @@ get_korebuild() {
|
||||
local version
|
||||
local lock_file="$repo_path/korebuild-lock.txt"
|
||||
if [ ! -f "$lock_file" ] || [ "$update" = true ]; then
|
||||
__get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file"
|
||||
__get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix"
|
||||
fi
|
||||
version="$(grep 'version:*' -m 1 "$lock_file")"
|
||||
if [[ "$version" == '' ]]; then
|
||||
@@ -66,7 +68,7 @@ get_korebuild() {
|
||||
local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip"
|
||||
tmpfile="$(mktemp)"
|
||||
echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}"
|
||||
if __get_remote_file "$remote_path" "$tmpfile"; then
|
||||
if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then
|
||||
unzip -q -d "$korebuild_path" "$tmpfile"
|
||||
fi
|
||||
rm "$tmpfile" || true
|
||||
@@ -98,6 +100,7 @@ __machine_has() {
|
||||
__get_remote_file() {
|
||||
local remote_path=$1
|
||||
local local_path=$2
|
||||
local remote_path_suffix=$3
|
||||
|
||||
if [[ "$remote_path" != 'http'* ]]; then
|
||||
cp "$remote_path" "$local_path"
|
||||
@@ -106,14 +109,14 @@ __get_remote_file() {
|
||||
|
||||
local failed=false
|
||||
if __machine_has wget; then
|
||||
wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true
|
||||
wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true
|
||||
else
|
||||
failed=true
|
||||
fi
|
||||
|
||||
if [ "$failed" = true ] && __machine_has curl; then
|
||||
failed=false
|
||||
curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true
|
||||
curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true
|
||||
fi
|
||||
|
||||
if [ "$failed" = true ]; then
|
||||
@@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do
|
||||
tools_source="${1:-}"
|
||||
[ -z "$tools_source" ] && __usage
|
||||
;;
|
||||
--tools-source-suffix|-ToolsSourceSuffix)
|
||||
shift
|
||||
tools_source_suffix="${1:-}"
|
||||
[ -z "$tools_source_suffix" ] && __usage
|
||||
;;
|
||||
-u|--update|-Update)
|
||||
update=true
|
||||
;;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
<OutputType>exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
|
||||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
|
||||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -14,8 +14,7 @@ namespace Microsoft.AspNetCore.NodeServices.Sockets
|
||||
/// <summary>
|
||||
/// A specialisation of the OutOfProcessNodeInstance base class that uses a lightweight binary streaming protocol
|
||||
/// to perform RPC invocations. The physical transport is Named Pipes on Windows, or Domain Sockets on Linux/Mac.
|
||||
/// For details on the binary streaming protocol, see
|
||||
/// Microsoft.AspNetCore.NodeServices.HostingModels.VirtualConnections.VirtualConnectionClient.
|
||||
/// For details on the binary streaming protocol, see <see cref="Microsoft.AspNetCore.NodeServices.Sockets.VirtualConnections.VirtualConnectionClient" />
|
||||
/// The advantage versus using HTTP for RPC is that this is faster (not surprisingly - there's much less overhead
|
||||
/// because we don't need most of the functionality of HTTP.
|
||||
///
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.NodeServices.Sockets, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.Sockets.NodeServicesOptionsExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseSocketHosting",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "options",
|
||||
"Type": "Microsoft.AspNetCore.NodeServices.NodeServicesOptions"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.Sockets.VirtualConnections.VirtualConnectionReadErrorHandler",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Sealed": true,
|
||||
"BaseType": "System.MulticastDelegate",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Invoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "ex",
|
||||
"Type": "System.Exception"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "BeginInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "ex",
|
||||
"Type": "System.Exception"
|
||||
},
|
||||
{
|
||||
"Name": "callback",
|
||||
"Type": "System.AsyncCallback"
|
||||
},
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.IAsyncResult",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "EndInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "result",
|
||||
"Type": "System.IAsyncResult"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "method",
|
||||
"Type": "System.IntPtr"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -121,8 +121,8 @@
|
||||
var parsedArgs = ArgsUtil_1.parseArgs(process.argv);
|
||||
var requestedPortOrZero = parsedArgs.port || 0; // 0 means 'let the OS decide'
|
||||
server.listen(requestedPortOrZero, 'localhost', function () {
|
||||
// Signal to HttpNodeHost which port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port ' + server.address().port + '\]');
|
||||
// Signal to HttpNodeHost which loopback IP address (IPv4 or IPv6) and port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on {' + server.address().address + '} port ' + server.address().port + '\]');
|
||||
// Signal to the NodeServices base class that we're ready to accept invocations
|
||||
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
||||
});
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
/// <seealso cref="Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance" />
|
||||
internal class HttpNodeInstance : OutOfProcessNodeInstance
|
||||
{
|
||||
private static readonly Regex PortMessageRegex =
|
||||
new Regex(@"^\[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port (\d+)\]$");
|
||||
private static readonly Regex EndpointMessageRegex =
|
||||
new Regex(@"^\[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on {(.*?)} port (\d+)\]$");
|
||||
|
||||
private static readonly JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
|
||||
private readonly HttpClient _client;
|
||||
private bool _disposed;
|
||||
private int _portNumber;
|
||||
private string _endpoint;
|
||||
|
||||
public HttpNodeInstance(NodeServicesOptions options, int port = 0)
|
||||
: base(
|
||||
@@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
{
|
||||
var payloadJson = JsonConvert.SerializeObject(invocationInfo, jsonSerializerSettings);
|
||||
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
|
||||
var response = await _client.PostAsync("http://localhost:" + _portNumber, payload, cancellationToken);
|
||||
var response = await _client.PostAsync(_endpoint, payload, cancellationToken);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -111,13 +111,19 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
|
||||
protected override void OnOutputDataReceived(string outputData)
|
||||
{
|
||||
// Watch for "port selected" messages, and when observed, store the port number
|
||||
// Watch for "port selected" messages, and when observed,
|
||||
// store the IP (IPv4/IPv6) and port number
|
||||
// so we can use it when making HTTP requests. The child process will always send
|
||||
// one of these messages before it sends a "ready for connections" message.
|
||||
var match = _portNumber != 0 ? null : PortMessageRegex.Match(outputData);
|
||||
var match = string.IsNullOrEmpty(_endpoint) ? EndpointMessageRegex.Match(outputData) : null;
|
||||
if (match != null && match.Success)
|
||||
{
|
||||
_portNumber = int.Parse(match.Groups[1].Captures[0].Value);
|
||||
var port = int.Parse(match.Groups[2].Captures[0].Value);
|
||||
var resolvedIpAddress = match.Groups[1].Captures[0].Value;
|
||||
|
||||
//IPv6 must be wrapped with [] brackets
|
||||
resolvedIpAddress = resolvedIpAddress == "::1" ? $"[{resolvedIpAddress}]" : resolvedIpAddress;
|
||||
_endpoint = $"http://{resolvedIpAddress}:{port}";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -70,8 +70,8 @@ const server = http.createServer((req, res) => {
|
||||
const parsedArgs = parseArgs(process.argv);
|
||||
const requestedPortOrZero = parsedArgs.port || 0; // 0 means 'let the OS decide'
|
||||
server.listen(requestedPortOrZero, 'localhost', function () {
|
||||
// Signal to HttpNodeHost which port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port ' + server.address().port + '\]');
|
||||
// Signal to HttpNodeHost which loopback IP address (IPv4 or IPv6) and port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on {' + server.address().address + '} port ' + server.address().port + '\]');
|
||||
|
||||
// Signal to the NodeServices base class that we're ready to accept invocations
|
||||
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
||||
|
||||
935
src/Microsoft.AspNetCore.NodeServices/baseline.netcore.json
Normal file
935
src/Microsoft.AspNetCore.NodeServices/baseline.netcore.json
Normal file
@@ -0,0 +1,935 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.NodeServices, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.Extensions.DependencyInjection.NodeServicesServiceCollectionExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "AddNodeServices",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "serviceCollection",
|
||||
"Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "AddNodeServices",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "serviceCollection",
|
||||
"Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection"
|
||||
},
|
||||
{
|
||||
"Name": "setupAction",
|
||||
"Type": "System.Action<Microsoft.AspNetCore.NodeServices.NodeServicesOptions>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.NodeServicesFactory",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "CreateNodeServices",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "options",
|
||||
"Type": "Microsoft.AspNetCore.NodeServices.NodeServicesOptions"
|
||||
}
|
||||
],
|
||||
"ReturnType": "Microsoft.AspNetCore.NodeServices.INodeServices",
|
||||
"Static": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.NodeServicesOptions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_NodeInstanceFactory",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Func<Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance>",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_NodeInstanceFactory",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Func<Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ProjectPath",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ProjectPath",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_WatchFileExtensions",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String[]",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_WatchFileExtensions",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String[]"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_NodeInstanceOutputLogger",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.Extensions.Logging.ILogger",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_NodeInstanceOutputLogger",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "Microsoft.Extensions.Logging.ILogger"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_LaunchWithDebugging",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Boolean",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_LaunchWithDebugging",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Boolean"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_DebuggingPort",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Int32",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_DebuggingPort",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Int32"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_EnvironmentVariables",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Collections.Generic.IDictionary<System.String, System.String>",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_EnvironmentVariables",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Collections.Generic.IDictionary<System.String, System.String>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_InvocationTimeoutMilliseconds",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Int32",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_InvocationTimeoutMilliseconds",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Int32"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ApplicationStoppingToken",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Threading.CancellationToken",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ApplicationStoppingToken",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "serviceProvider",
|
||||
"Type": "System.IServiceProvider"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.INodeServices",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Interface",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [
|
||||
"System.IDisposable"
|
||||
],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "args",
|
||||
"Type": "System.Object[]",
|
||||
"IsParams": true
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "cancellationToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
},
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "args",
|
||||
"Type": "System.Object[]",
|
||||
"IsParams": true
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "exportedFunctionName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "args",
|
||||
"Type": "System.Object[]",
|
||||
"IsParams": true
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "cancellationToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
},
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "exportedFunctionName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "args",
|
||||
"Type": "System.Object[]",
|
||||
"IsParams": true
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.EmbeddedResourceReader",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Read",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "assemblyContainingType",
|
||||
"Type": "System.Type"
|
||||
},
|
||||
{
|
||||
"Name": "path",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.String",
|
||||
"Static": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.StringAsTempFile",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [
|
||||
"System.IDisposable"
|
||||
],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_FileName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Dispose",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Sealed": true,
|
||||
"Virtual": true,
|
||||
"ImplementedInterface": "System.IDisposable",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Finalize",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Override": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "content",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "applicationStoppingToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Interface",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [
|
||||
"System.IDisposable"
|
||||
],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "cancellationToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
},
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "exportNameOrNull",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "args",
|
||||
"Type": "System.Object[]",
|
||||
"IsParams": true
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"BaseType": "System.Exception",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_NodeInstanceUnavailable",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Boolean",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_AllowConnectionDraining",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Boolean",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "message",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "details",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "message",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "details",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "nodeInstanceUnavailable",
|
||||
"Type": "System.Boolean"
|
||||
},
|
||||
{
|
||||
"Name": "allowConnectionDraining",
|
||||
"Type": "System.Boolean"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationInfo",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ModuleName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ModuleName",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ExportedFunctionName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ExportedFunctionName",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_Args",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Object[]",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_Args",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Object[]"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.HostingModels.NodeServicesOptionsExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseHttpHosting",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "options",
|
||||
"Type": "Microsoft.AspNetCore.NodeServices.NodeServicesOptions"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [
|
||||
"Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance"
|
||||
],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "cancellationToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
},
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "exportNameOrNull",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "args",
|
||||
"Type": "System.Object[]",
|
||||
"IsParams": true
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"Sealed": true,
|
||||
"Virtual": true,
|
||||
"ImplementedInterface": "Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Dispose",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Sealed": true,
|
||||
"Virtual": true,
|
||||
"ImplementedInterface": "System.IDisposable",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "invocationInfo",
|
||||
"Type": "Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationInfo"
|
||||
},
|
||||
{
|
||||
"Name": "cancellationToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<T0>",
|
||||
"Virtual": true,
|
||||
"Abstract": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": [
|
||||
{
|
||||
"ParameterName": "T",
|
||||
"ParameterPosition": 0,
|
||||
"BaseTypeOrInterfaces": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "PrepareNodeProcessStartInfo",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "entryPointFilename",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "projectPath",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "commandLineArguments",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "environmentVars",
|
||||
"Type": "System.Collections.Generic.IDictionary<System.String, System.String>"
|
||||
},
|
||||
{
|
||||
"Name": "launchWithDebugging",
|
||||
"Type": "System.Boolean"
|
||||
},
|
||||
{
|
||||
"Name": "debuggingPort",
|
||||
"Type": "System.Int32"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Diagnostics.ProcessStartInfo",
|
||||
"Virtual": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "OnOutputDataReceived",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "outputData",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "OnErrorDataReceived",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "errorData",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Dispose",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "disposing",
|
||||
"Type": "System.Boolean"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Finalize",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Override": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "entryPointScript",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "projectPath",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "watchFileExtensions",
|
||||
"Type": "System.String[]"
|
||||
},
|
||||
{
|
||||
"Name": "commandLineArguments",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "applicationStoppingToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
},
|
||||
{
|
||||
"Name": "nodeOutputLogger",
|
||||
"Type": "Microsoft.Extensions.Logging.ILogger"
|
||||
},
|
||||
{
|
||||
"Name": "environmentVars",
|
||||
"Type": "System.Collections.Generic.IDictionary<System.String, System.String>"
|
||||
},
|
||||
{
|
||||
"Name": "invocationTimeoutMilliseconds",
|
||||
"Type": "System.Int32"
|
||||
},
|
||||
{
|
||||
"Name": "launchWithDebugging",
|
||||
"Type": "System.Boolean"
|
||||
},
|
||||
{
|
||||
"Name": "debuggingPort",
|
||||
"Type": "System.Int32"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Field",
|
||||
"Name": "OutputLogger",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.Extensions.Logging.ILogger",
|
||||
"ReadOnly": true,
|
||||
"Visibility": "Protected",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -20,7 +20,6 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
public class AngularCliBuilder : ISpaPrerendererBuilder
|
||||
{
|
||||
private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine
|
||||
private static TimeSpan BuildTimeout = TimeSpan.FromSeconds(50); // Note that the HTTP request itself by default times out after 60s, so you only get useful error information if this is shorter
|
||||
|
||||
private readonly string _npmScriptName;
|
||||
|
||||
@@ -39,7 +38,7 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task Build(ISpaBuilder spaBuilder)
|
||||
public async Task Build(ISpaBuilder spaBuilder)
|
||||
{
|
||||
var sourcePath = spaBuilder.Options.SourcePath;
|
||||
if (string.IsNullOrEmpty(sourcePath))
|
||||
@@ -57,18 +56,26 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
null);
|
||||
npmScriptRunner.AttachToLogger(logger);
|
||||
|
||||
using (var stdOutReader = new EventedStreamStringReader(npmScriptRunner.StdOut))
|
||||
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))
|
||||
{
|
||||
try
|
||||
{
|
||||
return npmScriptRunner.StdOut.WaitForMatch(
|
||||
new Regex("chunk", RegexOptions.None, RegexMatchTimeout),
|
||||
BuildTimeout);
|
||||
await npmScriptRunner.StdOut.WaitForMatch(
|
||||
new Regex("Date", RegexOptions.None, RegexMatchTimeout));
|
||||
}
|
||||
catch (EndOfStreamException ex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"The NPM script '{_npmScriptName}' exited without indicating success. " +
|
||||
$"The NPM script '{_npmScriptName}' exited without indicating success.\n" +
|
||||
$"Output was: {stdOutReader.ReadAsString()}\n" +
|
||||
$"Error output was: {stdErrReader.ReadAsString()}", ex);
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"The NPM script '{_npmScriptName}' timed out without indicating success. " +
|
||||
$"Output was: {stdOutReader.ReadAsString()}\n" +
|
||||
$"Error output was: {stdErrReader.ReadAsString()}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
{
|
||||
@@ -17,7 +20,6 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
{
|
||||
private const string LogCategoryName = "Microsoft.AspNetCore.SpaServices";
|
||||
private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine
|
||||
private static TimeSpan StartupTimeout = TimeSpan.FromSeconds(50); // Note that the HTTP request itself by default times out after 60s, so you only get useful error information if this is shorter
|
||||
|
||||
public static void Attach(
|
||||
ISpaBuilder spaBuilder,
|
||||
@@ -47,7 +49,16 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
var targetUriTask = angularCliServerInfoTask.ContinueWith(
|
||||
task => new UriBuilder("http", "localhost", task.Result.Port).Uri);
|
||||
|
||||
SpaProxyingExtensions.UseProxyToSpaDevelopmentServer(spaBuilder, targetUriTask);
|
||||
SpaProxyingExtensions.UseProxyToSpaDevelopmentServer(spaBuilder, () =>
|
||||
{
|
||||
// On each request, we create a separate startup task with its own timeout. That way, even if
|
||||
// the first request times out, subsequent requests could still work.
|
||||
var timeout = spaBuilder.Options.StartupTimeout;
|
||||
return targetUriTask.WithTimeout(timeout,
|
||||
$"The Angular CLI process did not start listening for requests " +
|
||||
$"within the timeout period of {timeout.Seconds} seconds. " +
|
||||
$"Check the log output for error information.");
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<AngularCliServerInfo> StartAngularCliServerAsync(
|
||||
@@ -66,8 +77,7 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
try
|
||||
{
|
||||
openBrowserLine = await npmScriptRunner.StdOut.WaitForMatch(
|
||||
new Regex("open your browser on (http\\S+)", RegexOptions.None, RegexMatchTimeout),
|
||||
StartupTimeout);
|
||||
new Regex("open your browser on (http\\S+)", RegexOptions.None, RegexMatchTimeout));
|
||||
}
|
||||
catch (EndOfStreamException ex)
|
||||
{
|
||||
@@ -76,26 +86,57 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
$"Angular CLI was listening for requests. The error output was: " +
|
||||
$"{stdErrReader.ReadAsString()}", ex);
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"The Angular CLI process did not start listening for requests " +
|
||||
$"within the timeout period of {StartupTimeout.Seconds} seconds. " +
|
||||
$"Check the log output for error information.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
var uri = new Uri(openBrowserLine.Groups[1].Value);
|
||||
var serverInfo = new AngularCliServerInfo { Port = uri.Port };
|
||||
|
||||
// Even after the Angular CLI claims to be listening for requests, there's a short
|
||||
// period where it will give an error if you make a request too quickly. Give it
|
||||
// a moment to finish starting up.
|
||||
await Task.Delay(500);
|
||||
// period where it will give an error if you make a request too quickly
|
||||
await WaitForAngularCliServerToAcceptRequests(uri);
|
||||
|
||||
return serverInfo;
|
||||
}
|
||||
|
||||
private static async Task WaitForAngularCliServerToAcceptRequests(Uri cliServerUri)
|
||||
{
|
||||
// To determine when it's actually ready, try making HEAD requests to '/'. If it
|
||||
// produces any HTTP response (even if it's 404) then it's ready. If it rejects the
|
||||
// connection then it's not ready. We keep trying forever because this is dev-mode
|
||||
// only, and only a single startup attempt will be made, and there's a further level
|
||||
// of timeouts enforced on a per-request basis.
|
||||
var timeoutMilliseconds = 1000;
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If we get any HTTP response, the CLI server is ready
|
||||
await client.SendAsync(
|
||||
new HttpRequestMessage(HttpMethod.Head, cliServerUri),
|
||||
new CancellationTokenSource(timeoutMilliseconds).Token);
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
|
||||
// Depending on the host's networking configuration, the requests can take a while
|
||||
// to go through, most likely due to the time spent resolving 'localhost'.
|
||||
// Each time we have a failure, allow a bit longer next time (up to a maximum).
|
||||
// This only influences the time until we regard the dev server as 'ready', so it
|
||||
// doesn't affect the runtime perf (even in dev mode) once the first connection is made.
|
||||
// Resolves https://github.com/aspnet/JavaScriptServices/issues/1611
|
||||
if (timeoutMilliseconds < 10000)
|
||||
{
|
||||
timeoutMilliseconds += 3000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AngularCliServerInfo
|
||||
{
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.NodeServices;
|
||||
using Microsoft.AspNetCore.SpaServices;
|
||||
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
|
||||
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
@@ -68,6 +69,7 @@ namespace Microsoft.AspNetCore.Builder
|
||||
var excludePathStrings = (options.ExcludeUrls ?? Array.Empty<string>())
|
||||
.Select(url => new PathString(url))
|
||||
.ToArray();
|
||||
var buildTimeout = spaBuilder.Options.StartupTimeout;
|
||||
|
||||
applicationBuilder.Use(async (context, next) =>
|
||||
{
|
||||
@@ -85,9 +87,15 @@ namespace Microsoft.AspNetCore.Builder
|
||||
}
|
||||
|
||||
// If we're building on demand, wait for that to finish, or raise any build errors
|
||||
if (buildOnDemandTask != null)
|
||||
if (buildOnDemandTask != null && !buildOnDemandTask.IsCompleted)
|
||||
{
|
||||
await buildOnDemandTask;
|
||||
// For better debuggability, create a per-request timeout that makes it clear if the
|
||||
// prerendering builder took too long for this request, but without aborting the
|
||||
// underlying build task so that subsequent requests could still work.
|
||||
await buildOnDemandTask.WithTimeout(buildTimeout,
|
||||
$"The prerendering build process did not complete within the " +
|
||||
$"timeout period of {buildTimeout.Seconds} seconds. " +
|
||||
$"Check the log output for error information.");
|
||||
}
|
||||
|
||||
// It's no good if we try to return a 304. We need to capture the actual
|
||||
@@ -225,7 +233,8 @@ namespace Microsoft.AspNetCore.Builder
|
||||
|
||||
if (!string.IsNullOrEmpty(renderResult.RedirectUrl))
|
||||
{
|
||||
context.Response.Redirect(renderResult.RedirectUrl);
|
||||
var permanentRedirect = renderResult.StatusCode.GetValueOrDefault() == 301;
|
||||
context.Response.Redirect(renderResult.RedirectUrl, permanentRedirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,6 +248,11 @@ namespace Microsoft.AspNetCore.Builder
|
||||
$"embed any information you wish to return to the client.");
|
||||
}
|
||||
|
||||
if (renderResult.StatusCode.HasValue)
|
||||
{
|
||||
context.Response.StatusCode = renderResult.StatusCode.Value;
|
||||
}
|
||||
|
||||
context.Response.ContentType = "text/html";
|
||||
await context.Response.WriteAsync(renderResult.Html);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
||||
private const int DefaultWebSocketBufferSize = 4096;
|
||||
private const int StreamCopyBufferSize = 81920;
|
||||
|
||||
private static readonly string[] NotForwardedWebSocketHeaders = new[] { "Connection", "Host", "Upgrade", "Sec-WebSocket-Key", "Sec-WebSocket-Version" };
|
||||
// Don't forward User-Agent/Accept because of https://github.com/aspnet/JavaScriptServices/issues/1469
|
||||
// Others just aren't applicable in proxy scenarios
|
||||
private static readonly string[] NotForwardedWebSocketHeaders = new[] { "Accept", "Connection", "Host", "User-Agent", "Upgrade", "Sec-WebSocket-Key", "Sec-WebSocket-Version" };
|
||||
|
||||
public static HttpClient CreateHttpClientForProxy(TimeSpan requestTimeout)
|
||||
{
|
||||
@@ -204,7 +206,19 @@ namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
||||
{
|
||||
if (!NotForwardedWebSocketHeaders.Contains(headerEntry.Key, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
client.Options.SetRequestHeader(headerEntry.Key, headerEntry.Value);
|
||||
try
|
||||
{
|
||||
client.Options.SetRequestHeader(headerEntry.Key, headerEntry.Value);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// On net461, certain header names are reserved and can't be set.
|
||||
// We filter out the known ones via the test above, but there could
|
||||
// be others arbitrarily set by the client. It's not helpful to
|
||||
// consider it an error, so just skip non-forwardable headers.
|
||||
// The perf implications of handling this via a catch aren't an
|
||||
// issue since this is a dev-time only feature.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Builder
|
||||
{
|
||||
UseProxyToSpaDevelopmentServer(
|
||||
spaBuilder,
|
||||
Task.FromResult(baseUri));
|
||||
() => Task.FromResult(baseUri));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,10 +54,10 @@ namespace Microsoft.AspNetCore.Builder
|
||||
/// development. Do not enable this middleware in production applications.
|
||||
/// </summary>
|
||||
/// <param name="spaBuilder">The <see cref="ISpaBuilder"/>.</param>
|
||||
/// <param name="baseUriTask">A <see cref="Task"/> that resolves with the target base URI to which requests should be proxied.</param>
|
||||
/// <param name="baseUriTaskFactory">A callback that will be invoked on each request to supply a <see cref="Task"/> that resolves with the target base URI to which requests should be proxied.</param>
|
||||
public static void UseProxyToSpaDevelopmentServer(
|
||||
this ISpaBuilder spaBuilder,
|
||||
Task<Uri> baseUriTask)
|
||||
Func<Task<Uri>> baseUriTaskFactory)
|
||||
{
|
||||
var applicationBuilder = spaBuilder.ApplicationBuilder;
|
||||
var applicationStoppingToken = GetStoppingToken(applicationBuilder);
|
||||
@@ -72,11 +72,11 @@ namespace Microsoft.AspNetCore.Builder
|
||||
var neverTimeOutHttpClient =
|
||||
SpaProxy.CreateHttpClientForProxy(Timeout.InfiniteTimeSpan);
|
||||
|
||||
// Proxy all requests into the Angular CLI server
|
||||
// Proxy all requests to the SPA development server
|
||||
applicationBuilder.Use(async (context, next) =>
|
||||
{
|
||||
var didProxyRequest = await SpaProxy.PerformProxyRequest(
|
||||
context, neverTimeOutHttpClient, baseUriTask, applicationStoppingToken,
|
||||
context, neverTimeOutHttpClient, baseUriTaskFactory(), applicationStoppingToken,
|
||||
proxy404s: true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
||||
{
|
||||
@@ -18,7 +19,6 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
||||
{
|
||||
private const string LogCategoryName = "Microsoft.AspNetCore.SpaServices";
|
||||
private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine
|
||||
private static TimeSpan StartupTimeout = TimeSpan.FromSeconds(50); // Note that the HTTP request itself by default times out after 60s, so you only get useful error information if this is shorter
|
||||
|
||||
public static void Attach(
|
||||
ISpaBuilder spaBuilder,
|
||||
@@ -48,7 +48,16 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
||||
var targetUriTask = portTask.ContinueWith(
|
||||
task => new UriBuilder("http", "localhost", task.Result).Uri);
|
||||
|
||||
SpaProxyingExtensions.UseProxyToSpaDevelopmentServer(spaBuilder, targetUriTask);
|
||||
SpaProxyingExtensions.UseProxyToSpaDevelopmentServer(spaBuilder, () =>
|
||||
{
|
||||
// On each request, we create a separate startup task with its own timeout. That way, even if
|
||||
// the first request times out, subsequent requests could still work.
|
||||
var timeout = spaBuilder.Options.StartupTimeout;
|
||||
return targetUriTask.WithTimeout(timeout,
|
||||
$"The create-react-app server did not start listening for requests " +
|
||||
$"within the timeout period of {timeout.Seconds} seconds. " +
|
||||
$"Check the log output for error information.");
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<int> StartCreateReactAppServerAsync(
|
||||
@@ -75,8 +84,7 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
||||
// no compiler warnings. So instead of waiting for that, consider it ready as soon
|
||||
// as it starts listening for requests.
|
||||
await npmScriptRunner.StdOut.WaitForMatch(
|
||||
new Regex("Starting the development server", RegexOptions.None, RegexMatchTimeout),
|
||||
StartupTimeout);
|
||||
new Regex("Starting the development server", RegexOptions.None, RegexMatchTimeout));
|
||||
}
|
||||
catch (EndOfStreamException ex)
|
||||
{
|
||||
@@ -85,13 +93,6 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
||||
$"create-react-app server was listening for requests. The error output was: " +
|
||||
$"{stdErrReader.ReadAsString()}", ex);
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"The create-react-app server did not start listening for requests " +
|
||||
$"within the timeout period of {StartupTimeout.Seconds} seconds. " +
|
||||
$"Check the log output for error information.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return portNumber;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.SpaServices
|
||||
// Developers who need to host more than one SPA with distinct default pages can
|
||||
// override the file provider
|
||||
app.UseSpaStaticFilesInternal(
|
||||
overrideFileProvider: options.DefaultPageFileProvider,
|
||||
options.DefaultPageStaticFileOptions ?? new StaticFileOptions(),
|
||||
allowFallbackOnServingWebRootFiles: true);
|
||||
|
||||
// If the default file didn't get served as a static file (usually because it was not
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
@@ -29,7 +30,7 @@ namespace Microsoft.AspNetCore.SpaServices
|
||||
internal SpaOptions(SpaOptions copyFromOptions)
|
||||
{
|
||||
_defaultPage = copyFromOptions.DefaultPage;
|
||||
DefaultPageFileProvider = copyFromOptions.DefaultPageFileProvider;
|
||||
DefaultPageStaticFileOptions = copyFromOptions.DefaultPageStaticFileOptions;
|
||||
SourcePath = copyFromOptions.SourcePath;
|
||||
}
|
||||
|
||||
@@ -52,14 +53,14 @@ namespace Microsoft.AspNetCore.SpaServices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IFileProvider"/> that supplies content
|
||||
/// Gets or sets the <see cref="StaticFileOptions"/> that supplies content
|
||||
/// for serving the SPA's default page.
|
||||
///
|
||||
/// If not set, a default file provider will read files from the
|
||||
/// <see cref="IHostingEnvironment.WebRootPath"/>, which by default is
|
||||
/// the <c>wwwroot</c> directory.
|
||||
/// </summary>
|
||||
public IFileProvider DefaultPageFileProvider { get; set; }
|
||||
public StaticFileOptions DefaultPageStaticFileOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path, relative to the application working directory,
|
||||
@@ -67,5 +68,11 @@ namespace Microsoft.AspNetCore.SpaServices
|
||||
/// development. The directory may not exist in published applications.
|
||||
/// </summary>
|
||||
public string SourcePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum duration that a request will wait for the SPA
|
||||
/// to become ready to serve to the client.
|
||||
/// </summary>
|
||||
public TimeSpan StartupTimeout { get; set; } = TimeSpan.FromSeconds(50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,53 +50,75 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
/// </summary>
|
||||
/// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/>.</param>
|
||||
public static void UseSpaStaticFiles(this IApplicationBuilder applicationBuilder)
|
||||
{
|
||||
UseSpaStaticFiles(applicationBuilder, new StaticFileOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the application to serve static files for a Single Page Application (SPA).
|
||||
/// The files will be located using the registered <see cref="ISpaStaticFileProvider"/> service.
|
||||
/// </summary>
|
||||
/// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/>.</param>
|
||||
/// <param name="options">Specifies options for serving the static files.</param>
|
||||
public static void UseSpaStaticFiles(this IApplicationBuilder applicationBuilder, StaticFileOptions options)
|
||||
{
|
||||
if (applicationBuilder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(applicationBuilder));
|
||||
}
|
||||
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
UseSpaStaticFilesInternal(applicationBuilder,
|
||||
overrideFileProvider: null,
|
||||
staticFileOptions: options,
|
||||
allowFallbackOnServingWebRootFiles: false);
|
||||
}
|
||||
|
||||
internal static void UseSpaStaticFilesInternal(
|
||||
this IApplicationBuilder app,
|
||||
IFileProvider overrideFileProvider,
|
||||
StaticFileOptions staticFileOptions,
|
||||
bool allowFallbackOnServingWebRootFiles)
|
||||
{
|
||||
var shouldServeStaticFiles = ShouldServeStaticFiles(
|
||||
app,
|
||||
overrideFileProvider,
|
||||
allowFallbackOnServingWebRootFiles,
|
||||
out var fileProviderOrDefault);
|
||||
|
||||
if (shouldServeStaticFiles)
|
||||
if (staticFileOptions == null)
|
||||
{
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = fileProviderOrDefault
|
||||
});
|
||||
throw new ArgumentNullException(nameof(staticFileOptions));
|
||||
}
|
||||
|
||||
// If the file provider was explicitly supplied, that takes precedence over any other
|
||||
// configured file provider. This is most useful if the application hosts multiple SPAs
|
||||
// (via multiple calls to UseSpa()), so each needs to serve its own separate static files
|
||||
// instead of using AddSpaStaticFiles/UseSpaStaticFiles.
|
||||
// But if no file provider was specified, try to get one from the DI config.
|
||||
if (staticFileOptions.FileProvider == null)
|
||||
{
|
||||
var shouldServeStaticFiles = ShouldServeStaticFiles(
|
||||
app,
|
||||
allowFallbackOnServingWebRootFiles,
|
||||
out var fileProviderOrDefault);
|
||||
if (shouldServeStaticFiles)
|
||||
{
|
||||
staticFileOptions.FileProvider = fileProviderOrDefault;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The registered ISpaStaticFileProvider says we shouldn't
|
||||
// serve static files
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
app.UseStaticFiles(staticFileOptions);
|
||||
}
|
||||
|
||||
private static bool ShouldServeStaticFiles(
|
||||
IApplicationBuilder app,
|
||||
IFileProvider overrideFileProvider,
|
||||
bool allowFallbackOnServingWebRootFiles,
|
||||
out IFileProvider fileProviderOrDefault)
|
||||
{
|
||||
if (overrideFileProvider != null)
|
||||
{
|
||||
// If the file provider was explicitly supplied, that takes precedence over any other
|
||||
// configured file provider. This is most useful if the application hosts multiple SPAs
|
||||
// (via multiple calls to UseSpa()), so each needs to serve its own separate static files
|
||||
// instead of using AddSpaStaticFiles/UseSpaStaticFiles.
|
||||
fileProviderOrDefault = overrideFileProvider;
|
||||
return true;
|
||||
}
|
||||
|
||||
var spaStaticFilesService = app.ApplicationServices.GetService<ISpaStaticFileProvider>();
|
||||
if (spaStaticFilesService != null)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.NodeServices.Util
|
||||
Task.Factory.StartNew(Run);
|
||||
}
|
||||
|
||||
public Task<Match> WaitForMatch(Regex regex, TimeSpan timeout = default)
|
||||
public Task<Match> WaitForMatch(Regex regex)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<Match>();
|
||||
var completionLock = new object();
|
||||
@@ -72,15 +72,6 @@ namespace Microsoft.AspNetCore.NodeServices.Util
|
||||
OnReceivedLine += onReceivedLineHandler;
|
||||
OnStreamClosed += onStreamClosedHandler;
|
||||
|
||||
if (timeout != default)
|
||||
{
|
||||
var timeoutToken = new CancellationTokenSource(timeout);
|
||||
timeoutToken.Token.Register(() =>
|
||||
{
|
||||
ResolveIfStillPending(() => tcs.SetCanceled());
|
||||
});
|
||||
}
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.Extensions.Util
|
||||
{
|
||||
internal static class TaskTimeoutExtensions
|
||||
{
|
||||
public static async Task WithTimeout(this Task task, TimeSpan timeoutDelay, string message)
|
||||
{
|
||||
if (task == await Task.WhenAny(task, Task.Delay(timeoutDelay)))
|
||||
{
|
||||
task.Wait(); // Allow any errors to propagate
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TimeoutException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<T> WithTimeout<T>(this Task<T> task, TimeSpan timeoutDelay, string message)
|
||||
{
|
||||
if (task == await Task.WhenAny(task, Task.Delay(timeoutDelay)))
|
||||
{
|
||||
return task.Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TimeoutException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,7 +561,7 @@ Typically, when you change a source file, the effects appear in your local brows
|
||||
First ensure you already have a working Webpack dev middleware setup. Then, install the `webpack-hot-middleware` NPM module:
|
||||
|
||||
```
|
||||
npm install --save webpack-hot-middleware
|
||||
npm install --save-dev webpack-hot-middleware
|
||||
```
|
||||
|
||||
At the top of your `Startup.cs` file, add the following namespace reference:
|
||||
@@ -620,7 +620,7 @@ app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
|
||||
Also, install the NPM module `aspnet-webpack-react`, e.g.:
|
||||
|
||||
```
|
||||
npm install --save aspnet-webpack-react
|
||||
npm install --save-dev aspnet-webpack-react
|
||||
```
|
||||
|
||||
Now if you edit any React component (e.g., in `.jsx` or `.tsx` files), the updated component will be injected into the running application, and will even preserve its in-memory state.
|
||||
|
||||
@@ -50,5 +50,12 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
|
||||
/// the webpack compiler.
|
||||
/// </summary>
|
||||
public IDictionary<string, string> EnvironmentVariables { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a value for the "env" parameter to be passed into the Webpack configuration
|
||||
/// function. The value must be JSON-serializable, and will only be used if the Webpack
|
||||
/// configuration is exported as a function.
|
||||
/// </summary>
|
||||
public object EnvParam { get; set; }
|
||||
}
|
||||
}
|
||||
730
src/Microsoft.AspNetCore.SpaServices/baseline.netcore.json
Normal file
730
src/Microsoft.AspNetCore.SpaServices/baseline.netcore.json
Normal file
@@ -0,0 +1,730 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.SpaServices, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.Extensions.DependencyInjection.PrerenderingServiceCollectionExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "AddSpaPrerenderer",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "serviceCollection",
|
||||
"Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.Builder.SpaRouteExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "MapSpaFallbackRoute",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "routeBuilder",
|
||||
"Type": "Microsoft.AspNetCore.Routing.IRouteBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "name",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "defaults",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "constraints",
|
||||
"Type": "System.Object",
|
||||
"DefaultValue": "null"
|
||||
},
|
||||
{
|
||||
"Name": "dataTokens",
|
||||
"Type": "System.Object",
|
||||
"DefaultValue": "null"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "MapSpaFallbackRoute",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "routeBuilder",
|
||||
"Type": "Microsoft.AspNetCore.Routing.IRouteBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "name",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "templatePrefix",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "defaults",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "constraints",
|
||||
"Type": "System.Object",
|
||||
"DefaultValue": "null"
|
||||
},
|
||||
{
|
||||
"Name": "dataTokens",
|
||||
"Type": "System.Object",
|
||||
"DefaultValue": "null"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.Builder.WebpackDevMiddleware",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseWebpackDevMiddleware",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "appBuilder",
|
||||
"Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "options",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.Webpack.WebpackDevMiddlewareOptions",
|
||||
"DefaultValue": "null"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Webpack.WebpackDevMiddlewareOptions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_HotModuleReplacement",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Boolean",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_HotModuleReplacement",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Boolean"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_HotModuleReplacementEndpoint",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_HotModuleReplacementEndpoint",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_HotModuleReplacementServerPort",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Int32",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_HotModuleReplacementServerPort",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Int32"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ReactHotModuleReplacement",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Boolean",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ReactHotModuleReplacement",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Boolean"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_HotModuleReplacementClientOptions",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Collections.Generic.IDictionary<System.String, System.String>",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_HotModuleReplacementClientOptions",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Collections.Generic.IDictionary<System.String, System.String>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ConfigFile",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ConfigFile",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ProjectPath",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ProjectPath",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_EnvironmentVariables",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Collections.Generic.IDictionary<System.String, System.String>",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_EnvironmentVariables",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Collections.Generic.IDictionary<System.String, System.String>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerenderer",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Interface",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "RenderToString",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "exportName",
|
||||
"Type": "System.String",
|
||||
"DefaultValue": "null"
|
||||
},
|
||||
{
|
||||
"Name": "customDataParameter",
|
||||
"Type": "System.Object",
|
||||
"DefaultValue": "null"
|
||||
},
|
||||
{
|
||||
"Name": "timeoutMilliseconds",
|
||||
"Type": "System.Int32",
|
||||
"DefaultValue": "0"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<Microsoft.AspNetCore.SpaServices.Prerendering.RenderToStringResult>",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Prerendering.JavaScriptModuleExport",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ModuleName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ExportName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ExportName",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "moduleName",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Prerendering.Prerenderer",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "RenderToString",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "applicationBasePath",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "nodeServices",
|
||||
"Type": "Microsoft.AspNetCore.NodeServices.INodeServices"
|
||||
},
|
||||
{
|
||||
"Name": "applicationStoppingToken",
|
||||
"Type": "System.Threading.CancellationToken"
|
||||
},
|
||||
{
|
||||
"Name": "bootModule",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.Prerendering.JavaScriptModuleExport"
|
||||
},
|
||||
{
|
||||
"Name": "requestAbsoluteUrl",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "requestPathAndQuery",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "customDataParameter",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "timeoutMilliseconds",
|
||||
"Type": "System.Int32"
|
||||
},
|
||||
{
|
||||
"Name": "requestPathBase",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task<Microsoft.AspNetCore.SpaServices.Prerendering.RenderToStringResult>",
|
||||
"Static": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"BaseType": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelper",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ModuleName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ModuleName",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ExportName",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ExportName",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_CustomDataParameter",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Object",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_CustomDataParameter",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Object"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_TimeoutMillisecondsParameter",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Int32",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_TimeoutMillisecondsParameter",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Int32"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ViewContext",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.AspNetCore.Mvc.Rendering.ViewContext",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ViewContext",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "Microsoft.AspNetCore.Mvc.Rendering.ViewContext"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "ProcessAsync",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "context",
|
||||
"Type": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext"
|
||||
},
|
||||
{
|
||||
"Name": "output",
|
||||
"Type": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task",
|
||||
"Virtual": true,
|
||||
"Override": true,
|
||||
"ImplementedInterface": "Microsoft.AspNetCore.Razor.TagHelpers.ITagHelperComponent",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "serviceProvider",
|
||||
"Type": "System.IServiceProvider"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Prerendering.RenderToStringResult",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_Globals",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Newtonsoft.Json.Linq.JObject",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_Globals",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "Newtonsoft.Json.Linq.JObject"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_Html",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_Html",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_RedirectUrl",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_RedirectUrl",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_StatusCode",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Nullable<System.Int32>",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_StatusCode",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Nullable<System.Int32>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "CreateGlobalsAssignmentScript",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aspnet-webpack",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.3",
|
||||
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -33,6 +33,6 @@
|
||||
"webpack": "^1.13.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"webpack": "^1.13.2 || ^2.1.0-beta"
|
||||
"webpack": "^1.13.2 || ^2.1.0-beta || ^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,17 +32,28 @@ interface DevServerOptions {
|
||||
HotModuleReplacementServerPort: number;
|
||||
HotModuleReplacementClientOptions: StringMap<string>;
|
||||
ReactHotModuleReplacement: boolean;
|
||||
EnvParam: any;
|
||||
}
|
||||
|
||||
// We support these three kinds of webpack.config.js export. We don't currently support exported promises
|
||||
// (though we might be able to add that in the future, if there's a need).
|
||||
type WebpackConfigOrArray = webpack.Configuration | webpack.Configuration[];
|
||||
interface WebpackConfigFunc {
|
||||
(env?: any): WebpackConfigOrArray;
|
||||
// Interface as defined in es6-promise
|
||||
interface Thenable<T> {
|
||||
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
|
||||
}
|
||||
type WebpackConfigExport = WebpackConfigOrArray | WebpackConfigFunc;
|
||||
|
||||
// We support these four kinds of webpack.config.js export
|
||||
type WebpackConfigOrArray = webpack.Configuration | webpack.Configuration[];
|
||||
type WebpackConfigOrArrayOrThenable = WebpackConfigOrArray | Thenable<WebpackConfigOrArray>;
|
||||
interface WebpackConfigFunc {
|
||||
(env?: any): WebpackConfigOrArrayOrThenable;
|
||||
}
|
||||
type WebpackConfigExport = WebpackConfigOrArrayOrThenable | WebpackConfigFunc;
|
||||
type WebpackConfigModuleExports = WebpackConfigExport | EsModuleExports<WebpackConfigExport>;
|
||||
|
||||
function isThenable<T>(obj: any): obj is Thenable<T> {
|
||||
return obj && typeof (<Thenable<any>>obj).then === 'function';
|
||||
}
|
||||
|
||||
function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configuration, enableHotModuleReplacement: boolean, enableReactHotModuleReplacement: boolean, hmrClientOptions: StringMap<string>, hmrServerEndpoint: string) {
|
||||
// Build the final Webpack config based on supplied options
|
||||
if (enableHotModuleReplacement) {
|
||||
@@ -226,6 +237,15 @@ function beginWebpackWatcher(webpackConfig: webpack.Configuration) {
|
||||
export function createWebpackDevServer(callback: CreateDevServerCallback, optionsJson: string) {
|
||||
const options: CreateDevServerOptions = JSON.parse(optionsJson);
|
||||
|
||||
// Enable TypeScript loading if the webpack config is authored in TypeScript
|
||||
if (path.extname(options.webpackConfigPath) === '.ts') {
|
||||
try {
|
||||
require('ts-node/register');
|
||||
} catch (ex) {
|
||||
throw new Error('Error while attempting to enable support for Webpack config file written in TypeScript. Make sure your project depends on the "ts-node" NPM package. The underlying error was: ' + ex.stack);
|
||||
}
|
||||
}
|
||||
|
||||
// See the large comment in WebpackTestPermissions.ts for details about this
|
||||
if (!hasSufficientPermissions()) {
|
||||
console.log('WARNING: Webpack dev middleware is not enabled because the server process does not have sufficient permissions. You should either remove the UseWebpackDevMiddleware call from your code, or to make it work, give your server process user account permission to write to your application directory and to read all ancestor-level directories.');
|
||||
@@ -243,83 +263,92 @@ export function createWebpackDevServer(callback: CreateDevServerCallback, option
|
||||
: (webpackConfigModuleExports as WebpackConfigExport);
|
||||
|
||||
if (webpackConfigExport instanceof Function) {
|
||||
// If you export a function, we'll call it with an undefined 'env' arg, since we have nothing else
|
||||
// to pass. This is the same as what the webpack CLI tool does if you specify no '--env.x' values.
|
||||
// In the future, we could add support for configuring the 'env' param in Startup.cs. But right
|
||||
// now, it's not clear that people will want to do that (and they can always make up their own
|
||||
// default env values in their webpack.config.js).
|
||||
webpackConfigExport = webpackConfigExport();
|
||||
}
|
||||
const webpackConfigArray = webpackConfigExport instanceof Array ? webpackConfigExport : [webpackConfigExport];
|
||||
|
||||
const enableHotModuleReplacement = options.suppliedOptions.HotModuleReplacement;
|
||||
const enableReactHotModuleReplacement = options.suppliedOptions.ReactHotModuleReplacement;
|
||||
if (enableReactHotModuleReplacement && !enableHotModuleReplacement) {
|
||||
callback('To use ReactHotModuleReplacement, you must also enable the HotModuleReplacement option.', null);
|
||||
return;
|
||||
// If you export a function, then Webpack convention is that it takes zero or one param,
|
||||
// and that param is called `env` and reflects the `--env.*` args you can specify on
|
||||
// the command line (e.g., `--env.prod`).
|
||||
// When invoking it via WebpackDevMiddleware, we let you configure the `env` param in
|
||||
// your Startup.cs.
|
||||
webpackConfigExport = webpackConfigExport(options.suppliedOptions.EnvParam);
|
||||
}
|
||||
|
||||
// The default value, 0, means 'choose randomly'
|
||||
const suggestedHMRPortOrZero = options.suppliedOptions.HotModuleReplacementServerPort || 0;
|
||||
const webpackConfigThenable = isThenable<WebpackConfigOrArray>(webpackConfigExport)
|
||||
? webpackConfigExport
|
||||
: { then: callback => callback(webpackConfigExport) } as Thenable<WebpackConfigOrArray>;
|
||||
|
||||
const app = connect();
|
||||
const listener = app.listen(suggestedHMRPortOrZero, () => {
|
||||
try {
|
||||
// For each webpack config that specifies a public path, add webpack dev middleware for it
|
||||
const normalizedPublicPaths: string[] = [];
|
||||
webpackConfigArray.forEach(webpackConfig => {
|
||||
if (webpackConfig.target === 'node') {
|
||||
// For configs that target Node, it's meaningless to set up an HTTP listener, since
|
||||
// Node isn't going to load those modules over HTTP anyway. It just loads them directly
|
||||
// from disk. So the most relevant thing we can do with such configs is just write
|
||||
// updated builds to disk, just like "webpack --watch".
|
||||
beginWebpackWatcher(webpackConfig);
|
||||
} else {
|
||||
// For configs that target browsers, we can set up an HTTP listener, and dynamically
|
||||
// modify the config to enable HMR etc. This just requires that we have a publicPath.
|
||||
const publicPath = (webpackConfig.output.publicPath || '').trim();
|
||||
if (!publicPath) {
|
||||
throw new Error('To use the Webpack dev server, you must specify a value for \'publicPath\' on the \'output\' section of your webpack config (for any configuration that targets browsers)');
|
||||
}
|
||||
const publicPathNoTrailingSlash = removeTrailingSlash(publicPath);
|
||||
normalizedPublicPaths.push(publicPathNoTrailingSlash);
|
||||
webpackConfigThenable.then(webpackConfigResolved => {
|
||||
const webpackConfigArray = webpackConfigResolved instanceof Array ? webpackConfigResolved : [webpackConfigResolved];
|
||||
|
||||
// This is the URL the client will connect to, except that since it's a relative URL
|
||||
// (no leading slash), Webpack will resolve it against the runtime <base href> URL
|
||||
// plus it also adds the publicPath
|
||||
const hmrClientEndpoint = removeLeadingSlash(options.hotModuleReplacementEndpointUrl);
|
||||
|
||||
// This is the URL inside the Webpack middleware Node server that we'll proxy to.
|
||||
// We have to prefix with the public path because Webpack will add the publicPath
|
||||
// when it resolves hmrClientEndpoint as a relative URL.
|
||||
const hmrServerEndpoint = ensureLeadingSlash(publicPathNoTrailingSlash + options.hotModuleReplacementEndpointUrl);
|
||||
|
||||
// We always overwrite the 'path' option as it needs to match what the .NET side is expecting
|
||||
const hmrClientOptions = options.suppliedOptions.HotModuleReplacementClientOptions || <StringMap<string>>{};
|
||||
hmrClientOptions['path'] = hmrClientEndpoint;
|
||||
|
||||
const dynamicPublicPathKey = 'dynamicPublicPath';
|
||||
if (!(dynamicPublicPathKey in hmrClientOptions)) {
|
||||
// dynamicPublicPath default to true, so we can work with nonempty pathbases (virtual directories)
|
||||
hmrClientOptions[dynamicPublicPathKey] = true;
|
||||
} else {
|
||||
// ... but you can set it to any other value explicitly if you want (e.g., false)
|
||||
hmrClientOptions[dynamicPublicPathKey] = JSON.parse(hmrClientOptions[dynamicPublicPathKey]);
|
||||
}
|
||||
|
||||
attachWebpackDevMiddleware(app, webpackConfig, enableHotModuleReplacement, enableReactHotModuleReplacement, hmrClientOptions, hmrServerEndpoint);
|
||||
}
|
||||
});
|
||||
|
||||
// Tell the ASP.NET app what addresses we're listening on, so that it can proxy requests here
|
||||
callback(null, {
|
||||
Port: listener.address().port,
|
||||
PublicPaths: normalizedPublicPaths
|
||||
});
|
||||
} catch (ex) {
|
||||
callback(ex.stack, null);
|
||||
const enableHotModuleReplacement = options.suppliedOptions.HotModuleReplacement;
|
||||
const enableReactHotModuleReplacement = options.suppliedOptions.ReactHotModuleReplacement;
|
||||
if (enableReactHotModuleReplacement && !enableHotModuleReplacement) {
|
||||
callback('To use ReactHotModuleReplacement, you must also enable the HotModuleReplacement option.', null);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
// The default value, 0, means 'choose randomly'
|
||||
const suggestedHMRPortOrZero = options.suppliedOptions.HotModuleReplacementServerPort || 0;
|
||||
|
||||
const app = connect();
|
||||
const listener = app.listen(suggestedHMRPortOrZero, () => {
|
||||
try {
|
||||
// For each webpack config that specifies a public path, add webpack dev middleware for it
|
||||
const normalizedPublicPaths: string[] = [];
|
||||
webpackConfigArray.forEach(webpackConfig => {
|
||||
if (webpackConfig.target === 'node') {
|
||||
// For configs that target Node, it's meaningless to set up an HTTP listener, since
|
||||
// Node isn't going to load those modules over HTTP anyway. It just loads them directly
|
||||
// from disk. So the most relevant thing we can do with such configs is just write
|
||||
// updated builds to disk, just like "webpack --watch".
|
||||
beginWebpackWatcher(webpackConfig);
|
||||
} else {
|
||||
// For configs that target browsers, we can set up an HTTP listener, and dynamically
|
||||
// modify the config to enable HMR etc. This just requires that we have a publicPath.
|
||||
const publicPath = (webpackConfig.output.publicPath || '').trim();
|
||||
if (!publicPath) {
|
||||
throw new Error('To use the Webpack dev server, you must specify a value for \'publicPath\' on the \'output\' section of your webpack config (for any configuration that targets browsers)');
|
||||
}
|
||||
const publicPathNoTrailingSlash = removeTrailingSlash(publicPath);
|
||||
normalizedPublicPaths.push(publicPathNoTrailingSlash);
|
||||
|
||||
// This is the URL the client will connect to, except that since it's a relative URL
|
||||
// (no leading slash), Webpack will resolve it against the runtime <base href> URL
|
||||
// plus it also adds the publicPath
|
||||
const hmrClientEndpoint = removeLeadingSlash(options.hotModuleReplacementEndpointUrl);
|
||||
|
||||
// This is the URL inside the Webpack middleware Node server that we'll proxy to.
|
||||
// We have to prefix with the public path because Webpack will add the publicPath
|
||||
// when it resolves hmrClientEndpoint as a relative URL.
|
||||
const hmrServerEndpoint = ensureLeadingSlash(publicPathNoTrailingSlash + options.hotModuleReplacementEndpointUrl);
|
||||
|
||||
// We always overwrite the 'path' option as it needs to match what the .NET side is expecting
|
||||
const hmrClientOptions = options.suppliedOptions.HotModuleReplacementClientOptions || <StringMap<string>>{};
|
||||
hmrClientOptions['path'] = hmrClientEndpoint;
|
||||
|
||||
const dynamicPublicPathKey = 'dynamicPublicPath';
|
||||
if (!(dynamicPublicPathKey in hmrClientOptions)) {
|
||||
// dynamicPublicPath default to true, so we can work with nonempty pathbases (virtual directories)
|
||||
hmrClientOptions[dynamicPublicPathKey] = true;
|
||||
} else {
|
||||
// ... but you can set it to any other value explicitly if you want (e.g., false)
|
||||
hmrClientOptions[dynamicPublicPathKey] = JSON.parse(hmrClientOptions[dynamicPublicPathKey]);
|
||||
}
|
||||
|
||||
attachWebpackDevMiddleware(app, webpackConfig, enableHotModuleReplacement, enableReactHotModuleReplacement, hmrClientOptions, hmrServerEndpoint);
|
||||
}
|
||||
});
|
||||
|
||||
// Tell the ASP.NET app what addresses we're listening on, so that it can proxy requests here
|
||||
callback(null, {
|
||||
Port: listener.address().port,
|
||||
PublicPaths: normalizedPublicPaths
|
||||
});
|
||||
} catch (ex) {
|
||||
callback(ex.stack, null);
|
||||
}
|
||||
});
|
||||
},
|
||||
err => callback(err.stack, null)
|
||||
);
|
||||
}
|
||||
|
||||
function removeLeadingSlash(str: string) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const domainTaskBaseUrlStateKey = '__DOMAIN_TASK_INTERNAL_FETCH_BASEURL__DO_NOT_
|
||||
|
||||
let noDomainBaseUrl: string;
|
||||
|
||||
export function addTask(task: PromiseLike<any>) {
|
||||
export function addTask<T>(task: PromiseLike<T>): PromiseLike<T> {
|
||||
if (task && domain.active) {
|
||||
const state = domainContext.get(domainTasksStateKey) as DomainTasksState;
|
||||
if (state) {
|
||||
@@ -32,6 +32,8 @@ export function addTask(task: PromiseLike<any>) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
export function run<T>(codeToRun: () => T, completionCallback: (error: any) => void): T {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>2.1.0</VersionPrefix>
|
||||
<VersionSuffix>preview1</VersionSuffix>
|
||||
<VersionSuffix>rtm</VersionSuffix>
|
||||
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
|
||||
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
|
||||
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>
|
||||
<FeatureBranchVersionPrefix Condition="'$(FeatureBranchVersionPrefix)' == ''">a-</FeatureBranchVersionPrefix>
|
||||
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(FeatureBranchVersionSuffix)' != ''">$(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))</VersionSuffix>
|
||||
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user