6

I have used Microsoft.SqlServer.Dts.Runtime to run package in ASP.NET MVC. However I need to run this in asp.net core. As we cannot add individual dll in asp.net core, I was wondering if anyone has idea if there is nuget package which would help.

Nagashree Hs
  • 843
  • 6
  • 18

3 Answers3

6

Just to elaborate on how I resolved this issue. Below is the answer

To run SSIS package you need below DLLs in the code

  1. Microsoft.SqlServer.ManagedDTS.dll

  2. Microsoft.SqlServer.PipelineHost.dll

  3. Microsoft.SqlServer.DTSRuntimeWrap.dll

  4. Microsoft.SqlServer.DTSPipelineWrap.dll

It is easy to add DLLs in MVC projects, however in asp.net core it needs to be in form of a Nuget package.

So nuget package can be easily created using nuget package explorer. Below is the link

https://docs.nuget.org/create/using-a-gui-to-build-packages

In the nuget package explorer add a lib folder, inside that add a .net folder dnxcore50 and add the above DLLs. Click on tools analyse package and save the nuget

enter image description here

In the visual studio 2015 solution, you can refer local packages. Tools - Nuget Package Manager - Package Manager Settings - Package source add the local package path.

enter image description here

After which you will be able to add the nuget package using nuget package manager and select local package as source

enter image description here

If there is error in restoring package, add dnxcore to imports section and add "Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027" to dependencies in project.json

"dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027",
"SSISPackage": "1.0.0"
 }

"frameworks": {
"netcoreapp1.0": {
  "imports": [
    "dotnet5.6",
    "portable-net45+win8",
    "dnxcore"
  ]
  }
}

After which you will be able to use code to run SSIS package similar to MVC projects.

Application app = new Application();
        Package package = null;
        try
        {
            package = app.LoadPackage(@"C:\Files\Package.dtsx", null);
            Variables vars = package.Variables;
            vars["status"].Value = "ACTIVE";

            DTSExecResult results = package.Execute();

        }
        catch
        {
            return false;

        }
        finally
        {
            package.Dispose();
            package = null;
        }
Nagashree Hs
  • 843
  • 6
  • 18
  • 1
    This is no more an issue in ASP.net core 1.1 Visual studio 2017. We can add individual dlls and use them directly. – Nagashree Hs Jul 24 '17 at 12:50
  • I added directly in 2017 and I got an error *FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.ManagedDTS*. I ran ProcMonitor and there was no trace, so I found this: https://stackoverflow.com/a/43966827/495455 and then I found your NuGet Package https://www.nuget.org/packages/SSISPackage - but that gives me this error: Package SSISPackage 1.0.0 is not compatible with netcoreapp2.0 . – Jeremy Thompson Jul 24 '18 at 05:14
2

You can package the assembly into a nuget package, Create a Lib folder inside your solution to hold the nuget package, then, create a nuget.config file to set the package sources to include the Lib folder inside your solution.

The following links contains more details about creating nuget package and hosting it locally:

Hope that helps

Hossam Barakat
  • 1,399
  • 9
  • 19
2

You may now reference the dlls ( one from each) directly in your .net core project from the below locations to run ssis packages now

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.PipelineHost
C:\Windows\Microsoft.NET\assembly\GAC_64\Microsoft.SqlServer.DTSRuntimeWrap
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap

you no longer need to create a nuget package

Ram
  • 15,908
  • 4
  • 48
  • 41
  • I referenced the dll's you mention above but I still receive the FileNotFoundException for the Microsoft.SqlServer.DTSRuntimeWrap DLL. Any idea's what's wrong? – codingNightmares Jul 22 '21 at 13:12
  • will this be platform independent? will it work on Linux? – A_m0 May 22 '23 at 11:21