# ===== SECTION TO UPDATE ====
$SL_TOKEN="123456789" #Prefer an Env variable from your Credentials Manager
# Env specific
$SL_BSID_FILE="$SEALIGHTS_PATH\buildSessionId.txt"
$SL_ENV_LABID="TestLabEnv@Automation"
#App specific
$SL_ServiceName="YourService"
$SL_ProcessName="YourService.exe"
# ============================
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$previousProgressPref=$global:ProgressPreference && $global:ProgressPreference = "SilentlyContinue" #Disable Progress bar topowershell speed up download and expand
### Install Agent and Token ###
iwr -OutFile sealights-dotnet-agent.zip -UseBasicParsing -Uri https://agents.sealights.co/dotnetcore/latest/sealights-dotnet-agent-windows-self-contained.zip
Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath sl-dotnet-agent -Force
Write-Output "[Sealights] .NetCore Agent version is: $(Get-Content .\sl-dotnet-agent\version.txt)"
$global:ProgressPreference = $previousProgressPref #Restore progress bar
Out-File -Input-Object $SL_TOKEN -NoNewline -Force ".\sl-dotnet-agent\sltoken.txt"
### Install SL Collector Service ###
Invoke-Expression .\sl-dotnet-agent\SL.DotNet.CoverageCollectorService.exe install start
Invoke-Expression .\sl-dotnet-agent\SL.DotNet.exe instrumentService --serviceName $SL_ServiceName --force
Restart-Service -Name $SL_ServiceName -Force
### Stop all session for specific Service version if they exist ###
SL.DotNet.exe stopCollectorServiceSession --buildSessionIdFile $SL_BSID_FILE --labId $SL_ENV_LABID --processName $SL_ProcessName
### Starting session for specific Service version ###
Invoke-Expression .\sl-dotnet-agent\SL.DotNet.exe startCollectorServiceSession --buildSessionIdFile $SL_BSID_FILE --processName $SL_ProcessName --labId $SL_ENV_LABID `
--includeChildProcesses true `
--logAppendConsole true
#### You can start your tests ####