SSIS Script Tasks losing code - sql-server

I have a very strange issue happening that is causing Script Task code to clear out. I have been able to test on 2-3 different machines. We are running SSDT 15.4 preview. The steps to reproduce were as follows.
Create a script task inside of a foreach loop container.
Create a comment in the script task.
Change or add a variable mapping in the foreach.
Save package.
Close the package.
Open the package.
Open the script task and the comment will have vanished.
As my last attempt for success,I have upgraded to 15.5.1 and the problem still exists.

If you close/Cancel the Script Task Editor form in Visual Studio after editing code, the code will not save. This will occur even if the code was saved in the other Visual Studio editor - the one where you edit the code.
You MUST click "OK" for the code to save.

If there is some error in the script it is not saved. Check your script for errors in the menu Build / Run Code Analysis on Solution or pressing Alt+F11

I had something similar. All code was being stripped when I imported the packages into SQL Server. For us it turned out SSMS was silently stripping code with an incompatible DTS version. SSMS v18 was removing scripts built with DTSv14. Once I opened them in a new version of Visual Studio, moved one "block" 1px over, then saved, it changed the package to DTSv15, which then imported fine using SSMS v18.
Just to verify, I tried using SSMS v17 with the DTSv14 package, and the Script Tasks were left alone and imported fine. But for other reasons we need to be using SSMS v18.

Related

Converting 2008 ssis to 2019 - package configuration not working in debug

I have been using XML config files for a long time. I know there are thousands of post on this. Most are not about SSIS VS2019. The ones that I found that do stop at how to setup packages. None explain what happens if it doesn't work. Upgraded all my packages from SSIS 2008 to 2019. Everything converts good except scripts. I setup my package configuration and try to run in debug it is still using the values in the package not the config file. I Also tried running them in Server Agent with the same results. Not sure where I went wrong or if its a SSIS BI issue. Please help, Thank you.
Add a existing 2008 package to my project
Had to rewrite all the scripts by copping the code. Create a new Script task\component. Paste the code in the new script close the window. Ran the project on my local DB. Everything worked.
Click on the packages background and then in the properties window open Configurations collection selected enable configurations.
Add a new configuration. Select values for Initial Catalog, Server Name, StartupDir, InputDir, ArchiveDir. Now points to Dev server and input directories.
Save the configuration.
In the package, I can now right click on the back screen and see Package Configurations as a selection. I open it and package configuration's is enabled and the file is visible.
Close the configuration put a breakpoint in the package.
Click Start, Check the variables in the locals window. They do not have the configured values.
If i let it run it updates my local db not the DEV one.
I ended up having to change the protection level to DontSaveSensitive and changing the target version to 2019. My local server is 2016 so not sure why DEV and Prod are 2019 so if I can debug on 2016 with a 2019 target I'm good with that.
Warning for anyone trying this. After doing this I received a bunch of errors when I tried to open packages with scripts. I had to open the script and close it to rebuild. Then it worked and the massage went away.
And before I forget there's this annoying little message. I just ignored it.
Please try to change SSIS Project/Package(s) ProtectionLevel setting to DontSaveSensitive.
Starting from SSIS 2012 onwards the preferred way is to use Project/Package level parameters instead of XML config files.

Package part debugging is not supported when starting SSIS package

This very strange issue. When I press the start button to execute the SSIS project it shows "Package part debugging is not supported" and nothing else. I create a control flow with the data flow task and execute SQL task. I have a simple use case to count rows using variable and store package names and the number of rows in a table on the SQL server. When I open error list it shows
Error saving PackagePart1.dtsxp: Control flow package part need to contain exactly one executable.
C:\Users\pcp\Documents\Visual Studio 2015\Projects\Transformations\Transformations\PackagePart1.dtsxp
.
Try to change the Debug to Release mode in Visual studio, build and Retry.It worked for me.

SSIS - package works in VS, fails with "Failed to compiled scripts contained in the package". There are no script objects in the package

