locked
Visual Studio Caching Files RRS feed

  • Question

  • We have an addin that uses files off of disk (part of the backend watches for file changes). Very often we get things were VS saves 1/2 of something, as an example when renaming a file it will rename the file but not save the project. Is there anyway to force VS (either by watching events ourselves and forcing saves or some config property?). 

    Thanks in advance,

    Greg

    Thursday, February 10, 2011 2:23 PM

Answers

All replies

  • It partly depends upon which files you are referring to.

    For instance, if you're dealing with a designer surface you can use the flush() member function http://msdn.microsoft.com/en-us/library/system.componentmodel.design.designsurface.flush.aspx.

    For projects, EnvDTE.Project.Saved indicates if the project has been saved.

    Do you have a specific file you are looking at?

    Thursday, February 10, 2011 6:42 PM
  • We are on the outside listening for filesystem events... We also have an addin. Is there a way we could even trap something like a rename etc and force the projects to save? I think adding a new project causes this as well. Basically as if the user were to hit ctrl+shift+s 
    Thursday, February 10, 2011 10:40 PM
  • Hi Greg,

    Your scenario sounds very similar to what happens when the user invokes the build command. Take a look at Tools -> Options -> Projects and Solutions -> Build and Run. Note the first dropdown ("Before Building") and the default value ("Save all changes").

    Could you expose a similar option to control the behavior here? Perhaps something like "When MyAddin is active and an item is renamed or project is added" (you can probably come up with something more elegant).

    Issuing an automatic SaveAll is OK, but having the option there at least gives the user the ability to understand why the SaveAll is happening.

    Regards,
    Aaron

     


    http://blogs.msdn.com/aaronmar
    Friday, February 11, 2011 2:40 PM
  • Yes it is similar to the build command. Is there an easy way for me to trap adding a project or renaming an item?
    Friday, February 11, 2011 6:50 PM
  • Yes it is similar to the build command. Is there an easy way for me to trap adding a project or renaming an item?
    Any follow up on this?
    Wednesday, February 16, 2011 1:44 PM
  • You should be able to use the events exposed by the DTE for this:

    http://msdn.microsoft.com/en-us/library/envdte.projectitemseventsclass.aspx

    Thanks,

    Aaron


    http://blogs.msdn.com/aaronmar
    Wednesday, February 16, 2011 4:52 PM