Diffing web.config is hard, any way to prevent IIS Manager from formatting Web.config differently than Visual Studio's format? - visual-studio-2010

this drives me crazy.
Visual Studio does not format Web.config the same way than IIS Manager, which prevent easy diffing of different versions or the same file editing in both tools.
When Visual Studio edits a Web.config thru a wizard (like adding a reference) or when you click on Edit\Format Document (Ctrl+K, Ctrl+D), Visual Studio formats the XML in a beautiful way.
Unfortunately, if you change a value in IIS, it will reformat it with a different style.
Do you know any workaround?

no matter how ugly the xml is inside a file, when you open the file with visual studio press control k and then control d and it will format the XML for you instantly.

Related

Cant save BIML file in Visual Studio

I have just started trying to use BIML to generate my SSIS packages. Im currently using VIsual studio 2015 to do everything.
When I add a new BIML file to the project it appears in the Solution explore and I can open the file and edit it. But when I save and close and reopen none of the changes where saved. Is there a setting that i need to change in Visual Studio? Currently I have to edit this file through the use of Notepad++ or something similar.
Visual Studio ScreenShot
As a work around to this issue, you could right click on the file you wish to edit and choose XML (Text) Editor.
Sadly you'll loose intellisence for the C# code
If you open a file twice, once in the BIML editor and once in the XML editor then you can view side by side making your changes in XML but viewing nice formatting in BIML...

How does Visual Studio choose which editor to use for a file?

My project stores html code fragments for use in templating in files with a custom extension (*.phtml). I find that Visual Studio is inconsistent in its use of editors when I edit these files. Sometimes it provides no intellisense, sometimes it treats the files as XML (which is better than nothing), and sometimes I get lucky and it provides me with the HTML editor.
I've configured Visual Studio to treat *.phtml files as HTML, but that doesn't seem to make any difference.
What more can I do to convince Visual Studio to always use the HTML Editor for *.phtml files?
Right-clicking a file in solution explorer shows an "Open with ..." option, the window that it opens has a choice of editors plus a "Set as default" option.

How to enable open XML Package Editor power tool for Visual Studio

