小编Sun*_*ala的帖子

将秘密变量从TFS Build传递给Powershell脚本

我在我的构建定义中添加了名为Password的秘密变量,如下图所示:

TFS构建变量

我想在我的一个构建步骤中将密码传递给PowerShell脚本,如下图所示:

构建步骤

我的PowerShell脚本如下所示

 Param
(
    [Parameter(Mandatory=$true)]
    [string]$UserName,
    [Parameter(Mandatory=$true)]
    [string]$Password
)

$appPool = New-WebAppPool -Name "test"
$appPool.processModel.userName = $userName
$appPool.processModel.password = $password
$appPool.processModel.identityType = "SpecificUser"
$appPool | Set-Item
Run Code Online (Sandbox Code Playgroud)

但看起来密码的类型不是字符串.我尝试PSCredential但没有奏效.有人能帮助我吗?如何将密码从构建步骤传递给PowerShell脚本以及安全变量的类型?我无法直接读取环境变量,因为我在目标计算机上运行PowerShell脚本.因此,唯一的选择是将密码作为输入传递给脚本.

powershell tfsbuild continuous-deployment

8
推荐指数
1
解决办法
3241
查看次数

意外结束Stream,内容可能已被另一个组件读取.Microsoft.AspNetCore.WebUtilities.MultipartReaderStream

当我尝试从请求中读取多部分内容时,我得到一个异常,说明内容可能已被其他组件读取.

 if (MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
            {
                // Used to accumulate all the form url encoded key value pairs in the 
                // request.
                var formAccumulator = new KeyValueAccumulator();

                var boundary = Request.GetMultipartBoundary();
                var reader = new MultipartReader(boundary, HttpContext.Request.Body);
                var section = await reader.ReadNextSectionAsync();
                while (section != null)
                {
                    ContentDispositionHeaderValue contentDisposition;
                    var hasContentDispositionHeader =
                        ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out contentDisposition);
                }
            }
Run Code Online (Sandbox Code Playgroud)

asp.net-core asp.net-core-2.0

7
推荐指数
4
解决办法
6609
查看次数

如何在 Visual Studio 测试结果中包含测试类别

如何确保我在单元测试中使用的测试类别包含在测试结果中。这样我就可以使用类别来过滤我的测试或使用按类别分组的 trx2html 生成 html。

在此输入图像描述

[Trait("Category", "1")]
public class MyFeature1Tests

[Trait("Category", "2")]
public class MyFeature2Tests
Run Code Online (Sandbox Code Playgroud)

我可以在 Visual Studio 测试资源管理器中看到按类别分组的测试。但在测试结果(.trx)文件中不可能吗?

在此输入图像描述

mstest trx test-explorer vstest test-results

5
推荐指数
0
解决办法
443
查看次数