How can we help you today? How can we help you today?

MSBuild missing Newtonsoft.Json.dll

Howdy,
Not sure this is the best place to post this, but here goes...
I and some of my team recently upgraded our visual studio 2017/2019 SQL Change Automation extensions to Version 4.3.20205.21469.  
Our solution is currently set up to use (known to be legacy) MSBuild deployments for some steps in our development process.  We're now seeing errors on deployment relating to Newtonsoft.Json.dll.

Setting the diagnostic logging flag for msbuild shows the following output near the error:

Using "DBPatchTask" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\SqlChangeAutomation\RedGate.Versioning.Client.MsBuild.dll".
Task "DBPatchTask" (TaskId:22)
...
  Generating "Path\to\obj\Debug\output.sql"... (TaskId:22)
Path\to\project.sqlproj : error : Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

It took me a fair amount of time to realize I should turn on diagnostic logging and then to find the folder it was looking in for Newtonsoft.Json.dll... and my conclusion is that "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\SqlChangeAutomation\"
is missing Newtonsoft.Json.dll. 

As a test/temporary workaround, I grabbed a net45 version 12 copy of Newtonsoft.Json.dll and threw it into that specific folder, and viola, no more error and I'm back to my normal development process.  

Now, I am aware that MSBuild is a legacy deployment option, and it's advisable to move to powershell cmdlets, but we haven't gotten there yet.  Seeing as your visx installer is still being updated and apparently includes MSBuild support as it's populating binaries in that folder above, here's hoping you can adjust the next version to resolve this.

Thanks!
garrettloy
0

Comments

17 comments

  • Sean_Lively
    Running into the same error while attempting to deploy pending scripts.

    Using SQL Change Automation version: 4.3.20205.21469
    Error:  : Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
    Sean_Lively
    0
  • Sergio R
    Update (July 30th) - This issue has been fixed in  version 4.3.20211 of SQL Change Automation for Visual Studio
    Sergio R
    0
  • JoeHarkins
    @Sergio R We are not yet seeing that version available. 
    This has pretty much stalled my teams work today. 

    Any idea on when it will actually be available to install or is there somewhere we can pull an old version to get things working again?
    JoeHarkins
    0
  • Sergio R
    Visual Studio extensions are set to self-update by default, if that didn't happen in your case, you should be able to get it from the Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=vs-publisher-306627.RedgateSqlChangeAutomation
    Sergio R
    0
  • Sean_Lively
    Downloaded SQL Toolbelt installer today, and it did not update to 4.3.20209
    Downloaded the extension from VS Marketplace per the link, and it did update to 20209:
    Using SQL Change Automation version: 4.3.20209.21516
    Still getting the Newtonsoft.Json error:
    C:\Projects\database\SQLCore\PrimeReporting\PrimeReporting.sqlproj: Error:  : Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

    Sean_Lively
    0
  • JoeHarkins
    Applying the vsix install from the marketplace did not resolve the issue.
    I can see the file in the MSBuild folder referenced above now, but every build still fails. 
    Unlike the originator of this thread, adding the file manually before attempting the vsix install also did not correct the problem.

    My other team members attempted the vsix install without having attempted any manual corrections and also report local builds remain broken after the upgrade.
    JoeHarkins
    0
  • Sean_Lively
    Got a response from RedGate support-
    Newtonsoft.json.dll is missing from the Extensions directory: C:\Program Files (x86)\Microsoft Visual Studio\(Visual Studio Version)\(Visual Studio Edition)\Common7\IDE\Extensions\001rr241.rgs\
    Manually copying the .dll there resolved the problem for me.
    Sean_Lively
    0
  • JoeHarkins
    I just got the same reply from support and it worked perfectly for me too.
    JoeHarkins
    0
  • Sergio R
    I am sorry that this issue is still occurring, like @garrettloy, @Sean_Lively and @JoeHarkins   mentioned this can be worked around by copying Newtonsoft.json.dll version 12 to the appropriate locations (this is probably already present on your system, so it's just a case of searching and copying):

    C:\Program Files (x86)\Microsoft Visual Studio\(Visual Studio Version)\(Visual Studio Edition)\MSBuild\SqlChangeAutomation\
    for example: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\SqlChangeAutomation\

    C:\Program Files (x86)\Microsoft Visual Studio\(Visual Studio Version)\(Visual Studio Edition)\Common7\IDE\Extensions\001rr241.rgs\
    for example C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\001rr241.rgs\

    Sergio R
    0
  • garrettloy
    Just ran through resolving an issue with one of my team members - it seems that for Visual Studio 2017 Professional's 4.3.20209.21516 extension, the dll is still missing from the 001rr241.rgs folder.  

    I also had problems updating my extension after adding the Newtonsoft.Json.dll files manually to the extension folders. I ended up having to remove the mentioned folders entirely in order to successfully uninstall/reinstall. I believe this is due to the uninstall process only removing what it expects to be there, and then leaving Newtonsoft.Json.Dll because the previous installer didn't put it there, then the new installer doesn't expect it to be there and errors out.

    We're unblocked right now but I anticipate my folks having to go in and delete the folders and/or remember to remove newtonsoft.json.dll from those folders when we get another update.
    garrettloy
    0
  • Sergio R
    I am sorry for this issue, we are investigating this and hopefully, this will be fixed in the next version.
    Sergio R
    0
  • Sergio R
    @Sean_Lively
    @JoeHarkins

    Can you let us know what versions of Visual Studio you were using?
    Sergio R
    0
  • JoeHarkins
    We verified the issue was with all the folks using VS 2017.
    JoeHarkins
    0
  • Sean_Lively
    VS2017
    Sean_Lively
    0
  • StevenSegers
    I ran into this same (or a really similar) issue as well just now.
    No windows or VS updates had been installed for a while, but SCA had just gotten automatically updated.
    I found that the folder SqlChangeAutomation had a copy of Newtonsoft.Json.dll, but the folder 001rr241.rgs didn't. I copied the dll from the first to the second folder. After that I could build again without errors.

    OS: Windows 10 Enterprise
    IDE: Visual Studio Enterprise 2017, 15.9.22
    SCA: 4.3.20209.21516 (version that triggered the error. Don't know what the previous version was)
    StevenSegers
    0
  • rchie
    My team just ran into the same issue now. 
    I did the exact same thing that
    StevenSegers did and it fixed the issue.
    rchie
    0
  • Sergio R
    We've now released version 4.3.20211 of SQL Change Automation for Visual Studio which should resolve this
    Sergio R
    0

Add comment

Please sign in to leave a comment.