In .NET, there are SUO, SLN, Proj files for every solution/project. Whilst I know what these files are, is it wise to edit them by hand? Do they ever even need to be edited? If so, what is the best way?
Thanks
In .NET, there are SUO, SLN, Proj files for every solution/project. Whilst I know what these files are, is it wise to edit them by hand? Do they ever even need to be edited? If so, what is the best way?
Thanks
You can edit many of the files available. There are even instructions for doing it in the documentation http://msdn.microsoft.com/en-us/library/ms171487(v=VS.90).aspx
Solution files are NOT in XML format and you can find information on the content of .SLN files here: https://msdn.microsoft.com/en-us/library/bb165951(v=vs.140).aspx
Project files are MSBuild scripts so they are frequently edited (either with a tool or manually) to include items that modify the build configuration to meet your needs. Here is a link to the MSBuild reference that may help: http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx
.SUO files are your user options and shouldn't be edited directly. I have personally used the binary editor and edited it just to see if it can be done with success but you do so at your own risk.
The project files can easily be edited by hand - you have to do it sometimes to add items to the project that MSBuild supports but Visual Studio does not support the editing of (such as conditional elements). I have an add-in for Visual Studio (I think it might be PowerCommands) that adds an "Edit project file" option to the context menu in Solution Explorer. Clicking it unloads the project from Visual Studio and opens the prof file as XML to be edited in Visual Studio's XML editor.
The SLN files are not XML, but they do not really contain anything that would be worth editing by hand.
I think the SUO files are binary and shouldn't be edited (they only contain user-specific values for the solution).
Sure, I occasionally have the need to edit them. Recently, I had a project file that had the flag enabled to register the assembly as a COM object. After I removed all COM-visible classes, this generated a warning, so I removed that line from the project file. I used Notepad.
Have to edit them very rarely. One case was modification of the ProjectTypeGuids, so that it was recognized properly in Expression Blend. Couple of other times had to make some manual changes to references no longer existent.
All in all it has been few and far between. The .prj files are XML so any good XML editor would suffice. The properties page in VS obviously references the .prj file as well for changes not wanting to be made by hand.
I've never had to edit a SUO file - not even sure what it does.
With respect to .sln and .proj files, they are certainly editable by hand, but for anything complicated, I find it'd better to let VS do the hard work, followed by surgical editing of the files as required.
One thing that's made a lot of difference in my place of work is the adoption of PropertySheets to define a common set of settings across different projects.
When editing the project files, you can right-click the project in Visual Studio, and choose Unload Project. You can then right-click the same project (now greyed out) and choose edit. Once, complete, again right-click and choose Reload.
Many of our csproj files are edited for using advanced msbuild features. One common thing is to change the beforebuild and afterbuild targets for custom tasks.
You can do this from visual studio by right clicking on a project and selecting unload project from the context menu. After that you can edit and reload the project using right click again.