VS2017, Deploy to SS2016. Package runs without any errors from VS. Project deployment to a server that previously had package deployments only - we're moving to project deployment, and DBAs said to use that.
Getting many errors like:
Get Error Information:Error: Failed to compiled scripts contained in the package. Open the package in SSIS Designer and resolve the compilation errors.
The package has absolutely no script objects. I've checked with the package explorer, and there isn't even a scripts section. To verify, I added an empty script, and then the explorer did show that section.
Other info: Package deployment is new to our DBAs. They are completely mystified by this, and other errors, like:
Get Error Information:Error: CS2001 - Source file 'C:\Windows\TEMP.NETFramework,Version=v4.0.AssemblyAttributes.cs' could not be found, CSC, 0, 0
My opinion, unexpert in SSIS as I am, is that these servers are not set up or configured properly in some way, but I am out of my depth in this, and DBAs are floundering. What might I do to get to the root of this?
I ended up side-stepping the issue by essentially recreating the package. Even XML search revealed no scripts, so the assumption was some kind of corruption. The package was recently upgraded to package-deployment - perhaps that action had a hand in the problem.
We had the same issue and isolated the problem to a Script Task (regardless of language) that existed in a Sequence Container. Placing the Script Task outside the Sequence Container, and upgrading the package to 2016 worked. The package was originally 2012 (as far as I can see) and the server side SSIS was 2016 13.2.5426.0. We were using VS 2017 as well.
For me this was happening because I was targeting the wrong database version. in your SSIS Package project go into properties and set the TargetServerVersion appropriately And then recompile the project and redeploy to sql server.

C# code disapeared from script task after saving with "There is a compilation error. Do you want to save anyway" message

I am using VS2015 for SSIS development. My package consists of a script task which is very complex (has a number of classes and tricky logic). I made some modification to a class (in the script task), saved the modification, and wanted to close "Microsoft Visual Studio Tools for Applications 2015" which is used for working with C# code in SSIS. I received a VS message that my code had a compilation error, and it gave me a choice of "saving" anyway\"not saving". Since I was running out of work time, I hit "Save" and thought I would deal with the issue later.
Now when I open my SSIS project->script task, I can see that all my classes have gone. There is only one auto generated "ScriptMain.cs" that can be found.
Is there a way I can restore all my work? I cannot believe all code can just disappear if you press "save file" when a compilation error.
Any help is appreciated!
There are many thread in the Visual Studio developer community talking about a software bug found in Visual Studio 2015 and 2017 and it is mentioned that is fixed in the latest releases. I don't think you can try anything more than searching the Script Task project temp directory and the package bin folder if it contains an old version of the package.
The issue was mentioned in the following links:
Developer community - SSIS Script Task losing code
Developer community - Script task losing code
MSDN - Script Tasks losing code for Visual Studio 2015
Developer community - Script Task losing code in SSDT 15.8.0
All links mentioned that you have to install the latest release in order to prevent the error from occurring next time.

Cannot debug a script task

I exported a package from the production server (.ispac) to my local computer and opened in SQL Server Data Tools 2015 since I need to make some changes in the work flow. This package also include a script task which I need to alter and debug.
I added a break-point in the code, the problem is that when I run the package from Data Tools, VS 2015 opens but the below error is show and VS 2015 closed immediately and therefore I an not able to debug the code.
I have been trying to solve this for a couple of hours and viewed various post but no success.
I already: Set Run64BitRuntime = False
If I remove all the breakpoints and run the package all tasks will succeed but the script task is not doing what it is intended for... (this is why I need to debug).
I am stuck and not able to fix the code!
This is a reference issue. The references (dll's) version on your production server are different from the installed dlls on your loxal computer.
Try removing all reference used inside the script task and adding them again.
useful links
https://mitchellpearson.com/2015/04/13/upgrading-script-tasks-in-ssis-target-of-invocation-on-script-task/
DTS Script Task Runtime Error: Exception has been thrown by the target of an invocation
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/78373e2b-b4ea-4ce2-9590-b624a284d538/runtime-error-exception-has-been-thrown-by-the-target-of-an-invocation-from-script-task?forum=sqlintegrationservices
"Runtime error Exception has been thrown by the target of an invocation" from Script task

Resources