-2

I have an Azure bot service solution, which is in my VSTS Git repository.

enter image description here

I am using Task Runner in visual studio to compile, run and debug code on my local machine.

Similarly, I want to build and compile the code in my VSTS build pipeline, like how we do build using Visual Studio template for .Net applications

enter image description here

I am very new to Bot service projects where it having C# Script files.

I have seen msdn documents all are mentioned Continuous Integration where it will directly link to my Git repo branch. Whenever I commit code it automatically push to My Azure Bot Service, here I want to make sure the code I commit should be compile before push to Azure Bot service. For that I want to setup a Build pipeline.

Can anyone know how to setup a build pipeline for this kind of projects which having C# Script files?

UPDATE:

In my local PC I have installed Azure Functions CLI tools, and Command Task Runner extension to visual studio. I followed the below link to enable debugging locally enter link description here

Task runner running debughost.cmd file which is in my Bot Service code, it contains the following code

    @echo off
set size=0
call func settings list -data > %temp%\settings-list
call :filesize %temp%\settings-list
if NOT %size% == 0 goto show
@echo ----------------------------------------------------------------------
@echo To fetch your bot service settings run the following command:
@echo     func azure functionapp fetch-app-settings [YOUR_BOT_SERVICE_NAME]
@echo func azure functionapp fetch-app-settings AthenaDevbvpn6xsu2tz6i
@echo ----------------------------------------------------------------------

goto start

:show
type %temp%\settings-list
erase %temp%\settings-list 

:start
@func host start -p 3978 
goto :eof

:filesize
  set size=%~z1
  exit /b 0

Output in task runner is

enter image description here

narendramacha
  • 550
  • 6
  • 24
  • How do you compile project in local? Such as Gulp, Grunt etc... – starian chen-MSFT Dec 16 '16 at 01:44
  • @starain-MSFT I have updated my question with more Info how I am debugging locally. Can you please guide me on how can I debug in Build Step? – narendramacha Dec 19 '16 at 05:31
  • I made a test, the build process will be remain in run debughost.cmd (Command line step) and can't be finished, you can't debug it. – starian chen-MSFT Dec 19 '16 at 06:57
  • @starain-MSFT Is there any other way to build this kind of projects in VSTS build? If have any example that would help. – narendramacha Dec 19 '16 at 09:37
  • @narendramacha The build is used to build your code and publish the build output to some where for test or deploy. Why do you want to debug it from the VSTS build? – Eddie Chen - MSFT Dec 20 '16 at 03:24
  • @Eddie-MSFT I have two branches one is Dev and another one is master, then I setup a pull request build on master. When I do pull request on master I want to make sure that the code should not have compilation errors (I just want to compile the code not debugging). In pull request build one of the step want to have compile the Bot service code. Until the pull request build succeed I am blocking the code merge on master branch. – narendramacha Dec 20 '16 at 07:21

2 Answers2

2

There isn't any out of box task to compile CSX file for now. Following is the workaround I can think for your scenario but which is not perfect:

  1. Deploy your own build agent and then configure it by following the steps in the link you provided: Debugging C# bots built using the Azure Bot Service on Windows.
  2. Create a powershell script to call the Azure Function CLI to compile the csx file like the "debughost.cmd" did and check if there is any error occur during the compilation.
  3. Upload the powershell script into the source control.
  4. Add a powershell script task in your build definition to call the powershell script you created.
  5. Save and queue the build definition.

Here is the powershell script I created for your reference:

##Run Azure Func command to compile csx file
$compile = Start-Process 'func' -passthru -WorkingDirectory '.' -ArgumentList 'host start -p 3739' -RedirectStandardOutput 'output.txt'
##You need to set the sleep time base on the build time of your project
Start-Sleep -s 20
Stop-Process $compile -Force
Stop-Process -Name 'Func'

##Get the output from Func and check if there is error in the output
$boutput = Get-Content 'output.txt'
Write-Host 'Azure Function CLI Log:'
Write-Host '*****************************************************************************************************************************'
$boutput
Write-Host '*****************************************************************************************************************************'

$reg = "Function.compilation.error"
foreach($line in $boutput){
    if($line -match $reg)
    {
        ##Fail the task if function compilation error exist
        Write-Host '##vso[task.logissue type=error]Error occur during function compilation'
        Exit 1
    }
 }
 Write-Host 'Function compilation success!'

And you will get this result if the compilation failed: enter image description here

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
1

For Azure Bot Service, set continuous integration with master branch of your repository in VSTS, for repository in VSTS, you can create a new branch, such as Dev, then do work with Dev branch and merge to master. After that the code will be updated to azure.

Simple Steps:

  1. Set continuous integration to your repository (master branch) in VSTS
  2. Go to Code page of your repository in VSTS
  3. Select Branches
  4. Click New branch (e.g. dev)
  5. Clone dev branch to your local and work with it (e.g. modify)
  6. Push changes to remote Dev branch
  7. Create a build definition
  8. Enable Allow Scripts to Access OAuth Token option in Options tab. enter image description here
  9. Add a step to build app (e.g. gulp) according how do you build in local
  10. Add Command Line step

enter image description here

  1. Add Command Line step

enter image description here

  1. Add Command Line step

enter image description here

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53