首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在TeamCity构建结果中显示` `dnu发布‘异常

在TeamCity构建结果中显示` `dnu发布‘异常
EN

Stack Overflow用户
提问于 2015-09-01 18:07:19
回答 1查看 424关注 0票数 2

我花了大约3天的时间来安装TeamCity来构建和发布asp.net-5项目。最后,我通过使用dnu publish命令发布站点来做到这一点。我使用批处理文件来执行以下命令

代码语言:javascript
复制
// stops the apppool for 'samplesite' overvise it returns exception
// The process cannot access the file '...' because it is being used by another process
call "%windir%\system32\inetsrv\appcmd" stop apppool "samplesite"

// publish the site to the --out dir
call "C:\Users\Administrator\.dnx\runtimes\dnx-coreclr-win-x86.1.0.0-beta6\bin\dnu" publish --out "F:\Sites\samplesite" --runtime dnx-clr-win-x86.1.0.0-beta6

// copies the 'prod' config.json
copy "..\..\build\configuration\samplesite\config.json" "F:\Sites\samplesite\approot\src\samplesite\config.json" /Y

// copies the 'prod' web.config
copy "..\..\build\configuration\samplesite\web.config" "F:\Sites\samplesite\wwwroot\web.config" /Y

// starts the  apppool for 'samplesite'
call "%windir%\system32\inetsrv\appcmd" start apppool "samplesite"

问题是

  1. 是否可以从dnu publish命令返回错误/异常以显示发布失败?例如,在发布时我可以得到一个异常
    • 进程无法访问文件.或
    • 路径长度不能超过260个字符.

但是TeamCity构建结果将显示为Success,所以我总是需要检查它是否真的完成了,没有任何例外。

  1. 还有其他更好的方式/脚本来发布asp.net-5站点吗?也许我只是做错了什么。
EN

回答 1

Stack Overflow用户

发布于 2015-09-14 21:58:31

现在有点晚了,但我有件事一直在为我们工作。我一直在使用powershell脚本来包装命令行调用。因为它是PS,所以您可以尝试/捕获,然后在catch中使用##teamcity属性将失败标记为##teamcity。还请确保退出时使用的状态代码不是0。请注意,我使用状态代码1强制退出,以指示失败。最后,确保PS脚本中的任何命令行调用都以"&“作为前缀。

例如,要调用DNU发布(我使用在team中设置的环境变量来指示dnx版本)。

代码语言:javascript
复制
try
{
    & dnvm use $env:dnxversion -arch x64
    & dnu publish --no-source --configuration Release --runtime dnx-clr-win-x64.$env:dnxversion 
}
catch
{
    Write-Error $_
    ##teamcity[buildStatus status='FAILURE']
    [System.Environment]::Exit(1)
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32338218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档