I want to create customized ribbon on my excel sheet. I saw some of the tutorial (e.g, http://www.youtube.com/watch?v=hn3Qkp4Jw34) where they used Open XML package editor power tool for visual studio 2010 and worked on some xml configuration file to add ribbon. Hence I downloaded the tool and installed it. But when I drag and drop the excel file to the VS-2010, the file instead of opening in the VS editor it is opening in its new excel window. I tried to do same thing for a word file but still it is opening in new word window instead of opening in VS editor. Anybody could you please help me regarding this. I was using Visual Studio 2012 but then I came to know that Open XML package editor power tool for visual studio 2010 won't work for VS-2012 hence Installed VS-2010 but still getting same problem.
Thank you
Anup, Have you tried going to File->Open from Visual Studio?
If that opens it from an Office client application as well, then the Visual Studio Package Editor is not the default option for opening documents of that file extension.
If the document is a part of a solution (you can just create a new blank solution and add it in) you can right click on the file from Solution Explorer and choose "Open With", from there you can choose to open that file as a "Package File", and you can also select this as the default way to "open" files of that extension in Visual Studio.
I work for Microsoft and have just updated this plugin to work with VS2012 and 2013. Drag and drop should work in all the VS versions (I just tested it) but perhaps it's worth trying downloading the updated extension from the Gallery and seeing if it works for you in the newer VS version.

Can Visual Studio 2010 do ".inc" file syntax highlighting?

Can Visual Studio 2010 be configured to do syntax highlighting on ".inc" files? We have numerous large projects with tons of these ".inc" files (asp files) and so changing the file extension to ".asp" is not an option. All I want Visual Studio 2010 to do is treat these ".inc" files just like ".asp" files when it comes to syntax highlighting.
I've tried "Open With..." and selected the HTML Editor, which is the ".asp" default, but that did not work. I tried about every other editor in the list and none of them worked.
I know Notepad++ (among others) can do this, but I would prefer this be done in Visual Studio 2010 - using another IDE or text editor is not the answer I'm looking for here.
In Visual Studio...go to Options -> Text Editor -> File Extension. Type in 'inc' as extension and editor as 'Web Form Editor'. You may need to close then re-open your currently open .Inc pages...Hope this helps
I found both the 'Web Form Editor' and 'HTML Editor' to be less than ideal for me. Both of them appeared to highlight the syntax of the HTML ok, but the VBScript keywords were left in standard black text along with everything else.
While not ideal, I followed the instructions from the other answers, but substitude Visual Basic as the editor type and that worked much more to my liking (as they were include files, there is little HTML in them).
Options -> Text Editor -> File
Extension. Type in 'inc' as extension and set editor as 'Visual Basic'.
Close and re-open any '.inc' files and highlighting should be visible.
Antonio's solution worked for me. I did have to close and reopen files, but after I re-opened them the highlighting was visible. Thanks!
Options -> Text Editor -> File Extension.
Type in 'inc' as extension and set editor as 'Web Form Editor'.
Close and re-open any '.inc' files and highlighting should be visible.
Incidentally, this also works in Visual Studio 2005.
Use the File Extension, Text Editor, Options Dialog Box.
http://msdn.microsoft.com/en-us/library/4k7w5e5s.aspx
-update-
I see the same behavior :-( Will let you know if I find anything.
As a workaround, could you rename all your .inc files to .asp?
This has the added advantage that if a request is made for the inc file directly (highly unlikely but possible; and assuming you have the incs in the web directory), your code will be exposed unlike .asp where it is processed and rendered.
I really wanted to add a comment, because this is not a direct answer, but apparently you need 50 reputation for that.
I've found that in Visual Studio 2005 (again, in Tools -> Options -> Text Editor -> File Extension), both "Web Form Editor" and "User Control Editor" highlight both the HTML and the VBScript.
Amadiere mentioned that "Web Form Editor" doesn't highlight the VBScript in 2010, but maybe it's worth trying "User Control Editor", if that's an option in 2010.
In Visual Studio 2010 and 2012 Express it best works for me when I use "Microsoft Visual Basic" with my .inc files. Nevertheless, it's still not the same as with .asp files as there's no Autocomplete nor IntelliSense (Ctrl+Space, Ctrl+Shift+Space etc.) with the .inc files.
It should be made possible defining that .inc files are to be treated just as .asp files.
I agree with Purple Coder:
You should not name the files containing ASP code as .inc. It is a security risk. Anyone who knows/can guess the filename can open it in a browser and view the actual code inside the file.
But, first of all in my case this is an intranet page and therefore not very risky, as most people there would somehow find the files on the server anyway. I'm also not sure where this naming convention came from. It was there before I started. This was started on Visual Studio 6.
But, to avoid this risk there's a simple solution: add .inc in the Application Mapping of the IIS in the same manner as .asp.
You should not name the files containing ASP code as .inc. It is a security risk. Anyone who knows/can guess the filename can open it in a browser and view the actual code inside the file.

Is there a visual studio automatic save configuration setting?

I use the java IDE IntelliJ IDEA and one of the features I like is that there's no saving. Everything's always saved and you just use history navigation. I tend to have both editors open and I'm always forgetting to save in VS.
I'm running vs 2008 with resharper 4.5 but as far as I can tell this isn't achievable or configurable.
Any suggestions?
For VS 2019, the Auto Save File extension seems to work as expected.
It saves individual files on lost focus, can save all files when VS loses focus and can also save all after an inactivity delay.
In VS 2015, I used to use NoMorePanicSave2015.
It does an equivalent of Ctrl+Shift+S when Visual Studio loses focus, which saves all your files, including solution and projects.
Another plugin: CBAutoSave
This extension can automatically save modified documents, projects, and the solution whenever Visual Studio loses focus.
Saving of modified documents is on by default, while automatically saving projects and the solution is not. All options are configurable through the Visual Studio options dialog.
In VS2017/19 Community there is Auto-Recover option under tools->options->autorecover. It will not autosave unless there is a crash, so it may be a good compromise.
In VS2019 its under tools->Options->Environment-AutoRecover.
how-to-auto-save-work-on-visual-studio
Visual Studio 2008 will probably be the same:
http://www.howtogeek.com/howto/programming/configure-autosave-autorecovery-of-crashed-projects-in-visual-studio-2005/
However, it's not "no saving" but you can set it down to 1 minute.
Visual Studio 17.2 can now automatically save code documents whenever the application loses focus. This feature can be accessed via Tools > Options > Environment > Document.
There is an autosave, but I must admit that it doesn't seem to always work for me - notably I suspect that it only saves files, but not projects/solutions, or the .user and .suo files. I don't have any links to prove this mind you.
Visual Studio 2022 (Enterprise) has auto save option. But you have to enable it.
Navigate from Tools > Options > Environment > Preview Features and Enable the autosave.
here is a screenshot

Resources