views:

102

answers:

8

Hi,

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

A: 

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.

Steven Sudit
+3  A: 

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.

Even though the SLN files are XML, 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).

adrianbanks
A: 

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.

Aaron
A: 

I've manually edited .proj files to add or modify build targets because the company's build process for a particular product was very rigid and did not handle non-x86 targets. Wrote up a quick script that would make the necessary changes in the file, though I'm not sure if it would work with anything other than Visual Studio 2005.

Another thing I've had to do was downgrade solution/project files from 2005 to 2003.

Thankfully, we use cmake now.

birryree
A: 

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.

cristobalito
A: 

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.

Pratik
Can't this be done from the IDE directly?
Steven Sudit
@stephen In the ide you have the option to run a command script. You can do far more in custom MSBUILD. Of course you an alays shell out to another MSBUILD process in the command script.
Preet Sangha
+1  A: 

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: http://msdn.microsoft.com/en-us/library/bb165951(v=VS.90).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.

zainnab
A: 

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.

jnielsen