How to save the VS 2010 settings in Project file? - visual-studio-2010

Is there is a way to save the vs setting in project file(csproj/csproj.user).For eg i have two project called x and y, x should loads with a settings(font,fontsize,tab space) and different from y and then i don't want to import and export the *.vssettings in my vs every time.

This isn't directly possible, as the preferences are not project (or solution) based.
There are extensions that might provide a solution for you, like EditorConfig
If you're looking to simply share your settings between VS installs on multiple systems, there is a cloud sync feature in VS2012 (or you can use third party tools like this)

Related

Building related projects on Visual Studio

I am a Visual Studio noob. My background is more Unix-related and mostly used to building things via scons or make. I don't even have much Eclipse experience.
Anyway, I am frustrated how it seems very difficult to move files between projects in VS. (I am running Visual Studio 2013). For example, suppose I have a ProjectXRel (release) and I want a ProjectXDev (development). I want them both to be runnable, and the dev version might have just a few editing changes that differ it from the rel version.
The intuitive thought is to just copy the files from ProjectXRel to create ProjectXDev, but VS seems to fight me on that (it wants to rename all the namespaces to the title of the project).
Also, some of the files, like .cs files derived from .dbml via OR designer, seem uncopyable, and rely on one replicating the process of using the utility to having valid files. I'm used to a project being defined by its files, but that's not really the case in VS. Instead it seems defined by process steps used to create and organize the files.
Also, do serious developers just use command line calls and powershell? That's seems harder, but at least you know what the %#$$# is going on.....
So, the basic question is, how does one replicate an existing project to produce a similar one for development purposes? (I know source control such as git could help with that, but that's not an option for this situation.)
Thanks!
You should be using the same project for both Development and Release.
The things that are different between Development and Release should be stored in a config file (web.config or app.config, depending on what type of project).
You should then be using Configuration Transformations to transform that .config file into Development or Release.
In Visual Studio, right click on the project and click Add New Item, select "Application Configuration File".
In this file you can put connection strings or key/value pair settings in the AppSettings element (MSDN Link).
Once you have your basic settings defined, you can then right click on the config file and click Add Transformation. This will add transformations for each of the Project Configurations you have. (by default Debug and Release).
It will look like this:
Now you can build deployment packages.
Or install Slowchetah and then when you press F5 to debug it will run the selected project configuration with the configuration transformation applied.

VSCT: Different icons for different VS versions

I am making an extension for both VS2010 and VS2012 that has a toolbar command.
Given the change in icon style between them, I want to provide a separate icon for each.
How do I specify that in .vsct? I assume I might be able to use Condition, but I am not sure if there is already a pre-defined value with VS version.
It seems it is not possible without using an MSI, see "VS Package (VSIX): Having two different toolbar icons for VS2010/VS2012" on MSDN forums.
Ryan Molden (MSFT):
I do not believe you can use VSIX to install or specify target specific resources. VSIX is intended as a very simplistic deployment mechanism, it is in fact just a renamed ZIP file plus an installer with a small amount of logic to process pkgdef files. If you want more complex installs (like laying down different dlls based on your install target) I believe you would need to create an MSI.

Visual Studio Project vs. Solution

Being new to VS, how may I think of these two concepts, what is the difference?
I find some missing information in the other answers (at least for people who come from other IDEs like, say, Eclipse) . To say that a solution is a container for projects is only part of the thing. The conceptual feature of a VS project (what determines its 'granularity') is that one project produces one output: typically an executable or a library (dll). So, if you are going to code three executables that uses related code, you'll create one solution and at least three projects - probably more.
A solution is a container for projects, and tracks dependencies between projects.
Just to come up with a metaphor..
A solution is like a house, a project like a room. Each room provides a piece of functionality whereas the house, a container of rooms, provides the means to link the rooms together and organize them appropriately.
Kind of corny but I made it up on the fly, so bear with me :)
It doesn't help that Visual Studio seems to make things more confusing. "New Project" actually creates a new SOLUTION containing a project. "Open Project" actually opens a solution containing one (or many) project. (The file menu says "Open Project/Solution" but it really is opening solutions. There is no "Close Project" only "Close Solution" which is accurate.
So, in VS you are always working within a solution. Many solutions contain only one project and newer developers are likely to think of them as the same thing. However you can add other projects into a solution.
In case anyone decides to scroll down this far... I thought the MS docs did a pretty good job at describing the differences. I've copy pasted (and rephrased) the relevant bits here:
When you create an app, application, website, Web App, script, plug-in, etc in Visual Studio, you start with a project. In a logical sense, a project contains of all the source code files, icons, images, data files and anything else that will be compiled into an executable program or web site, or else is needed in order to perform the compilation. A project also contains all the compiler settings and other configuration files that might be needed by various services or components that your program will communicate with.
You don't have to use solutions or projects if you don't want to. You can simply open the files in Visual Studio and start editing your code.
In a literal sense, a project is an XML file (.vbproj, .csproj, .vcxproj) that defines a virtual folder hierarchy along with paths to all the items it "contains" and all the build settings.
In Visual Studio, the project file is used by Solution Explorer to display the project contents and settings. When you compile your project, the MSBuild engine consumes the project file to create the executable. You can also customize projects to product other kinds of output.
A project is contained, in a logical sense and in the file system, within a solution, which may contain one or more projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with any project. In a literal sense, the solution is a text file with its own unique format; it is generally not intended to be edited by hand.
A solution has an associated .suo file that stores settings, preferences and configuration information for each user that has worked on the project.
A Solution can have many Projects.
The Solution can also handle managing the dependencies between its different Projects...making sure that each Project gets Built in the appropriate order for the final Solution to work.
A project contains executable and library files that make up an application or component of an application.
A solution is a placeholder for logically related projects that make up an application. For example, you could have separate projects for your application's GUI, database access layer, and so on. The projects would be specific divisions for your program's functionality, and the solution would be the umbrella unifying all of them under one application.
A solution is a readable text file whose extension is .sln and having a structured content that describes the projects that it contains. A project is a readable XML formatted text file whose extension is .vcxproj and having a structured content according to its XML schema, and whose primary purpose is to contain the listing of source codes filenames and their dependencies or references to other project's source codes as well.
Solutions are containers for projects - you can also use them to organize items that are used across different related project (shared dll's and such).
Solutions are containers used by Visual Studio to organize one or more related projects. When you open a solution in Visual Studio, it will automatically load all the projects it contains.
When you create a new project in Visual Studio, it automatically creates a solution to house the project if there's not a solution already open.
You can set dependencies of projects on other projects in the solution. The dependent project is build after the project it is depending on is built.
For more details refer - https://learn.microsoft.com/en-us/visualstudio/ide/quickstart-projects-solutions
If you are from an Eclipse background you would probably go to build path of a project and add a dependency on other project or add an external jar. In VS you can do that in a single container called solution where all related projects are grouped together.
Eg. Let's say you are build and android and iOS app in xamrin, there would be some common code and resources that could go in a separate project and then your android and iOS projects can depend on this common code project. Also you could have projects to test these projects etc.

Is it possible to keep Visual Studio source control binding (to VSS2005) information in solution file (.sln) only and out of project files?

Basically, what I want to achieve, is to be able to have 2 separate solutions containing the same set of projects, but 1st solution needs to be bound to source control, 2nd - not.
So whenever you want source control integration in Visual Studio, you can open 1st solution, but if you don’t want it, you can open the 2nd one.
The problem is, that VS stores some binding info in the project files, and while it is there, no matter what solution the project is part of, it will have source control integration when opened in VS.
Is it possible to have all the binding info in the .sln file only?
Or maybe there is another solution form my problem?
Edit: the reason I want to do that is because some of the team members prefer to have source control integration in Visual Studio, the others don't. Having 2 solutions would give them a choice.
No.
It couldn't be the same set of projects - the files in a project are either source controlled or not, but you could have a non-source-controlled copy of a version retrieved from source control.
You could probably automate the process of removing source control bindings. So you would get a solution from source control, make a copy, and remove the source control bindings from the copy.
I've needed this in the past in the following situation: a source-controlled solution with a shared class library and a sample application that uses the shared library. I wanted to be able to ship a ZIP file containing the sample application without source control bindings.
This is technically possible. Open the File -> Source Control -> Change Source Control dialog and you can adjust the bindings for each individual project, including the root solution. However, it probably won't do what you want. If you remove the bindings from the projects but keep the solution binding, you'll end up in a state where changes to the solution itself (e.g. stuff you do in Configuration Manager) are automatically checked in & out, but changes to files that are "owned" by the individual project systems won't be.
The best answer IMO is to have the developers who don't like SCC integration adjust the settings in Tools -> Options -> Source Control -> Environment to their liking. Here you can turn off most (all?) of the SCC features that act "behind your back." And they are all strictly per-user, stored in the HKCU registry rather than your makefiles.

Visual Studio 2005/2008: How can you share/force all developers to use the same formatting rules?

I would like to have all developers on my team to use the same rules for formatting several types of code (ASPX, CSS, JavaScript, C#). Can I have visual studio look to a common place for these rules?
I would like to not rely on export/import settings as that brings many settings along. I (for example) don't care what font colors the developer uses when typing, I just want similar formatting. Can you import a subset of settings?
StyleCop, originally called "Source Analysis" is the best choice for C#. The first version was rather inflexible, but after recognizing the value that it provides for the community, Microsoft has opened it up to extensions and customizations. It's a solid tool.
For Visual Studio settings, it's trivial to export a sub-set of your settings into a .settings file and require that other team members import and use these settings.
Like any standards, the tools are only as good as the team members, so it probably goes without saying that you will need team buy-in regardless of what tool you use for enforcement.
If you're using C#, take a look at StyleCop.
Visual Studio uses the settings in Tools > Options > Text Editor > [your language] > Formatting to set how it auto-formats code.
You can set it up how you like and then use Tools > Import and Export settings to create a .settings file for your team to import and use. It won't enforce rules, but it will make the default VS behavior the same for everyone.
There is a tool called NArrange which will arrange your code. This is particular useful to avoid conflicts in source control systems, but also has several other advantages. Check out the web site.
No-one's mentioned Team Settings yet? You just export the desired settings to a network share, then get everyone to map to it. Job's a good 'un.
Tools -> Options -> Import and Export Settings, then tick "Use Team Settings"
An extensive use of Visual Assist's snippets (bits of pre-formatted codes) may help...
I second Luke's answer. StyleCop can help you enforce common coding style across your team. If you want to share formatting rules take a look at ReSharper AFAIK it allows you to export and share this settings.
Editor settings are stored in the registry, so no luck having a single source for them. You'll need to go with an external tool to ensure uniformity.
A free, quick solution would be exporting the relevant registry settings and loading them up on everyone's machine. They'll still be able to change them (and they will -- naughty developers!), but you'll at least have a common starting point.
We use the following tools:
StyleCop (as mentioned before)
Resharper
StyleCop for Resharper
The reason we use the latter two is twofold: First you are able to do a Clean Up of your code. This allows you to clean your code in one go and solve all warnings. At least that is what the brochure says. In reality you need to set quite a few settings in Resharper. Have a look at links like this to see how that works. Second: Resharper integrates the Stylecop violations in the source editor. Extremely useful as they are visible while writing code and can therefore be solved on the spot.
Code Review.

Resources