Upgrading SSIS Packages to 2017 The purpose of this question is to document my answer to what seemed to be a strange issue when changing the target SQL Server version of an SSIS package created in some older versions of SSIS prior to 2012 that use script tasks.

An SSIS package originally created in BIDS 2005 or 2008 had no issues when upgraded through the various versions of BIDS/SSDT over the years. Even now when the package was upgraded to SSDT and targeting SQL Server 2016 everything still worked as it always has in addition to being able to take advantage of the latest SSIS features (package parts, project parameters, etc.) and deploying the package through SSDT/Visual Studio to the same target SQL Server. SQL Servers with SSIS installed that were upgraded to 2016 or 2017 seemed to have no issues with packages that were in MSDB or the package store since the jobs continued to run as expected post-upgrade.

So as part of normal upgrade routine, decided to open an SSIS package and upgrade it like before with the previous SSDT changes. In previous SSDT changes, one release worked for a particular version of SSIS. Once they introduced the ability to target some previous versions of SSIS, that feature seemed to work as expected. I figured things would be the same with the latest SSIS and SSDT versions.

However, once changing the target version to SQL Server 2017 within SSDT, there are some things that showed up that SSDT did not catch/fix or could not handle for some reason. Some of the issues I ran into were:


Cannot change the target .Net Framework version as it always reverts
back to original settings in the script task properties
Errors would show up such as "'Dts' is not a member of 'Microsoft.SQLServer'", "Type 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase' is not defined", "Failed to migrate scripts contained in the package to the VSTA 14.0 format. Move the scripts to a new Script task.", and "Type 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute' is not defined."
Building the script task would fail and one of the errors would be "The primary reference "Microsoft.SqlServer.ScriptTask, Version=14.0.0.0, Culture=Neutral, PublicKeyToken=89845dcd8080cc91" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0" and the other error I would see was "Namespace or type specified in the Imports 'Microsoft.SqlServer.Dts.Runtime' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."


The good thing is changing the target back to SQL Server 2016 seemed to work and I could continue editing the packages as before without errors and build would work as expected but the bad news is deploying the 2016 package to an 2017 SSIS server did not get converted like it did during the SQL Server upgrade. So how would I be able to update the packages to target SQL Server 2017 and not have these issues that prevent that?
The main source of the problem is the tags changed in SSIS schema that 2016 and prior handled without issue. I had to view the code of the SSIS package to check for differences and SSIS 2017 seemed to be a bit more strict when it came to the schema within the PropertyGroup node of the Project tag for the script tasks.

Here is what one tag looked like that had errors:

&lt;PropertyGroup&gt;
  &lt;ProjectTypeGuids&gt;{30D016F9-3734-4E33-A861-5E7D899E18F3};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}&lt;/ProjectTypeGuids&gt;
  &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt;
  &lt;Platform Condition=" '$(Platform)' == '' "&gt;AnyCPU&lt;/Platform&gt;
  &lt;OutputType&gt;Library&lt;/OutputType&gt;
  &lt;RootNamespace&gt;ST_f5177258030742e5ba64fefba1f795ea.vbproj&lt;/RootNamespace&gt;
  &lt;AssemblyName&gt;ST_f5177258030742e5ba64fefba1f795ea.vbproj&lt;/AssemblyName&gt;
  &lt;StartupObject&gt;&lt;/StartupObject&gt;
  &lt;OptionExplicit&gt;On&lt;/OptionExplicit&gt;
  &lt;OptionCompare&gt;Binary&lt;/OptionCompare&gt;
  &lt;OptionStrict&gt;Off&lt;/OptionStrict&gt;
  &lt;OptionInfer&gt;On&lt;/OptionInfer&gt;
  &lt;ProjectGuid&gt;{D93B5E70-A7E9-4AA1-94E7-7859FE6B3672}&lt;/ProjectGuid&gt;
&lt;/PropertyGroup&gt;


The fix that seemed to solve half of my problems were to add the missing entries so that the above now looked like the below code new entries (which are after &lt;/ProjectGuid&gt; and before &lt;/PropertyGroup&gt;) are: 


ProductVersion
SchemaVersion
AppDesignerFolder
TargetFrameworkVersion
FileAlignment
ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch
TargetFrameworkProfile


Here is what it looked like after adding the changes:

&lt;PropertyGroup&gt;
  &lt;ProjectTypeGuids&gt;{30D016F9-3734-4E33-A861-5E7D899E18F3};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}&lt;/ProjectTypeGuids&gt;
  &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt;
  &lt;Platform Condition=" '$(Platform)' == '' "&gt;AnyCPU&lt;/Platform&gt;
  &lt;OutputType&gt;Library&lt;/OutputType&gt;
  &lt;RootNamespace&gt;ST_f5177258030742e5ba64fefba1f795ea.vbproj&lt;/RootNamespace&gt;
  &lt;AssemblyName&gt;ST_f5177258030742e5ba64fefba1f795ea.vbproj&lt;/AssemblyName&gt;
  &lt;StartupObject&gt;&lt;/StartupObject&gt;
  &lt;OptionExplicit&gt;On&lt;/OptionExplicit&gt;
  &lt;OptionCompare&gt;Binary&lt;/OptionCompare&gt;
  &lt;OptionStrict&gt;Off&lt;/OptionStrict&gt;
  &lt;OptionInfer&gt;On&lt;/OptionInfer&gt;
  &lt;ProjectGuid&gt;{D93B5E70-A7E9-4AA1-94E7-7859FE6B3672}&lt;/ProjectGuid&gt;
  &lt;ProductVersion&gt;8.0.30703&lt;/ProductVersion&gt;
  &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
  &lt;AppDesignerFolder&gt;My Project&lt;/AppDesignerFolder&gt;
  &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
  &lt;FileAlignment&gt;512&lt;/FileAlignment&gt;
  &lt;ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch&gt;true&lt;/ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch&gt;
  &lt;TargetFrameworkProfile&gt;&lt;/TargetFrameworkProfile&gt;
&lt;/PropertyGroup&gt;


Doing this did not fix the issue with inability to change .Net Framework target so there had to be something else so I looked through the code and found the problem. In the code I found the following after &lt;/ProjectExtensions&gt;:

&lt;PropertyGroup&gt;
  &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
&lt;/PropertyGroup&gt;
&lt;PropertyGroup&gt;
  &lt;TargetFrameworkProfile&gt;&lt;/TargetFrameworkProfile&gt;
&lt;/PropertyGroup&gt;


Since these were now located in the main PropertyGroup of the script task, they are considered redundant so they are no longer needed in the old location. Deleting these entries fixed the other half of the problem. After doing this, not only was I able to change the SQL Server target to 2017, I was also able to change the .Net Framework version and it would not revert. Also, the builds were able to build successfully again.

Fixing the problem this way was easier than to try opening every package and manually creating a new script task, copying the logic from the old one to the new one, making sure the variables and references were the same, and deleting the old task, among other things. That process would take too long especially if there are a lot of packages to go through.

Hopefully you find this useful if you run into this issue.