mavcp10
mavcp10

Reputation: 51

SSIS Script Component Version/Target .NET Version

I'm trying target .NET 4.5.2 in a script component created in VS 2017. Every time I change the target version in VSTA it reverts back to 4.5. The solution I've seen on several other sites as well as here is to open the script in VSTA, go the properties, and change the target version. No matter how many times I do that, rebuild, restart VS, etc., the target version always changes back to 4.5.

I'm wondering if it's related to the script component version that keeps coming up as 11. That would correspond to SQL 2012. I can't figure out why the script component is being created as version 11. I only have VS 2017 and SQL Server 2017 installed on my machine. That would make me think that the components should be v14. That is not the case and I can't figure out how to change the version.

My true objective is to target .NET 4.5.2. I only mention the script component version as the answer about changing the target version in VSTA does not work for me and I though this might be related.

Upvotes: 1

Views: 1900

Answers (1)

digital.aaron
digital.aaron

Reputation: 5707

This is quite an interesting issue. I've been poking at this problem on my local dev box, and I've found some interesting things.

We have two environments. SQL 2008 R2 with BIDS (VS 2008), and SQL 2016 with SSDT (VS 2017). Using BIDS, I can change the target framework version of a script task as expected. Reloading the script in VSTA always opens the ScriptMain.cs file with the correct framework version set.

In VS 2017, I can open a script task in VSTA, and the target framework always loads as 4.5, as you're seeing. But if I change it to, say 4.5.2, build the solution, close VSTA, and then save and close the package, I can open the .dtsx file in a text editor, and I can see it saved the correct framework version of the task.

I think the issue is that although the script is stored in the package definition, when you edit the script, VSTA opens the script as part of a temporary project. This temporary project seems to target 4.5 by default.

I found that if you set the target framework for the script's temp project to 4.5.2, write all your 4.5.2 code, build the project, save all files, then close VSTA, hit "OK" on the Script Task Editor, and then save your package, your script will save into the package, with the correct target framework. If you attempt to edit the script again, you'll have to go through setting the framework version again.

Upvotes: 1

Related Questions