我花了大约3天的时间来安装TeamCity来构建和发布asp.net-5项目。最后,我通过使用dnu publish命令发布站点来做到这一点。我使用批处理文件来执行以下命令
// 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"问题是
dnu publish命令返回错误/异常以显示发布失败?例如,在发布时我可以得到一个异常
但是TeamCity构建结果将显示为Success,所以我总是需要检查它是否真的完成了,没有任何例外。
发布于 2015-09-14 21:58:31
现在有点晚了,但我有件事一直在为我们工作。我一直在使用powershell脚本来包装命令行调用。因为它是PS,所以您可以尝试/捕获,然后在catch中使用##teamcity属性将失败标记为##teamcity。还请确保退出时使用的状态代码不是0。请注意,我使用状态代码1强制退出,以指示失败。最后,确保PS脚本中的任何命令行调用都以"&“作为前缀。
例如,要调用DNU发布(我使用在team中设置的环境变量来指示dnx版本)。
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)
}https://stackoverflow.com/questions/32338218
复制相似问题