Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
60fd993c
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
60fd993c
编写于
10月 24, 2018
作者:
J
Jared Parsons
提交者:
GitHub
10月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30002 from dotnet/dev/jaredpar/fix-copy
Reduce set of files copied on official builds
上级
bd2a39d8
933356a7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
111 addition
and
102 deletion
+111
-102
.vsts-ci.yml
.vsts-ci.yml
+13
-1
0
0
+0
-0
build/scripts/build-utils.ps1
build/scripts/build-utils.ps1
+51
-17
build/scripts/vsts-robocopy.ps1
build/scripts/vsts-robocopy.ps1
+34
-84
docs/contributing/Powershell Guidelines.md
docs/contributing/Powershell Guidelines.md
+13
-0
未找到文件。
.vsts-ci.yml
浏览文件 @
60fd993c
...
...
@@ -89,10 +89,14 @@ steps:
# Publish VSTS artifact that the RoslynInsertionTool is able to find by its name.
# The backing storage of the artifact is a file share.
#
# The bulk of the publish work is done by the Powershell task below. This exists to create
# the proper entries in the build log so that the insertion tool can find the drop that
# needs to get published
-
task
:
PublishBuildArtifacts@1
displayName
:
Publish Drop - Binaries
inputs
:
PathtoPublish
:
'
Binaries\$(BuildConfiguration)'
PathtoPublish
:
'
Binaries\$(BuildConfiguration)
\DevDivInsertionFiles
'
ArtifactName
:
'
$(Build.BuildNumber)'
publishLocation
:
FilePath
TargetPath
:
'
$(DropRoot)\Roslyn-Signed\$(Build.SourceBranchName)\$(BuildConfiguration)'
...
...
@@ -100,6 +104,14 @@ steps:
ParallelCount
:
64
condition
:
succeededOrFailed()
# Archive the files from the build necessary for future investigations
-
task
:
PowerShell@2
displayName
:
Publish Drop - Binaries Real
inputs
:
arguments
:
'
-Source
Binaries\$(BuildConfiguration)
-Target
$(DropRoot)\Roslyn-Signed\$(Build.SourceBranchName)\$(BuildConfiguration)\$(Build.BuildNumber)
-ParallelCount
8
-Exclude
UnitTests,PerfTests'
filePath
:
'
build\scripts\vsts-robocopy.ps1'
condition
:
succeededOrFailed()
# Copy additional files to the drop directory
-
task
:
PowerShell@2
displayName
:
Publish Drop - VSSetup
...
...
0
0 → 100644
浏览文件 @
60fd993c
B
2
build/scripts/build-utils.ps1
浏览文件 @
60fd993c
...
...
@@ -27,36 +27,70 @@ function Exec-Block([scriptblock]$cmd) {
}
}
function
Exec-CommandCore
([
string
]
$command
,
[
string
]
$commandArgs
,
[
switch
]
$useConsole
=
$true
)
{
# This will exec a process using the console and return it's exit code. This will not
# throw when the process fails.
function
Exec-Process
([
string
]
$command
,
[
string
]
$commandArgs
)
{
$startInfo
=
New-Object
System.Diagnostics.ProcessStartInfo
$startInfo
.
FileName
=
$command
$startInfo
.
Arguments
=
$commandArgs
$startInfo
.
UseShellExecute
=
$false
$startInfo
.
WorkingDirectory
=
Get-Location
if
(
-not
$useConsole
)
{
$startInfo
.
RedirectStandardOutput
=
$true
$startInfo
.
CreateNoWindow
=
$true
$process
=
New-Object
System.Diagnostics.Process
$process
.
StartInfo
=
$startInfo
$process
.
Start
()
|
Out-Null
$finished
=
$false
try
{
while
(
-not
$process
.
WaitForExit
(
100
))
{
# Non-blocking loop done to allow ctr-c interrupts
}
$finished
=
$true
$process
.
ExitCode
}
finally
{
# If we didn't finish then an error occured or the user hit ctrl-c. Either
# way kill the process
if
(
-not
$finished
)
{
$process
.
Kill
()
}
}
}
function
Exec-CommandCore
([
string
]
$command
,
[
string
]
$commandArgs
,
[
switch
]
$useConsole
=
$true
)
{
if
(
$useConsole
)
{
$exitCode
=
Exec-Process
$command
$commandArgs
if
(
$exitCode
-ne
0
)
{
throw
"Command failed to execute with exit code
$(
$process
.
ExitCode
)
:
$command
$commandArgs
"
}
return
}
$startInfo
=
New-Object
System.Diagnostics.ProcessStartInfo
$startInfo
.
FileName
=
$command
$startInfo
.
Arguments
=
$commandArgs
$startInfo
.
UseShellExecute
=
$false
$startInfo
.
WorkingDirectory
=
Get-Location
$startInfo
.
RedirectStandardOutput
=
$true
$startInfo
.
CreateNoWindow
=
$true
$process
=
New-Object
System.Diagnostics.Process
$process
.
StartInfo
=
$startInfo
$process
.
Start
()
|
Out-Null
$finished
=
$false
try
{
if
(
-not
$useConsole
)
{
# The OutputDataReceived event doesn't fire as events are sent by the
# process in powershell. Possibly due to subtlties of how Powershell
# manages the thread pool that I'm not aware of. Using blocking
# reading here as an alternative which is fine since this blocks
# on completion already.
$out
=
$process
.
StandardOutput
while
(
-not
$out
.
EndOfStream
)
{
$line
=
$out
.
ReadLine
()
Write-Output
$line
}
# The OutputDataReceived event doesn't fire as events are sent by the
# process in powershell. Possibly due to subtlties of how Powershell
# manages the thread pool that I'm not aware of. Using blocking
# reading here as an alternative which is fine since this blocks
# on completion already.
$out
=
$process
.
StandardOutput
while
(
-not
$out
.
EndOfStream
)
{
$line
=
$out
.
ReadLine
()
Write-Output
$line
}
while
(
-not
$process
.
WaitForExit
(
100
))
{
...
...
@@ -65,7 +99,7 @@ function Exec-CommandCore([string]$command, [string]$commandArgs, [switch]$useCo
$finished
=
$true
if
(
$process
.
ExitCode
-ne
0
)
{
throw
"Command failed to execute:
$command
$commandArgs
"
throw
"Command failed to execute
with exit code
$(
$process
.
ExitCode
)
:
$command
$commandArgs
"
}
}
finally
{
...
...
build/scripts/vsts-robocopy.ps1
浏览文件 @
60fd993c
...
...
@@ -3,105 +3,55 @@
[
CmdletBinding
()]
param
(
[
Parameter
(
Mandatory
=
$true
)]
[
string
]
$
S
ource
,
[
string
]
$
s
ource
,
[
Parameter
(
Mandatory
=
$true
)]
[
string
]
$
T
arget
,
[
string
]
$
t
arget
,
[
Parameter
(
Mandatory
=
$true
)]
[
int
]
$
P
arallelCount
,
[
int
]
$
p
arallelCount
,
[
Parameter
(
Mandatory
=
$false
)]
[
string
]
$File
)
# This script translates the output from robocopy into UTF8. Node has limited
# built-in support for encodings.
#
# Robocopy uses the system default code page. The system default code page varies
# depending on the locale configuration. On an en-US box, the system default code
# page is Windows-1252.
#
# Note, on a typical en-US box, testing with the '' character is a good way to
# determine whether data is passed correctly between processes. This is because
# the '' character has a different code point across each of the common encodings
# on a typical en-US box, i.e.
# 1) the default console-output code page (IBM437)
# 2) the system default code page (i.e. CP_ACP) (Windows-1252)
# 3) UTF8
[
string
]
$file
,
[
Parameter
(
Mandatory
=
$false
)]
[
string
[]]
$exclude
)
$Error
ActionPreference
=
'Stop'
Set-StrictMode
-version
2.0
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default.
$stdout
=
[
System.Console
]::
OpenStandardOutput
()
$utf8
=
New-Object
System.Text.UTF8Encoding
(
$false
)
# do not emit BOM
$writer
=
New-Object
System.IO.StreamWriter
(
$stdout
,
$utf8
)
[
System.Console
]::
SetOut
(
$writer
)
try
{
.
(
Join-Path
$PSScriptRoot
"build-utils.ps1"
)
# All subsequent output must be written using [System.Console]::WriteLine(). In
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer.
if
(
!
$File
)
{
$File
=
"*"
;
}
if
(
!
$File
)
{
$File
=
"*"
;
}
# Print the ##command. The /MT parameter is only supported on 2008 R2 and higher.
if
(
$ParallelCount
-gt
1
)
{
[
System.Console
]::
WriteLine
(
"##[command]robocopy.exe /E /COPY:DA /NP /R:3 /MT:
$ParallelCount
`"
$Source
`"
`"
$Target
`"
`"
$File
`"
"
)
}
else
{
[
System.Console
]::
WriteLine
(
"##[command]robocopy.exe /E /COPY:DA /NP /R:3
`"
$Source
`"
`"
$Target
`"
`"
$File
`"
"
)
}
$commandLine
=
"/E /COPY:DA /NP /R:3 "
if
(
$parallelCount
-gt
1
)
{
$commandLine
+=
"/MT:
$parallelCount
"
}
# The $OutputEncoding variable instructs PowerShell how to interpret the output
# from the external command.
$OutputEncoding
=
[
System.Text.Encoding
]::
Default
$commandLine
+=
"
$source
$target
$file
"
# Usage :: ROBOCOPY source destination [file [file]...] [options]
# source :: Source Directory (drive:\path or \\server\share\path).
# destination :: Destination Dir (drive:\path or \\server\share\path).
# file :: File(s) to copy (names/wildcards: default is "*.*").
# /E :: copy subdirectories, including Empty ones.
# /COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
# (copyflags : D=Data, A=Attributes, T=Timestamps).
# (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).
# /NP :: No Progress - don't display percentage copied.
# /MT[:n] :: Do multi-threaded copies with n threads (default 8).
# n must be at least 1 and not greater than 128.
# This option is incompatible with the /IPG and /EFSRAW options.
# Redirect output using /LOG option for better performance.
# /R:n :: number of Retries on failed copies: default 1 million.
#
# Note, the output from robocopy needs to be iterated over. Otherwise PowerShell.exe
# will launch the external command in such a way that it inherits the streams.
#
# Note, the /MT parameter is only supported on 2008 R2 and higher.
if
(
$ParallelCount
-gt
1
)
{
&
robocopy.exe
/E
/COPY:DA
/NP
/R:3
/MT:
$ParallelCount
$Source
$Target
$File
2
>
&
1
|
ForEach-Object
{
if
(
$_
-is
[
System.Management.Automation.ErrorRecord
])
{
[
System.Console
]::
WriteLine
(
$_
.
Exception
.
Message
)
}
else
{
[
System.Console
]::
WriteLine
(
$_
)
if
((
$null
-ne
$exclude
)
-and
(
$exclude
.
Length
-gt
0
))
{
$commandLine
+=
"/XD "
foreach
(
$e
in
$exclude
)
{
$commandLine
+=
"
$e
"
}
}
}
else
{
&
robocopy.exe
/E
/COPY:DA
/NP
/R:3
$Source
$Target
$File
2
>
&
1
|
ForEach-Object
{
if
(
$_
-is
[
System.Management.Automation.ErrorRecord
])
{
[
System.Console
]::
WriteLine
(
$_
.
Exception
.
Message
)
}
else
{
[
System.Console
]::
WriteLine
(
$_
)
}
Write-Host
"robocopy
$commandLine
"
$exitCode
=
Exec-Process
"robocopy"
$commandLine
if
(
$exitCode
-gt
8
)
{
Write-Host
"robocopy failed
$exitCode
"
}
}
[
System.Console
]::
WriteLine
(
"##[debug]robocopy exit code '
$LASTEXITCODE
'"
)
[
System.Console
]::
Out.Flush
()
if
(
$LASTEXITCODE
-ge
8
)
{
exit
$LASTEXITCODE
exit
0
}
catch
{
Write-Host
$_
Write-Host
$_
.
Exception
Write-Host
$_
.
ScriptStackTrace
exit
1
}
exit
0
\ No newline at end of file
docs/contributing/Powershell Guidelines.md
浏览文件 @
60fd993c
...
...
@@ -113,3 +113,16 @@ Invoke-Expression "& $command $args"
Exec-Command
$command
$args
```
## Comarisons with null
Whenever comparing with
`$null`
always make sure to put
`$null`
on the left hand side of the
operator. For non-collection types this doesn't really affect behavior. For collection types though
having a collection on the left hand side changes the meaning of
`-ne`
and
`-eq`
. Instead of checking
for
`$null`
it will instead compare collection contents.
```
powershell
# DO NOT
if
(
$e
-ne
$null
)
{
...
}
# DO
if
(
$null
-ne
$e
)
{
...
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录