Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
A
aspnetcore
管理
动态
成员
标记
计划
议题
议题看板
里程碑
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
dotnet
aspnetcore
提交
ae8f67f2
未验证
提交
ae8f67f2
编辑于
4 years ago
作者:
Pranav K
浏览文件
操作
下载
补丁
差异文件
Use randomized ports in dotnet-serve
上级
dd62a699
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
.config/dotnet-tools.json
+1
-1
1 个添加, 1 个删除
.config/dotnet-tools.json
src/ProjectTemplates/test/BlazorWasmTemplateTest.cs
+39
-17
39 个添加, 17 个删除
src/ProjectTemplates/test/BlazorWasmTemplateTest.cs
有
40 个添加
和
18 个删除
.config/dotnet-tools.json
+
1
−
1
浏览文件 @
ae8f67f2
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
"isRoot"
:
true
,
"isRoot"
:
true
,
"tools"
:
{
"tools"
:
{
"dotnet-serve"
:
{
"dotnet-serve"
:
{
"version"
:
"1.
5.0
"
,
"version"
:
"1.
7.125
"
,
"commands"
:
[
"commands"
:
[
"dotnet-serve"
"dotnet-serve"
]
]
...
...
此差异已折叠。
点击以展开。
src/ProjectTemplates/test/BlazorWasmTemplateTest.cs
+
39
−
17
浏览文件 @
ae8f67f2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Net
;
...
@@ -58,7 +59,7 @@ namespace Templates.Test
...
@@ -58,7 +59,7 @@ namespace Templates.Test
await
BuildAndRunTest
(
project
.
ProjectName
,
project
);
await
BuildAndRunTest
(
project
.
ProjectName
,
project
);
using
var
serveProcess
=
RunPublishedStandaloneBlazorProject
(
project
);
RunPublishedStandaloneBlazorProject
(
project
);
}
}
[
Fact
]
[
Fact
]
...
@@ -133,13 +134,7 @@ namespace Templates.Test
...
@@ -133,13 +134,7 @@ namespace Templates.Test
ValidatePublishedServiceWorker
(
project
);
ValidatePublishedServiceWorker
(
project
);
using
(
var
serverProcess
=
RunPublishedStandaloneBlazorProject
(
project
))
var
listeningUri
=
RunPublishedStandaloneBlazorProject
(
project
);
{
// We want to use this form to ensure that it gets disposed right after the test.
}
// Todo: Use dynamic port assignment: https://github.com/natemcmaster/dotnet-serve/pull/40/files
var
listeningUri
=
"https://localhost:8080"
;
// The PWA template supports offline use. By now, the browser should have cached everything it needs,
// The PWA template supports offline use. By now, the browser should have cached everything it needs,
// so we can continue working even without the server.
// so we can continue working even without the server.
...
@@ -326,7 +321,7 @@ namespace Templates.Test
...
@@ -326,7 +321,7 @@ namespace Templates.Test
// for that, we use the common microsoft tenant.
// for that, we use the common microsoft tenant.
await
BuildAndRunTest
(
project
.
ProjectName
,
project
,
usesAuth
:
false
);
await
BuildAndRunTest
(
project
.
ProjectName
,
project
,
usesAuth
:
false
);
using
var
serveProcess
=
RunPublishedStandaloneBlazorProject
(
project
);
RunPublishedStandaloneBlazorProject
(
project
);
}
}
public
static
TheoryData
<
TemplateInstance
>
TemplateData
=>
new
TheoryData
<
TemplateInstance
>
public
static
TheoryData
<
TemplateInstance
>
TemplateData
=>
new
TheoryData
<
TemplateInstance
>
...
@@ -551,20 +546,47 @@ namespace Templates.Test
...
@@ -551,20 +546,47 @@ namespace Templates.Test
}
}
private
ProcessEx
RunPublishedStandaloneBlazorProject
(
Project
project
)
private
string
RunPublishedStandaloneBlazorProject
(
Project
project
)
{
{
var
publishDir
=
Path
.
Combine
(
project
.
TemplatePublishDir
,
"wwwroot"
);
var
publishDir
=
Path
.
Combine
(
project
.
TemplatePublishDir
,
"wwwroot"
);
AspNetProcess
.
EnsureDevelopmentCertificates
();
AspNetProcess
.
EnsureDevelopmentCertificates
();
Output
.
WriteLine
(
"Running dotnet serve on published output..."
);
Output
.
WriteLine
(
"Running dotnet serve on published output..."
);
var
serveProcess
=
ProcessEx
.
Run
(
Output
,
publishDir
,
DotNetMuxer
.
MuxerPathOrDefault
(),
"serve -S"
);
using
(
var
serveProcess
=
ProcessEx
.
Run
(
Output
,
publishDir
,
DotNetMuxer
.
MuxerPathOrDefault
(),
"serve -S --port 0"
))
{
var
listeningUri
=
ResolveListeningUrl
(
serveProcess
);
Output
.
WriteLine
(
$"Opening browser at
{
listeningUri
}
..."
);
Browser
.
Navigate
().
GoToUrl
(
listeningUri
);
// Todo: Use dynamic port assignment: https://github.com/natemcmaster/dotnet-serve/pull/40/files
TestBasicNavigation
(
project
.
ProjectName
);
var
listeningUri
=
"https://localhost:8080"
;
Output
.
WriteLine
(
$"Opening browser at
{
listeningUri
}
..."
);
return
listeningUri
;
Browser
.
Navigate
().
GoToUrl
(
listeningUri
);
}
TestBasicNavigation
(
project
.
ProjectName
);
}
return
serveProcess
;
private
static
string
ResolveListeningUrl
(
ProcessEx
process
)
{
var
buffer
=
new
List
<
string
>();
try
{
foreach
(
var
line
in
process
.
OutputLinesAsEnumerable
)
{
if
(
line
!=
null
)
{
buffer
.
Add
(
line
);
if
(
line
.
Trim
().
Contains
(
"https://"
,
StringComparison
.
Ordinal
)
||
line
.
Trim
().
Contains
(
"http://"
,
StringComparison
.
Ordinal
))
{
return
line
.
Trim
();
}
}
}
}
catch
(
OperationCanceledException
)
{
}
throw
new
InvalidOperationException
(
@
$"Couldn't find listening url:
{
string
.
Join
(
Environment
.
NewLine
,
buffer
.
Append
(
process
.
Error
))}
");
}
}
}
}
}
}
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录