Showing `dnu publish` exceptions in TeamCity build results

I spent about 3 days installing TeamCity to create and publish an asp.net-5 project. Finally, I did this using the dnu publish command to publish the site. I use a batch file to do this with the following commands

 // 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" 

Questions

  • Can I return errors / exceptions from the dnu publish command to indicate that the publication failed? For example, I can get an exception when posting
    • The process cannot access the file ..... or
    • The path length cannot exceed 260 characters ...

BUT the result of TeamCity build will be shown as Success , so I always need to check that it is really finished without any exceptions.

  1. Is there an even better way / script to publish an asp.net-5 site? Maybe I'm just doing something wrong.
+2
c # asp.net-core teamcity dnu
Sep 01 '15 at 18:07
source share
1 answer

It's a little late, but I have something that works for us. I used a powershell script to transfer calls on the command line. Because it's PS, you can do try / catch, and then in catch I use the ## teamcity attribute to mark a failure in the command city. Also make sure that you exit with a status code other than 0. Note that I force the exit with status code 1 to indicate a failure. Finally, make sure that any command line calls in your PS script are preceded by "&".

So, for example, to invoke a DNU publication (I use an environment variable that I set in the command city to indicate the dnx version).

 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
Sep 14 '15 at 21:58
source share



All Articles