Search code examples
sql-servervisual-studiosql-server-2012

Object reference not set to an instance of an object: on Publish


When I click a publish button:

PUBLISH BUTTON

on the Database project in Visual Studio I cannot access the publish window and I just get a popup that says Object reference not set to an instance of an object.

ERROR

Therefore any changes to the database are impossible. my co-workers do not have this problem at all and if they had the issue dissapeared after updating Visual Studio

What I tried

  • Deleting all bin, obj & .vs folders Running .\devenv.exe
  • /ResetUserData Running .\devenv.exe /UpdateConfiguration &
    .\devenv.exe /ClearCache
  • Update and re-install Visual Studio
  • turn off all extensions I have tried to clean and rebuild the project
  • Delete folder ComponentModelCache on path C:\Users{user}\AppData\Local\Microsoft\VisualStudio{version}
  • Reset Visual Studio to system Default
  • Sign in to the Visual Studio via different account

I suspect the issue is somewhere in the project and my machine since other projects works fine in this scenario. Still other coleagues can change whatever they want and publish without any issues. On my coworker laptop the issue is gone even if I sign in with my own Profile and pull the branch where I have made changes.

Worth noting that other projects in the company does not run on the same framework. No project that runs on the same framework as the one that I am facing the issue can be tested, except a dummy project that I have created and there the issue is gone.

I am hopeless and it is frustrating to ask my coworkers to publish the changes for me every time a new field or table is required

  • Target platform of the Database Project - SQL Server 2012
  • Visual Studio version - Version 17.8.7
  • .NET framework version - Version 4.8.09037

Solution

  • Workaround:

    Select properties of an entire solution: enter image description here

    Than change the configuration of Database project to any configuration and than back to the configuration you are using: enter image description here

    NOTE: Do not commit the solution changes otherwise the problem occurs again... Discard the changes and once you need to publish again repeat the process...