Question: I need, to clear my chartViewers from a layout, but when I do, I can't delete the last widget.
when I test the length of my layout, I get 0 but the widget is still here after update of the layout, as in the picture : 

[![enter image description here](https://i.stack.imgur.com/dG8xb.png)](https://i.stack.imgur.com/dG8xb.png)

here my code when I delete, the widgets and the graphs

```
print("proceding to delete chart ", chartName, "  at : ", indexGraph)
currentGraph = self.charts[indexGraph]
currentWidget = self.chartVs[indexGraph]

self.chartLayout.removeWidget(currentWidget)
self.chartVs.remove(currentWidget)

currentGraph.clearData()
self.charts.remove(currentGraph)
self.chartLayout.update()

#currentWidget.resetCachedContent()
listGraphs.remove(chartName)
self.refreshListWithOpt(self.chartTree, listGraphs, 1, optGraphs)

```

and here is the code where I create the graphs and add it to the layout: 

```
self.charts.append(chartClass(patientStr, exp))

print("\nNew Plot chart ", self.charts[lastIndex].name, " length : ", lastIndex )

listGraphs.append(self.charts[lastIndex].name)
print("list Graphs : ", listGraphs)
self.charts[lastIndex].plotJSON(myData.plot(patientStr, exp))

self.chartVs.append(QChartView(self.charts[lastIndex]))
self.chartVs[lastIndex].setRenderHint(QPainter.Antialiasing)
self.chartLayout.insertWidget(0, self.chartVs[lastIndex])

```

Any suggestion?

Answer: 
Here is a [link](http://blogs.adatis.co.uk/jonathoneveoconnor/post/Continuous-Integration-With-TeamCity-Automating-SSIS-Build-and-Deployment) that describes the auto-deployment of packages post check-in into SSISDB catalog. If you have SSIS 2012+ then that would be a way to go. Even if not you would need to modify the target to msdb/SSIS file system.

Coming to your second ask, deploy to SQL Agent. You would need to write another build step to do that step of automation. Make use of [T-SQL code](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-add-jobstep-transact-sql) and add the package name as a parameter and have it deployed. The thing to remember about this is that SQL Agent job can have numerous job steps doing various tasks. 

Say if you are deploying 10 packages of project and your requirement demands that all ten to be part of one SQL Server Agent Job, then design your T-SQL Code accordingly. If you need 10 seperate jobs for these packages then your code needs to do that in that manner.

I would strongly advice doing this as a one-time job. If you have the auto-deployment to create Agent when the package gets changed thereby needing to re-create the job, then you would be losing job history.
Generally, In TFS there isn't a way to do that. 

Although we can use the [Checkin command](https://www.visualstudio.com/en-us/docs/tfvc/checkin-command) to check in the changes, but have to identify the changes first. The system will identify the changes and display in **Pending Changes** page. Then we can check in the changes manually by click the **Check in** button or with check in command

So, **Check in** is the required and the first step. You can set [Continuous integration (CI)](https://www.visualstudio.com/en-us/docs/build/define/triggers#continuous-integration-ci) for your build definition which with the "`Deploy to SQL Agent`" steps set, thus the build/deploy will be triggered automatically once any changes be checked in.

Reference below articles: 

* [Deployment to several databases using SQL Server Data Tools and Team
foundation Server](https://www.sqlshack.com/continuous-integration-sql-server-data-tools-team-foundation-server/)
* [Build and Deploy SSIS packages using VSTS](http://abelsquidhead.com/index.php/2016/10/06/build-and-deploy-ssis-packages-using-vsts/)