Automate Visual Studio 2019

Terry St Jean 81 Reputation points
2022-07-12T11:34:52.19+00:00

Hi,
We support multiple versions of SQL Server and when deploying SSIS packages, we need to produce each package for each version of SQL Server (2019/2017/2016/2014/2012).
So, in Visual Studio 2019, I make a change to a package in 2019, copy off the 2019 version of the .dtsx, then for each other version, change the TargetServerDeployment to the next version of SQL Server, copy off the dtsx, then the next version, copy off the dtsx etc.
Is there a way in Visual Studio to automate this process?

Thanks,
Terry

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,643 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 40,431 Reputation points
    2022-07-13T06:39:06.713+00:00

    Hi @Terry St Jean ,

    It is a little difficult to do that.

    Maybe you may try with PowerShell script.

    Here is a blog you may take a carefully reference to.

    deployment-automation-for-sql-server-integration-services-ssis

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Terry St Jean 81 Reputation points
    2022-07-13T11:09:46.257+00:00

    That you Zoe.
    Not quite what I was looking for. I need to convert 2019 SSIS packages to prior versions. I'm hoping I can open the solution in VS 2019 and then change the TargetServerDeployment on the project to each of the lower versions so VS takes care of any changes.
    I'm looking for something when , via c#, I can open VS, open the solution, change the TargetServerDeployment of the project, save the solution and then copy the .dtsx files to another folder. Repeat this for each version of SQL server we use.
    I'm current trying to see how in c#, I can open an instance of VS 2019 and then open the solution.
    Thanks,
    Terry

    0 comments No comments

  3. ZoeHui-MSFT 40,431 Reputation points
    2022-07-14T01:29:06.983+00:00

    Hi @Terry St Jean ,

    As mentioned in the blog, it could set the parameter of the target server, so you may have a double check.

    Straightforward deployment to any target server

    The details of the target server can be stored / passed as a parameter to the deployment automation process. The software can be deployed to the new target server with the help of simple configuration changes.

    I agree with your opinion that maybe you could do that via c#, code writing is out of my ability, wish you success.

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. RLWA32 47,031 Reputation points
    2022-07-14T15:21:13.207+00:00

    The following sample automates VS2019 from a C# console application. It accepts the fully qualified path to a solution on the command line. Then it instantiates VS2019 and uses the VS2019 object model to load the solution and print some information about the projects that it contains. Naturally, error checking is minimal.

    Code -

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Text;  
    using System.Threading.Tasks;  
    using System.Runtime.InteropServices;  
      
    namespace VSAuto  
    {  
        class Program  
        {  
            [STAThread]  
            static void Main(string[] args)  
            {  
                EnvDTE.DTE dTE = null;  
                EnvDTE80.DTE2 dTE2 = null;  
                EnvDTE80.Solution2 solution = null;  
                EnvDTE.Projects projects = null;  
                Guid CppGuid = new Guid("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}");  
                Guid CSGuid = new Guid("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");  
                Guid VBGuid = new Guid("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}");  
      
                if (args.Length != 1)  
                    return;  
      
                try  
                {  
                    Type t = Type.GetTypeFromProgID("VisualStudio.DTE.16.0");  
                    dTE = (EnvDTE.DTE)Activator.CreateInstance(t);  
                    dTE2 = (EnvDTE80.DTE2)dTE;  
                    solution = (EnvDTE80.Solution2) dTE2.Solution;  
                    solution.Open(args[0]);  
                    projects = solution.Projects;  
                    Console.WriteLine($"Solution {solution.FullName} contains {projects.Count} projects.");  
                    foreach( EnvDTE.Project proj in projects)  
                    {  
                        Guid projGuid = new Guid(proj.Kind);  
      
                        if (projGuid.Equals(CSGuid))  
                            Console.WriteLine($"Project name is {proj.Name}, project type is C#");  
                        else if (projGuid.Equals(CppGuid))  
                            Console.WriteLine($"Project name is { proj.Name }, project type is C++");  
                        else if (projGuid.Equals(VBGuid))  
                            Console.WriteLine($"Project name is { proj.Name }, project type is VB.Net");  
                        else  
                            Console.WriteLine($"Project name is { proj.Name }, project type is {proj.Kind}");  
      
                        Marshal.ReleaseComObject(proj);  
                    }  
                    solution.Close();  
                }  
                catch (Exception ex)  
                {  
                    Console.WriteLine($"Exception: {ex.Message}");  
                }  
                finally  
                {  
                    if (projects != null)  
                        Marshal.ReleaseComObject(projects);  
      
                    if (solution != null)  
                        Marshal.ReleaseComObject(solution);  
      
                    if (dTE2 != null)  
                    {  
                        dTE2.Quit();  
                        Marshal.ReleaseComObject(dTE2);  
                    }  
      
                    if (dTE != null)  
                        Marshal.ReleaseComObject(dTE);  
      
                }  
            }  
        }  
    }  
      
    

    References added for VS2019 Automation interfaces -

    220700-references.png

    Solution to be Targeted showing the contained projects -

    220768-solution.png

    Results from execution -

    220749-results.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.