43

I have several database projects in the same solution. They all fail to publish. My Visual Studio version is Enterprise 2015. My SQL Server version is 12.0.4459.0.

The projects used to publish correctly on my machine. They publish correctly on my co-workers machines. I've not changed the database projects from the correctly publishing versions on my co-workers machines.

The steps I use to publish are as follows:

  • I right click and select publish.
  • I load the publish profile from the xml file.
  • I click publish.

What I'd expect to happen: The Data Tools Operations window is displayed and the project publishes successfully.

What actually happens: The Data Tools Operations window is not displayed. On switching to the Data Tools Operations window it is empty. The project is not published. Visual Studio subsequently operates normally apart from when it is closed. On closing Visual Studio a dialog is displayed saying "The solution cannot be closed while publishing".

Giles Roberts
  • 6,407
  • 6
  • 48
  • 63

8 Answers8

82

Edit: The old answer below worked for me once but was intermittent on subsequent occasions. I then noticed that I was actually getting an error displayed in the bottom left hand corner of Visual Studio:

Exception from HRESULT: 0x80041FE2 The tab has been closed.

Searching on the above returned this article: https://connect.microsoft.com/VisualStudio/feedback/details/827417/vs-express-2013-cannot-reopen-any-open-file-tabs-and-silently-closes-them-on-selection

So I closed all my open tabs and was then able to publish.

Old answer: To resolve this issue after clicking Publish, instead of clicking Load Profile I clicked Edit and browsed to the database server. I then clicked Test connection. The test connection came back successful. I then clicked Load Values for my SQLCMD variables. On clicking Publish, the database project published successfully.

After following the above steps, I was then able to publish again by my usual method of clicking Load Profile on the Publish Database dialog.

Giles Roberts
  • 6,407
  • 6
  • 48
  • 63
  • 8
    Thank you - seems like this issue is still happening even in vs 2019 :(. The strange thing is that in vs2019 if you try to close vs after you publish it tells you can't close it because the publishing is in progress... – Bogdan Aug 18 '19 at 16:14
  • 3
    Same for me in VS2019, even restarting Visual Studio twice did not work. Just close all windows/tabs. – KnarfaLingus Oct 05 '19 at 01:07
  • 1
    Seemed to happen for me after shelving a bunch of changes, some of which were in the database, and then trying to republish database. Fixed by closing tabs as well. – Lukas Oct 13 '20 at 16:37
  • Same here - closed all tabs and it worked. Thanks a lot! – Alexander Mihailov Jan 25 '21 at 10:43
  • I got myself into a state (which I can't reproduce) where I had the properties page for the project open in two different tabs, and got exactly the symptoms in the question. – Benjol Oct 28 '21 at 13:34
  • 1
    THREE years later since your last reply, Visual Studio ***Enterprise 2022*** this nonsensical behavior is still there. And as you described, it starts working after closing all tabs. ***Why*** is this a thing and ***why*** it does not trigger a more visible error message... – SPArcheon Aug 22 '22 at 14:29
26

I have a Visual Studio 2015 solution with database and SSIS projects. At some point publishing the database project stopped working as described above.

I closed all open tabs in the solution, and then was able to publish the database successfully.

4

And for me, under VS 2017, the solution was Rebuilding the DB project

ajeh
  • 2,652
  • 2
  • 34
  • 65
3

I had the same problem and the suggestions to close all the tabs worked for me, but that sucks. So, when I got the problem, I started closing tabs one at a time and found that for me, closing tabs related to Azure storage (blob containers, download status) let me publish again.

1

If you are working with multiple projects in one solution, then please close all working tabs and rebuild and re-publish the SQL project.

1

Checking in the Visual Studio 2019 (Build 16.8.4).

In the right corner, there is a link called "View Results."

enter image description here

When clicking on it, the separate tab should open with the details about the error.

For example, here is what appeared as an error in my case:

enter image description here

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42
0

Using Visual Studio 2019, the publish feature failed to generate script despite build succeeded. Following Gert Drappers advice on link below helped me:

  • Go to database project folder
  • Find .dbmdl file and rename it (so project can't find it. In my case I just removed it) and then try again. It worked for me.

https://social.msdn.microsoft.com/Forums/es-ES/62dfb033-91be-47fe-b252-a1671efc7983/ssdt-build-failed-error-sql72043-1-elements-are-in-an-error-state

-1

My Team Mate helped me to resolve the issue ---> in VS 2019 --> solution Explorer --> Switch views --> select the database project alone and publish ---> via this i was able to publish

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Welcome to Stackoverflow. This is not an answer to my problem above so shouldn't be posted as an answer. Try the other answers and see if they resolve your issue. It sounds like this might be a separate issue and you'd be best posting this as its own question. – Giles Roberts Jul 14 '21 at 09:44
  • My Team Mate helped me to resolve the issue ---> in VS 2019 --> solution Explorer --> Switch views --> select the database project alone and publish ---> via this i was able to publish – user16445928 Jul 14 '21 at 10:01
  • 1
    Great. Could you update your answer to reflect this solution please? – Giles Roberts Jul 14 '21 at 10:09