visual-studionugetnuget-packagevisual-studio-2019

VS2019 is dropping my references when I save the script?


So I'm following this tutorial here in an attempt to get data from a REST API:

https://www.c-sharpcorner.com/article/how-to-consume-web-api-through-ssis-package/

And I've followed all the steps, had to figure out how to use nuget to get an outdated package that it was missing, and the 'response' in Async threw errors, but that's fine. Anyways, I am getting this error that the guide seems to vaguely cover, but I don't understand it.

Error: 0x1 at Script Task: Could not load file or assembly 'System.Net.Http.Formatting

This is when I save the script and try to run it. I notice that when I go back into the editor, the nuget package is gone...? Why is that? It's the "Microsoft.AspNet.WebApi.Client" one. I keep re-installing it, but then VS just "loses" it when I save the script and exit the editor. I open the script task again, and have to reinstall it like I never did the first time.


Solution

  • This is when I save the script and try to run it. I notice that when I go back into the editor, the nuget package is gone...? Why is that?

    You should register these DLLs into GAC so that VSTA project can take reference directly.

    Solution

    1) Open Powershell and then enter into the path of these DLLS:

     cd "Path of dll"
    

    2) register any msissing DLLs just like this way:

    gacutil /i System.Net.Http.Formatting.dll
    gacutil /i Newtonsoft.Json.dll
    

    3) do not forget to check these two options under Tools-->Options-->Nuget Package Manager-->General

    enter image description here

    4) after adding these into GAC, you can open ssis package script task again to check whether ther references are restored or not.