Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
0868ca8a
F
fsharp
项目概览
dotNET Platform
/
fsharp
11 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0868ca8a
编写于
12月 30, 2020
作者:
K
Kevin Ransom (msft)
提交者:
GitHub
12月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix dotnet io (#10815)
上级
94885f55
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
63 addition
and
19 deletion
+63
-19
src/fsharp/FxResolver.fs
src/fsharp/FxResolver.fs
+63
-19
未找到文件。
src/fsharp/FxResolver.fs
浏览文件 @
0868ca8a
...
...
@@ -56,7 +56,8 @@ type internal FxResolver(assumeDotNetFramework: bool option, projectDir: string,
static
let
getDotnetHostPath
()
=
match
(
Environment
.
GetEnvironmentVariable
(
"DOTNET_HOST_PATH"
))
with
|
value
when
not
(
String
.
IsNullOrEmpty
(
value
))
->
value
// Value set externally
// Set externally
value
|
_
->
match
getDotnetDirectory
()
with
|
Some
dotnetDir
->
...
...
@@ -68,29 +69,72 @@ type internal FxResolver(assumeDotNetFramework: bool option, projectDir: string,
/// we repeatedly try to run dotnet.exe on every keystroke for a script
static
let
desiredDotNetSdkVersionForDirectoryCache
=
ConcurrentDictionary
<
string
,
Result
<
string
,
exn
>>()
// Execute the process pathToExe passing the arguments: arguments with the working directory: workingDir timeout after timeout milliseconds -1 = wait forever
// returns exit code, stdio and stderr as string arrays
let
executeProcess
pathToExe
arguments
(
workingDir
:
string
option
)
timeout
=
if
not
(
String
.
IsNullOrEmpty
pathToExe
)
then
let
errorsList
=
ResizeArray
()
let
outputList
=
ResizeArray
()
let
mutable
errorslock
=
obj
let
mutable
outputlock
=
obj
let
outputDataReceived
(
message
:
string
)
=
if
not
(
isNull
message
)
then
lock
outputlock
(
fun
()
->
outputList
.
Add
(
message
))
let
errorDataReceived
(
message
:
string
)
=
if
not
(
isNull
message
)
then
lock
errorslock
(
fun
()
->
errorsList
.
Add
(
message
))
let
psi
=
ProcessStartInfo
()
psi
.
FileName
<-
pathToExe
if
workingDir
.
IsSome
then
psi
.
WorkingDirectory
<-
workingDir
.
Value
psi
.
RedirectStandardOutput
<-
true
psi
.
RedirectStandardError
<-
true
psi
.
Arguments
<-
arguments
psi
.
CreateNoWindow
<-
true
psi
.
EnvironmentVariables
.
Remove
(
"MSBuildSDKsPath"
)
// Host can sometimes add this, and it can break things
psi
.
UseShellExecute
<-
false
use
p
=
new
Process
()
p
.
StartInfo
<-
psi
p
.
OutputDataReceived
.
Add
(
fun
a
->
outputDataReceived
a
.
Data
)
p
.
ErrorDataReceived
.
Add
(
fun
a
->
errorDataReceived
a
.
Data
)
if
p
.
Start
()
then
p
.
BeginOutputReadLine
()
p
.
BeginErrorReadLine
()
if
not
(
p
.
WaitForExit
(
timeout
))
then
// Timed out resolving throw a diagnostic.
raise
(
new
TimeoutException
(
sprintf
"Timeout executing command '%s' '%s'"
(
psi
.
FileName
)
(
psi
.
Arguments
)))
else
p
.
WaitForExit
()
#
if
DEBUG
if
workingDir
.
IsSome
then
File
.
WriteAllLines
(
Path
.
Combine
(
workingDir
.
Value
,
"StandardOutput.txt"
),
outputList
)
File
.
WriteAllLines
(
Path
.
Combine
(
workingDir
.
Value
,
"StandardError.txt"
),
errorsList
)
#
endif
p
.
ExitCode
,
outputList
.
ToArray
()
,
errorsList
.
ToArray
()
else
-
1
,
Array
.
empty
,
Array
.
empty
/// Find the relevant sdk version by running `dotnet --version` in the script/project location,
/// taking into account any global.json
let
tryGetDesiredDotNetSdkVersionForDirectoryInfo
()
=
desiredDotNetSdkVersionForDirectoryCache
.
GetOrAdd
(
projectDir
,
(
fun
_
->
let
dotnetHostPath
=
getDotnetHostPath
()
try
let
psi
=
ProcessStartInfo
(
dotnetHostPath
,
"--version"
)
psi
.
RedirectStandardOutput
<-
true
psi
.
RedirectStandardError
<-
true
psi
.
UseShellExecute
<-
false
psi
.
CreateNoWindow
<-
true
psi
.
StandardOutputEncoding
<-
Encoding
.
UTF8
psi
.
StandardErrorEncoding
<-
Encoding
.
UTF8
let
workingDir
=
if
Directory
.
Exists
(
projectDir
)
then
psi
.
WorkingDirectory
<-
projectDir
let
p
=
Process
.
Start
(
psi
)
let
stdout
=
p
.
StandardOutput
.
ReadToEnd
()
let
stderr
=
p
.
StandardError
.
ReadToEnd
()
p
.
WaitForExit
()
if
p
.
ExitCode
<>
0
then
Result
.
Error
(
Error
(
FSComp
.
SR
.
scriptSdkNotDetermined
(
dotnetHostPath
,
projectDir
,
stderr
,
p
.
ExitCode
),
rangeForErrors
))
Some
projectDir
else
None
let
exitCode
,
output
,
errors
=
executeProcess
dotnetHostPath
"--version"
workingDir
30000
if
exitCode
<>
0
then
Result
.
Error
(
Error
(
FSComp
.
SR
.
scriptSdkNotDetermined
(
dotnetHostPath
,
projectDir
,
(
errors
|>
String
.
concat
"
\n
"
),
exitCode
),
rangeForErrors
))
else
Result
.
Ok
(
stdout
.
Trim
()
)
Result
.
Ok
(
output
|>
String
.
concat
"
\n
"
)
with
err
->
Result
.
Error
(
Error
(
FSComp
.
SR
.
scriptSdkNotDetermined
(
dotnetHostPath
,
projectDir
,
err
.
Message
,
1
),
rangeForErrors
))))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录