开发者

How can I close all the document windows in Visual Studio from an external script?

开发者 https://www.devze.com 2023-01-07 08:27 出处:网络
I\'m creating the software for a course.What with exercise start points and worked solutions and both C# and VB I have about 100 VS2010 solutions.

I'm creating the software for a course. What with exercise start points and worked solutions and both C# and VB I have about 100 VS2010 solutions.

During development I reopen these as neccessary and they get a lot of tweaking. When I'm done I want to leave the solutions with NO documents open. That way when the student opens the solution it's a very clean view, not littered with the files I was last looking at.

Up to VS2008 this was was easy. I simply deleted all the *.suo files - that seems to be where VS stores the window layout. When a solution was opened VS happily created a new SUO file. This approach was suggested in Close all files in visual studio on exit

With VS2010 this causes an annoying dialog...

Security warning for You should only open projects from a trustworthy source

This is completely reproducible.

  1. Open one开发者_StackOverflow社区 of the solutions, for which there is no SUO file
  2. VS gives a trust warning. User accepts it. SUO file is created.
  3. Subsequent opening of the SLN don’t report trust problems.
  4. Delete the SUO file.
  5. Reopen the SLN and the trust errors reoccurs.

How can I achieve my ambition of having VS open up with no document windows open, and no security dialog? I really want it to be automated from OUTSIDE VS. Opening all of 100 solutions and manually closing the windows is NOT what I'm looking for.

It's pretty easy to create a macro that will close all windows, but I cannot see a way of starting VS from the command line and getting it to run a macro on startup.


This sounds like you downloaded the project file from an untrusted source. Scott Hanselman wrote a blog post about it. The short story is that if you go to the properties page for the project file (windows explorer -> right click project file -> properties), you can unblock the file with the button at the bottom:

How can I close all the document windows in Visual Studio from an external script?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号